feat(service-registry rule): add describe and list command#1431
feat(service-registry rule): add describe and list command#1431rkpattnaik780 merged 12 commits intoservice-registry-rulesfrom
Conversation
It is better to not use screenshots unless necessary or to complement readable text. Screenshots cannot be understood by screen readers and so it makes this inaccessible to those with visual impairments. It is better to paste the code if needed. Edit: though I see that this is not verification steps or anything important, so it is probably fine :) |
pkg/cmd/registry/rule/list/list.go
Outdated
| var compatibilityRuleStatus = ruleRow{ | ||
| RuleType: ruleCompatibility, | ||
| Description: "Enforce a compatibility level when updating this artifact (for example, Backwards Compatibility).", | ||
| Status: "DISABLED", |
There was a problem hiding this comment.
| Status: "DISABLED", | |
| Status: DISABLED_RULE_CONSTANT, |
You should use a constant here.
pkg/cmd/registry/rule/list/list.go
Outdated
|
|
||
| var compatibilityRuleStatus = ruleRow{ | ||
| RuleType: ruleCompatibility, | ||
| Description: "Enforce a compatibility level when updating this artifact (for example, Backwards Compatibility).", |
There was a problem hiding this comment.
Should that use i18n?
pkg/cmd/registry/rule/list/list.go
Outdated
|
|
||
| for _, rule := range enabledRules { | ||
| if rule == ruleValidity { | ||
| validityRuleStatus.Status = "ENABLED" |
There was a problem hiding this comment.
| validityRuleStatus.Status = "ENABLED" | |
| validityRuleStatus.Status = SHOULD_BE_A_CONSTANT |
There was a problem hiding this comment.
Would lowercase "enabled" be possible instead? Will this value ever need to be input by the user? If so we will want it to be lowercase.
There was a problem hiding this comment.
It is just for display.
There was a problem hiding this comment.
Even if it is just for display - all uppercase is harder to read than all lowercase.
There was a problem hiding this comment.
Changed:
Fetching global rules for artifacts in Service Registry Instance
RULE TYPE DESCRIPTION STATUS
--------------- ----------------------------------------------------------- ---------
validity Ensure that content is valid when updating this artifact. enabled
compatibility Enforce a compatibility level when updating this enabled
artifact (for example, Backwards Compatibility).
Run describe command to view configuration of an enabled rule:
$ rhoas service-registry rule describe --rule-type <compatibility/validity>
pkg/cmd/registry/rule/list/list.go
Outdated
| ruleValidity = "VALIDITY" | ||
| ruleCompatibility = "COMPATIBILITY" |
There was a problem hiding this comment.
Should these be in lowercase?
There was a problem hiding this comment.
These serve two purpose: check the server response, display the status of rules.
| one = 'No rules enabled' | ||
|
|
||
| [registry.rule.list.log.info.describeHint] | ||
| one = 'Run describe command to view confiuration of enabled rule' |
There was a problem hiding this comment.
| one = 'Run describe command to view confiuration of enabled rule' | |
| one = 'Run describe command to view configuration of enabled rule' |
There was a problem hiding this comment.
I think we should be less vague about what the describe command is, and just give them the full command instead.
Run "rhoas service-registry describe"
There was a problem hiding this comment.
Changing text to :
Run describe command to view configuration of an enabled rule:
$ rhoas service-registry rule describe --rule-type <compatibility/validity>
| @@ -0,0 +1,175 @@ | |||
| package describe | |||
There was a problem hiding this comment.
$ rhoas service-registry rule describe --rule-type compatibilitkiy -v
❌ Invalid value "&{0xc00044fd10}" for --rule-type, valid options are: "validity", "compatibility". Run the command in verbose mode using the -v flag to see more informationPutting in an invalid type-type value is not handled correctly.
| return err | ||
| } | ||
|
|
||
| instanceIDPrompt := &survey.Input{ |
There was a problem hiding this comment.
@wtrocki prompts for few flags got missed in the last PR.
There was a problem hiding this comment.
I don't think we should be prompting for the instance ID - it is not a pattern used in the other commands.
50db4d8 to
e5a715e
Compare
a57c9b1 to
6a13f3e
Compare
e5a715e to
8cd92aa
Compare
| } | ||
| } | ||
|
|
||
| cfg, err := opts.Config.Load() |
There was a problem hiding this comment.
This can be moved to line 101 - it is out of the place
8cd92aa to
8dbca10
Compare
craicoverflow
left a comment
There was a problem hiding this comment.
Verified functionally, good job 👍🏻
My main concern though is that the artifact ID and instance ID are not being validated in interactive mode. Can we have that?
|
|
||
| [registry.rule.list.log.info.describeHint] | ||
| one = ''' | ||
| Run describe command to view configuration of an enabled rule: |
There was a problem hiding this comment.
I don't think it reads very well currently, maybe this?
| Run describe command to view configuration of an enabled rule: | |
| Run the following to view the configuration of an enabled rule: |
| one = ''' | ||
| Run describe command to view configuration of an enabled rule: | ||
|
|
||
| $ rhoas service-registry rule describe --rule-type <compatibility/validity> |
There was a problem hiding this comment.
This should be indented.
| return err | ||
| } | ||
|
|
||
| instanceIDPrompt := &survey.Input{ |
There was a problem hiding this comment.
I don't think we should be prompting for the instance ID - it is not a pattern used in the other commands.
| return err | ||
| } | ||
|
|
||
| artifactIDPrompt := &survey.Input{ |
There was a problem hiding this comment.
I think this would make more sense to be a list you can select from - it would be less error prone?
There was a problem hiding this comment.
Validating and suggesting values becomes bit tricky here as artifact operations need the group before hand. Even if we put the group prompt before artifact prompt, there doesn't seem to be any way to retrieve the list of groups.
There was a problem hiding this comment.
I don't think we should be prompting for the instance ID - it is not a pattern used in the other commands.
I agree but other interactive modes didn't have the instance id flags, I am not sure if we should make the interactive mode have less options than non-interactive.
There was a problem hiding this comment.
Let's keep in mind that sometimes reasons why integration is soo hard is because API is simply making it hard. If there is some suggestion we can put for future versions of the API (this area is being worked on) it would be good for entire service.
There was a problem hiding this comment.
Changed instance ID argument to flag only, removed from prompt.
| } | ||
| } else { | ||
|
|
||
| opts.Logger.Info(opts.localizer.MustLocalize( |
There was a problem hiding this comment.
This should have a spinner in front of it (use these as much as possible when some action is taking place)
pkg/cmd/registry/rule/list/list.go
Outdated
|
|
||
| opts.localizer.MustLocalize("registry.rule.list.compatibilityRule.description") | ||
|
|
||
| var compatibilityRuleStatus = ruleRow{ |
There was a problem hiding this comment.
| var compatibilityRuleStatus = ruleRow{ | |
| compatibilityRuleStatus := ruleRow{ |
^ recommended
pkg/cmd/registry/rule/list/list.go
Outdated
| RuleValidity = "validity" | ||
| RuleCompatibility = "compatibility" | ||
| ) | ||
|
|
||
| const ( | ||
| RuleDisabled = "disabled" | ||
| RuleEnabled = "enabled" |
There was a problem hiding this comment.
Do these variables need to be public?
| "github.com/redhat-developer/app-services-cli/pkg/core/localize" | ||
| ) | ||
|
|
||
| type RegistryRuleError struct { |
There was a problem hiding this comment.
| type RegistryRuleError struct { | |
| type RegistryRuleError struct { |
That name is misleading - when I saw it being used in the code I thought that it is an error struct.
| // AddArtifactID adds a flag for setting the artifact ID | ||
| func (fs *flagSet) AddArtifactID(artifactID *string) { | ||
| flagName := "artifact-id" | ||
|
|
||
| fs.StringVar( | ||
| artifactID, | ||
| flagName, | ||
| "", | ||
| fs.factory.Localizer.MustLocalize("artifact.common.id"), | ||
| ) | ||
|
|
||
| } |
There was a problem hiding this comment.
Could that be more common - isn't artifact-id used elsewhere?
There was a problem hiding this comment.
flagbuilders for --artifact-id and --group will be moved to the registrycmdutil in the next PR.
82d4ff0 to
89d35b5
Compare
craicoverflow
left a comment
There was a problem hiding this comment.
LGTM. However I recommend improving how the spinner indicator gets displayed by keeping the message there and not having it disappear.
| s.Stop() | ||
| } else { | ||
| s := spinner.New(opts.IO.ErrOut, opts.localizer) | ||
| s.SetLocalizedSuffix("registry.rule.list.log.info.fetching.artifactRules") |
There was a problem hiding this comment.
"Fetching global rules for artifacts in Service Registry Instance" disappears once the data has loaded Do you want that? Maybe it is better to not have any message at all since I am not sure if it tells the user something they don't know.
There was a problem hiding this comment.
Otherwise it would be better to let that message remain on the top of the display even after it has completed.
There was a problem hiding this comment.
Same goes in other instances where this happens.
There was a problem hiding this comment.
Same goes in other instances where this happens.
Is this suggestion for list command only or all commands that use spinners?
I cant form a strong opinion about the loader text. We can probably remove it as it shows nothing new.
Cc @wtrocki
There was a problem hiding this comment.
The loader text is fine but it should not just flash up for a half second and disappear - the user will be thinking they missed something important. It is best to ensure it just does not be deleted so the user can still see the message as normal.
There was a problem hiding this comment.
Sounds good. Updating PR to keep the spinners.
There was a problem hiding this comment.
Persisting the spinner texts runs to newline issue, logger.info() or \n for spacing doesn't seem to fix this either.
⣷ Fetching rules for the artifact❌ Artifact with ID 41590799-c99f-47cc-85a2-c50578 not found. Run the command in verbose mode using the -v flag to see more information
Any instance where we have leave spinner unclosed?


Add
describeandlistcommand forservice-registry rules.Verification Steps
Type of change
Checklist