From 49a6a661c5f71d86be37510ec0c6979bceb74949 Mon Sep 17 00:00:00 2001 From: Enda Date: Thu, 14 Jan 2021 14:56:16 +0000 Subject: [PATCH] refactor(topics): validate user session earlier (#224) --- pkg/cmd/kafka/topics/create/create.go | 5 +++++ pkg/cmd/kafka/topics/delete/delete.go | 5 +++++ pkg/cmd/kafka/topics/list/list.go | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/pkg/cmd/kafka/topics/create/create.go b/pkg/cmd/kafka/topics/create/create.go index b75665a30..53ea24cc3 100644 --- a/pkg/cmd/kafka/topics/create/create.go +++ b/pkg/cmd/kafka/topics/create/create.go @@ -58,6 +58,11 @@ func NewCreateTopicCommand(f *factory.Factory) *cobra.Command { } func createTopic(opts *Options) error { + _, err := opts.Connection() + if err != nil { + return err + } + logger, err := opts.Logger() if err != nil { return err diff --git a/pkg/cmd/kafka/topics/delete/delete.go b/pkg/cmd/kafka/topics/delete/delete.go index b43072ec7..26885bf56 100644 --- a/pkg/cmd/kafka/topics/delete/delete.go +++ b/pkg/cmd/kafka/topics/delete/delete.go @@ -46,6 +46,11 @@ func NewDeleteTopicCommand(f *factory.Factory) *cobra.Command { } func deleteTopic(opts *Options) error { + _, err := opts.Connection() + if err != nil { + return err + } + logger, err := opts.Logger() if err != nil { return err diff --git a/pkg/cmd/kafka/topics/list/list.go b/pkg/cmd/kafka/topics/list/list.go index bac98359a..941cdbd50 100644 --- a/pkg/cmd/kafka/topics/list/list.go +++ b/pkg/cmd/kafka/topics/list/list.go @@ -43,6 +43,11 @@ func NewListTopicCommand(f *factory.Factory) *cobra.Command { } func listTopic(opts *Options) error { + _, err := opts.Connection() + if err != nil { + return err + } + logger, err := opts.Logger() if err != nil { return err