Skip to content

Commit

Permalink
refactor(context): reuse helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rkpattnaik780 authored and wtrocki committed Apr 11, 2022
1 parent bb51d04 commit 08a552b
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions pkg/shared/contextutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,9 @@ func GetCurrentKafkaInstance(f *factory.Factory) (*kafkamgmtclient.KafkaRequest,
return nil, err
}

if svcContext.CurrentContext == "" {
return nil, f.Localizer.MustLocalizeError("context.common.error.notSet")
}

currCtx, ok := svcContext.Contexts[svcContext.CurrentContext]
if !ok {
return nil, f.Localizer.MustLocalizeError("context.common.error.context.notFound", localize.NewEntry("Name", svcContext.CurrentContext))
currCtx, err := GetCurrentContext(svcContext, f.Localizer)
if err != nil {
return nil, err
}

if currCtx.KafkaID == "" {
Expand Down Expand Up @@ -90,13 +86,9 @@ func GetCurrentRegistryInstance(f *factory.Factory) (*registrymgmtclient.Registr
return nil, err
}

if svcContext.CurrentContext == "" {
return nil, f.Localizer.MustLocalizeError("context.common.error.notSet")
}

currCtx, ok := svcContext.Contexts[svcContext.CurrentContext]
if !ok {
return nil, f.Localizer.MustLocalizeError("context.common.error.context.notFound", localize.NewEntry("Name", svcContext.CurrentContext))
currCtx, err := GetCurrentContext(svcContext, f.Localizer)
if err != nil {
return nil, err
}

if currCtx.ServiceRegistryID == "" {
Expand Down

0 comments on commit 08a552b

Please sign in to comment.