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

rpk redpanda config set: improve setting arrays #5522

Merged
merged 1 commit into from
Jul 20, 2022
Merged

rpk redpanda config set: improve setting arrays #5522

merged 1 commit into from
Jul 20, 2022

Conversation

twmb
Copy link
Contributor

@twmb twmb commented Jul 19, 2022

Recent rpk improvements now initialize index 0 of a slice if the key we
are setting is deeply inside the slice. e.g., foo.bar.baz would
initialize bar[0] to set baz. However, it was not possible to set
foo.bar[1]. This change fixes that. We also allow setting one past the
end of an array to extend it: if foo.bar[0] exists, then foo.bar[1].baz
adds to the array.

Old rpk never had the ability to set an array key to a single value that
was not wrapped in brackets. For example, foo.bar = "baz" would not
work if bar was an array. Now, we use / initialize element 0 and set
that.

Fixes #2958
Fixes #5498
Fixes #5264

Release notes

Features

  • rpk redpanda config set can now modify any element in an array through indexing semantics: rpk redpanda config set rpk.kafka_api.brokers[1] = "127.0.0.1:9092 modifies the second broker (0 based indexing). Setting one-past-the-end extends the array by one.
  • rpk redpanda config set now unmarshals single elements as arrays with one element

@r-vasquez
Copy link
Contributor

Can we update rpk redpanda config set --help output? in https://github.com/redpanda-data/redpanda/blob/dev/src/go/rpk/pkg/cli/cmd/redpanda/config.go#L53-L64 so users can discover this new feature

Recent rpk improvements now initialize index 0 of a slice if the key we
are setting is deeply inside the slice. e.g., foo.bar.baz would
initialize bar[0] to set baz. However, it was not possible to set
foo.bar[1]. This change fixes that. We also allow setting one past the
end of an array to extend it: if foo.bar[0] exists, then foo.bar[1].baz
adds to the array.

Old rpk never had the ability to set an array key to a single value that
was not wrapped in brackets. For example, `foo.bar = "baz"` would not
work if bar was an array. Now, we use / initialize element 0 and set
that.

Fixes #2958
Fixes #5498
Fixes #5264
Copy link
Contributor

@r-vasquez r-vasquez left a comment

Choose a reason for hiding this comment

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

Awesome, thank you :D !

@twmb
Copy link
Contributor Author

twmb commented Jul 20, 2022

debug is #4772
release is #5466

@twmb twmb merged commit b08ac47 into redpanda-data:dev Jul 20, 2022
@twmb twmb deleted the config_set_slice_improvements branch July 20, 2022 03:52
@mmedenjak mmedenjak added the kind/bug Something isn't working label Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rpk kind/bug Something isn't working
Projects
None yet
3 participants