-
Notifications
You must be signed in to change notification settings - Fork 270
Added --broker-config flag to broker create command #1700
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vyasgun: 5 warnings.
In response to this:
Description
This flag will be used to set the
.spec.config
field in the broker objectChanges
- Added the flag
- The flag has to be used in conjunction with
--class
flag- TODO: Add unit tests and examples
Reference
Fixes #1525
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Codecov Report
@@ Coverage Diff @@
## main #1700 +/- ##
==========================================
+ Coverage 79.69% 79.77% +0.08%
==========================================
Files 173 174 +1
Lines 13264 13357 +93
==========================================
+ Hits 10571 10656 +85
- Misses 1963 1968 +5
- Partials 730 733 +3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First thanks for contribution. Left some comments. However, is this part 1 of the PR. I don't see any tests?
docs/cmd/kn_broker_create.md
Outdated
@@ -23,6 +23,7 @@ kn broker create NAME | |||
``` | |||
--backoff-delay string The delay before retrying. | |||
--backoff-policy string The retry backoff policy (linear, exponential). | |||
--broker-config string Broker config object like ConfigMap or RabbitMQ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow this statement is missing something "Broker config object like ConfigMap or RabbitMQ" can we be more descriptive. Also is "or" the right conjunctive here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the flag description in my latest commit. Please let me know if it can be improved further
case "apiversion": | ||
kRef.APIVersion = v | ||
default: | ||
return nil, fmt.Errorf("incorrect field %q. Please specify any of the following: Namespace, Group, APIVersion", k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since field test is on lower case names perhaps the error message should use lower case in message too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argument is being converted to lower case before the check so the user can provide it in any case. I think the error message looks clearer with capitalisation.
7a2c935
to
f88d879
Compare
@maximilien Thanks for the review. I updated the PR with tests and more detailed docs. |
pkg/kn/commands/broker/create.go
Outdated
# Create a broker 'mybroker' in the myproject namespace with config referencing configmap named spec-cm in test namespace | ||
kn broker create mybroker --namespace myproject --class Kafka --broker-config cm:broker-spec-cm:test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd nice to show at least one different example than ConfigMap.
@@ -33,6 +34,15 @@ var createExample = ` | |||
|
|||
# Create a broker 'mybroker' in the 'myproject' namespace and with a broker class of 'Kafka' | |||
kn broker create mybroker --namespace myproject --class Kafka | |||
|
|||
# Create a broker 'mybroker' in the myproject namespace with config referencing configmap named spec-cm | |||
kn broker create mybroker --namespace myproject --class Kafka --broker-config cm:spec-cm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A counter proposal to the config k,v format:
--broker-config rabbitmq.com/v1beta1:RabbitmqCluster:<name>:<namespace>
# With special case for core v1 resources like ConfigMaps and Secrets
--broker-config cm:spec-cm:spec-cm-ns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, see my proposal above.
|
||
# Create a broker 'mybroker' in the myproject namespace with config referencing configmap named spec-cm in test namespace | ||
kn broker create mybroker --namespace myproject --class Kafka --broker-config cm:broker-spec-cm:test | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last example seems to duplicate the example before. As @dsimansk mentioned, having an example for a secret and/or a full GVK would be helpful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I updated the examples accordingly. Hope they look okay now
docs/cmd/kn_broker_create.md
Outdated
--broker-config string Reference to the configuration that specifies configuration options for this Broker. For example, a pointer to a ConfigMap, Secret, RabbitmqCluster etc.The format for specifying the object is a colon separated string consisting of at most 3 substrings: | ||
kind:object-name:namespace=?,apiVersion=?,group=? | ||
The third substring is optional and the following is also acceptable (in case of ConfigMap, Secret, and RabbitmqCluster kinds): | ||
kind:object-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposal for the wording
Reference pointing to the broker configuration. The value takes the format "<prefix>:<name>:<namespace>", where <prefix> is either "cm" for a ConfigMap, "secret" for a Secret or a GVK in the format "rabbitmq.com/v1beta1/RabbitmqCluster". "name" is the name of the referenced resource and "namespace" the optional namespace of that resource (which by default is the current namespace).
I back @dsimansk opinion that we should not invent another format to provide a full GVK (like in your proposal with additional apiVersion
and group
), but encode it already in the prefix. We have done that already I think, for the sink: (or at least plan for this). The prefix actually should fully specify the reference type (and we allow some shortcut for well-known types like cm and secret)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sink is using the same delimiter (':') to get the prefix. So, instead of having the prefix as a part of the first slice and then splitting it by '/', I have added the format as follows:
<apiVersion>:<kind>:<name>:<namespace>
I can change this if this doesn't seem right/consistent.
func getDefaultKReference(kind string) *duckv1.KReference { | ||
k := strings.ToLower(kind) | ||
switch k { | ||
case "cm", "configmap": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make that switch more dynamic ? I.e. already add the list of shortcut prefixes to KReferenceMapping
and then either iterate of the list to find the entry or build up a map before with the shortcut prefix as key, pointing to the KReferenceMapping entry (i.e. I would create an own Struct for the mapping with a KReference and a string array as member for KRerferenceMapping.
The advantage would be that all the relevant parts (reference + prefixes) are defined in a single place (i.e. where KReferenceMapping is defined)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sounds good. I'll do that.
/test all |
c8310ac
to
2d25e77
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dsimansk, vyasgun The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/kind feature |
Description
This flag will be used to set the
.spec.config
field in the broker objectChanges
--class
flagReference
Fixes #1525
Release Note