Skip to content

Commit

Permalink
fix(service-registry create): fetch registry URL after creation (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkpattnaik780 authored May 25, 2022
1 parent 71e66bb commit 5f71a87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
28 changes: 17 additions & 11 deletions pkg/cmd/registry/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions pkg/core/localize/locales/en/cmd/registry_crud.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 5f71a87

Please sign in to comment.