Skip to content

Instantly share code, notes, and snippets.

@rkpattnaik780
Created March 28, 2022 13:31
Show Gist options
  • Save rkpattnaik780/e04e3f4ad9010d974b9dbe3e0df0c1af to your computer and use it in GitHub Desktop.
Save rkpattnaik780/e04e3f4ad9010d974b9dbe3e0df0c1af to your computer and use it in GitHub Desktop.
GetCurrentContext
// GetCurrent_Context returns the name of the currently selected context
func GetCurrent_Context(svcContext *servicecontext.Context, localizer localize.Localizer) (*servicecontext.ServiceConfig, error) {
if svcContext.CurrentContext == "" {
return nil, localizer.MustLocalizeError("context.common.error.notSet")
}
currCtx, ok := svcContext.Contexts[svcContext.CurrentContext]
if !ok {
return nil, localizer.MustLocalizeError("context.common.error.context.notFound", localize.NewEntry("Name", svcContext.CurrentContext))
}
return &currCtx, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment