From 5f71a871caa4d5aa7ff4b058f68538184c7ada41 Mon Sep 17 00:00:00 2001 From: Ramakrishna Pattnaik Date: Thu, 26 May 2022 03:34:01 +0530 Subject: [PATCH] fix(service-registry create): fetch registry URL after creation (#1580) --- pkg/cmd/registry/create/create.go | 28 +++++++++++-------- .../locales/en/cmd/registry_crud.en.toml | 7 +++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/pkg/cmd/registry/create/create.go b/pkg/cmd/registry/create/create.go index c46ff7ff0..4b54b1ae7 100644 --- a/pkg/cmd/registry/create/create.go +++ b/pkg/cmd/registry/create/create.go @@ -18,6 +18,7 @@ import ( "github.com/redhat-developer/app-services-cli/pkg/shared/contextutil" "github.com/redhat-developer/app-services-cli/pkg/shared/factory" "github.com/redhat-developer/app-services-cli/pkg/shared/remote" + "github.com/redhat-developer/app-services-cli/pkg/shared/serviceregistryutil" srsmgmtv1 "github.com/redhat-developer/app-services-sdk-go/registrymgmt/apiv1/client" srsmgmtv1errors "github.com/redhat-developer/app-services-sdk-go/registrymgmt/apiv1/error" @@ -150,23 +151,28 @@ func runCreate(opts *options) error { return opts.localizer.MustLocalizeError("registry.cmd.create.error.limitreached") } + opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("registry.cmd.create.info.successMessage")) + + registry, _, err := serviceregistryutil.GetServiceRegistryByID(opts.Context, conn.API().ServiceRegistryMgmt(), response.GetId()) if err != nil { return err } - opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("registry.cmd.create.info.successMessage")) - - compatibleEndpoints := registrycmdutil.GetCompatibilityEndpoints(response.GetRegistryUrl()) + if err = dump.Formatted(opts.IO.Out, opts.outputFormat, registry); err != nil { + return err + } - opts.Logger.Info(opts.localizer.MustLocalize( - "registry.common.log.message.compatibleAPIs", - localize.NewEntry("CoreRegistryAPI", compatibleEndpoints.CoreRegistry), - localize.NewEntry("SchemaRegistryAPI", compatibleEndpoints.SchemaRegistry), - localize.NewEntry("CncfSchemaRegistryAPI", compatibleEndpoints.CncfSchemaRegistry), - )) + if registry.GetRegistryUrl() != "" { + compatibleEndpoints := registrycmdutil.GetCompatibilityEndpoints(registry.GetRegistryUrl()) - if err = dump.Formatted(opts.IO.Out, opts.outputFormat, response); err != nil { - return err + opts.Logger.Info(opts.localizer.MustLocalize( + "registry.common.log.message.compatibleAPIs", + localize.NewEntry("CoreRegistryAPI", compatibleEndpoints.CoreRegistry), + localize.NewEntry("SchemaRegistryAPI", compatibleEndpoints.SchemaRegistry), + localize.NewEntry("CncfSchemaRegistryAPI", compatibleEndpoints.CncfSchemaRegistry), + )) + } else { + opts.Logger.Info(opts.localizer.MustLocalize("registry.cmd.create.info.compatibilityEndpointHint")) } if opts.autoUse { diff --git a/pkg/core/localize/locales/en/cmd/registry_crud.en.toml b/pkg/core/localize/locales/en/cmd/registry_crud.en.toml index 7882f8de2..b519cc8e4 100644 --- a/pkg/core/localize/locales/en/cmd/registry_crud.en.toml +++ b/pkg/core/localize/locales/en/cmd/registry_crud.en.toml @@ -46,6 +46,13 @@ one = 'Successfully created Service Registry instance' [registry.cmd.create.info.action] one = 'Creating Service Registry instance with name: {{.Name}}' +[registry.cmd.create.info.compatibilityEndpointHint] +one = ''' +Run the following command to view service status + + $ rhoas service-registry describe +''' + [registry.cmd.delete.shortDescription] one = 'Delete a Service Registry instance'