rpk redpanda config set: improve setting arrays #5522
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 notwork 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