Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: feat(service-registry): setting command #1677

Merged
merged 2 commits into from
Jul 25, 2022

Conversation

SafarMirek
Copy link
Contributor

This PR adds new setting command group with three subcommands:

list : List current configuration settings
set : Set the value of a configuration setting
get: Get the value of a configuration setting

Closes #1650

Usage:

List all settings of the current Service Registry instance

$ rhoas service-registry setting list

Set the value of setting

$ rhoas service-registry setting set --setting-name registry.ccompat.legacy-id-mode.enabled --value true

Also, in registry there is an option to reset setting to default value, to do this using cli tool you can use a set command:

$ rhoas service-registry setting set --setting-name registry.ccompat.legacy-id-mode.enabled --default

Get the calue of setting

From the original proposal I have added also get command to get ConfigurationProperty of specific name.

$ rhoas service-registry setting get --setting-name registry.ccompat.legacy-id-mode.enabled

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Other (please specify)

@SafarMirek SafarMirek force-pushed the sr-setting-cmd branch 2 times, most recently from 6c3ae0a to 43a6019 Compare July 25, 2022 09:59
Service registry setting command with subcommands: get, set, list

configProperty, _, err := request.Execute()
if err != nil {
return registrycmdutil.TransformInstanceError(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Really really nice that you have found and used that method.


var missingFlags []string

if opts.settingName == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOW! Just wow!


opts.registryID = registryInstance.GetId()

return runSet(opts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset to default would ignore other fields. We can:

  • Return error
  • Print warning that fields are ignored
  • (current) do nothing and just reset it (but ignore values passed)

Your choice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the warning, that value is ignored, when default flag is present.


func runInteractivePrompt(opts *options, missingFlags []string) (err error) {

if slices.Contains(missingFlags, "setting-name") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOW :) very nice pattern :)

[setting.set.cmd.example]
one = '''
## Set value of setting by name
$ rhoas service-registry setting set --setting-name registry.ccompat.legacy-id-mode.enabled --value true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have some docs where those settings are documented etc. It might be good to include in long description

Copy link
Collaborator

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just WOW :)

}

if len(missingFlags) > 0 {
err = runInteractivePrompt(opts, missingFlags)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice pattern to use interactive mode when flags are not set, I should use this more often 😄


[setting.cmd.description.long]
one = '''
Configure settings of a Service Registry instance
Copy link
Contributor

@jackdelahunt jackdelahunt Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a longer description for this, it is the same for short and long

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have dedicated documentation team that works on descriptions for the commands.
It is good to write something long but certainly not required.

Copy link
Contributor

@smccarthy-ie smccarthy-ie Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey folks,
This is an admin only-feature in the Apicurio Registry API and RHOSR UI. Assuming this is admin-only also in RHOAS CLI?

I can create a PR to update the help doc with more info (e.g. admin/instance owner feature, available settings, etc.).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We might actually add some extra checks to see if user is admin (assuming that non admin would not get useful error.

@jackdelahunt
Copy link
Contributor

lgtm 👍

@wtrocki wtrocki marked this pull request as ready for review July 25, 2022 14:09
@wtrocki
Copy link
Collaborator

wtrocki commented Jul 25, 2022

@SafarMirek LGTM

image

Leaving for @jackdelahunt to leave any additional comments if needed.

@jackdelahunt jackdelahunt merged commit 9207eca into redhat-developer:main Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add commands for managing RHOSR instance settings
4 participants