Skip to content

Commit

Permalink
fix(service-registry create): improve error handling (#1814)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkpattnaik780 authored Feb 23, 2023
1 parent 63e0eba commit 4512b73
Show file tree
Hide file tree
Showing 29 changed files with 564 additions and 167 deletions.
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ require (

require (
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/accountmgmt/apiv1/client v0.0.0-20230216114230-4ff0373de47f
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/connectormgmt v0.0.0-20230220160753-3c2c52e7e98a
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkainstance v0.0.0-20230220160753-3c2c52e7e98a
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/connectormgmt v0.0.0-20230222114134-d97c4c88765b
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkainstance v0.0.0-20230222114134-d97c4c88765b
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkamgmt v0.0.0-20230220160753-3c2c52e7e98a
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registryinstance v0.0.0-20230220160753-3c2c52e7e98a
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registrymgmt v0.0.0-20230220160753-3c2c52e7e98a
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/serviceaccountmgmt v0.0.0-20230220160753-3c2c52e7e98a
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registryinstance v0.0.0-20230222114134-d97c4c88765b
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registrymgmt v0.0.0-20230222114134-d97c4c88765b
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/serviceaccountmgmt v0.0.0-20230222114134-d97c4c88765b
)

require (
Expand Down Expand Up @@ -96,7 +96,7 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go v0.1.0 // indirect
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go v0.2.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 // indirect
Expand Down
23 changes: 12 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -691,22 +691,23 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go v0.1.0 h1:bl64y8lVc+rcda483ZvJr+GjuhsQQhkrzUiDfzPjB4Q=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go v0.1.0/go.mod h1:JPNDOitDoHoHk5ZPRjfOxHQhE4Br0WtiyV8m43E0rso=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go v0.2.0 h1:N2FoVU7tD8S94+xmgYDOfbLJpZz4o6bVoub7D/jFWC4=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go v0.2.0/go.mod h1:JPNDOitDoHoHk5ZPRjfOxHQhE4Br0WtiyV8m43E0rso=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/accountmgmt/apiv1/client v0.0.0-20230216114230-4ff0373de47f h1:jXUB35TstK4p1JkhMTU0xGRsoNlnwffv4qX9E3LRMck=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/accountmgmt/apiv1/client v0.0.0-20230216114230-4ff0373de47f/go.mod h1:I2ayTdtOFVLwyASlzvbnKaz23v9c/GiJazXek2k1yUg=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/connectormgmt v0.0.0-20230220160753-3c2c52e7e98a h1:8viwGaF7yMMYX1RJTkH7DUkhuND9b2v0LaPcrIoYWs0=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/connectormgmt v0.0.0-20230220160753-3c2c52e7e98a/go.mod h1:gK7/wdWr89PXSQbJ/KlaBVMdspFkDboi8yQqVuM5Ke0=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkainstance v0.0.0-20230220160753-3c2c52e7e98a h1:k2wz3MgCKzTbOSvhSRD0hXjgfgMzarRZP528kCpcH1E=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkainstance v0.0.0-20230220160753-3c2c52e7e98a/go.mod h1:eJWRq/utm2rgeF/CVTeiMdlUAlEoYE5P3/13KAJyaL8=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/connectormgmt v0.0.0-20230222114134-d97c4c88765b h1:ZbZfNu6+bP2Im8ZIhC3d7yE/SthmuTc5tpvoYBHh8kM=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/connectormgmt v0.0.0-20230222114134-d97c4c88765b/go.mod h1:gK7/wdWr89PXSQbJ/KlaBVMdspFkDboi8yQqVuM5Ke0=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkainstance v0.0.0-20230222114134-d97c4c88765b h1:XL00la+2TXfgI5NibnqlM/2y44FrQv7N/XKqgPYxSqU=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkainstance v0.0.0-20230222114134-d97c4c88765b/go.mod h1:eJWRq/utm2rgeF/CVTeiMdlUAlEoYE5P3/13KAJyaL8=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkamgmt v0.0.0-20230220160753-3c2c52e7e98a h1:LhFKr0iCPdEUSaIzrl+2Y6CXqV5fkfUktwCDnH2wdeQ=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkamgmt v0.0.0-20230220160753-3c2c52e7e98a/go.mod h1:AHZLQfBqzwY+uDWfo577AipCpnFPG4GNXTnXyWeFKD4=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registryinstance v0.0.0-20230220160753-3c2c52e7e98a h1:VMkueGJm/lHF0SmNUrUYqrwQzquahX3ZkjUdOll2j+4=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registryinstance v0.0.0-20230220160753-3c2c52e7e98a/go.mod h1:Pvw6KeJUK9tdvCHkDIoXcWUyjxWc3Nn//Eax2mcbMJ0=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registrymgmt v0.0.0-20230220160753-3c2c52e7e98a h1:t0a5qZfNfRjw2fKlyzM878cZOGIpfjLHKJ9jw3y61Ak=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registrymgmt v0.0.0-20230220160753-3c2c52e7e98a/go.mod h1:T20A1WmLYXFpA5QntaAF1B44uj9geAgUbTco0qIX7kY=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/serviceaccountmgmt v0.0.0-20230220160753-3c2c52e7e98a h1:tkIWnEabTTum0iB2mPVAJVdPES296Qo5qPxeBZnzwBY=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/serviceaccountmgmt v0.0.0-20230220160753-3c2c52e7e98a/go.mod h1:9UjE86bWDvSfAwSAqweZPRNEAjAgI0ZvKYMIoz06qd0=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registryinstance v0.0.0-20230222114134-d97c4c88765b h1:fz4sahm2HQq5dJV7M8LUldosM2RAXzVthn6pUEBSeFM=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registryinstance v0.0.0-20230222114134-d97c4c88765b/go.mod h1:Pvw6KeJUK9tdvCHkDIoXcWUyjxWc3Nn//Eax2mcbMJ0=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registrymgmt v0.0.0-20230222114134-d97c4c88765b h1:tYahCNjxLYtikqnhIdbGyEP+zZ2bkEtxnpJQhN0Se6s=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registrymgmt v0.0.0-20230222114134-d97c4c88765b/go.mod h1:T20A1WmLYXFpA5QntaAF1B44uj9geAgUbTco0qIX7kY=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/serviceaccountmgmt v0.0.0-20230222114134-d97c4c88765b h1:+4KWvTNPiEaz7f8Nncbkyag9MEO9u22d2ijrojAwP1c=
github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/serviceaccountmgmt v0.0.0-20230222114134-d97c4c88765b/go.mod h1:9UjE86bWDvSfAwSAqweZPRNEAjAgI0ZvKYMIoz06qd0=
github.com/redhat-developer/service-binding-operator v0.9.0 h1:CS+eEtzu/PtWuyvYQFQpZXd6ukSuFtN+U0EKKtTsvlA=
github.com/redhat-developer/service-binding-operator v0.9.0/go.mod h1:D415gZQiz5Q8zyRbmrNrlieb6Xp73oFtCb+nCuTL6GA=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/registry/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ func handleErrors(err error, opts *options) error {
if srsmgmtv1errors.IsAPIError(err, srsmgmtv1errors.ERROR_7) {
return opts.localizer.MustLocalizeError("registry.cmd.create.error.limitreached")
}
if srsmgmtv1errors.IsAPIError(err, srsmgmtv1errors.ERROR_9) {
return opts.localizer.MustLocalizeError("registry.cmd.create.error.name.alreadyExists", localize.NewEntry("Name", opts.name))
}
if srsmgmtv1errors.IsAPIError(err, srsmgmtv1errors.ERROR_13) {
return opts.localizer.MustLocalizeError("registry.cmd.create.error.trial.limitreached")
}
Expand Down
2 changes: 2 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 @@ -146,6 +146,8 @@ one = '''
Instance cannot be created. We have reached global the limit of service registry instances.
'''

[registry.cmd.create.error.name.alreadyExists]
one = 'Instance with name "{{.Name}}" already exists'

[registry.cmd.create.flag.use.description]
one = 'Set the new Service Registry instance to the current instance'
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4512b73

Please sign in to comment.