-
Notifications
You must be signed in to change notification settings - Fork 382
Add flags to svcat register broker command #2208
Add flags to svcat register broker command #2208
Conversation
if you put |
I dunno how to read regexes, but here https://github.com/kubernetes/test-infra/blob/master/prow/plugins/wip/wip-label.go#L41 |
d551332
to
d02d379
Compare
89d9d62
to
cd16a6f
Compare
a6d2fb5
to
35314a0
Compare
f1b9e85
to
bde82bc
Compare
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.
This is looking good! 👍
FYI, I didn't review the tests yet, I'll look at those once the desired behavior is clarified.
PlanRestrictions []string | ||
SkipTLS bool | ||
RelistBehavior string | ||
RelistDuration time.Duration |
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'm always confused by what a create should look like with a manual relistduration. Should we pass a null duration or does the api server just ignore whatever is sent for the duration?
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.
This sends a time.Duration of 0, which the apiserver drops on the floor. It never gets set in the spec at all.
cmd/svcat/broker/register_cmd.go
Outdated
} | ||
cmd := &cobra.Command{ | ||
Use: "register NAME --url URL", | ||
Use: "register NAME URL", |
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.
lol I see what you did there. 😂 My vote is still for keeping --url.
cmd/svcat/broker/register_cmd.go
Outdated
cmd.Flags().StringVar(®isterCmd.URL, "url", "", | ||
"The broker URL (Required)") | ||
cmd.MarkFlagRequired("url") | ||
cmd.Flags().StringVar(®isterCmd.BasicSecret, "basic-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.
Do you know how the secrets work when we are making a ClusterServiceBroker vs a ServiceBroker. For a namespaced broker, I assume that the secret is in the same namespace. For a cluster-scoped broker though, do they have to provide a namespace? Or is it just embedded in the format, e.g. "namespace/secret-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.
Currently it tags the secret as being in whatever namespace the command was executed in. This might be a problem when we want to change the command to create namespaced broker.
cmd/svcat/broker/register_cmd.go
Outdated
cmd.Flags().StringVar(®isterCmd.CAFile, "ca", "", | ||
"A file containing the CA certificate to connect to the broker") | ||
cmd.Flags().StringSliceVar(®isterCmd.ClassRestrictions, "class-restrictions", []string{}, | ||
"A whitelist of Classes to allow from the broker") |
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.
Let's not use blacklist/whitelist and stick with the terms that are used in the documentation:
https://svc-cat.io/docs/catalog-restrictions/
I recommend "A list of restrictions to apply to the classes allowed from the broker" or something like that.
cmd/svcat/broker/register_cmd.go
Outdated
cmd.Flags().StringSliceVar(®isterCmd.PlanRestrictions, "plan-restrictions", []string{}, | ||
"A whitelist of Plans to allow from the broker") | ||
cmd.Flags().StringVar(®isterCmd.RelistBehavior, "relist-behavior", "", | ||
"Behavior for relisting the broker's catalogue. Manual/Duration") |
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 think we use the US spelling "catalog" everywhere else, so let's rename "catalogue" to "catalog" for consistency.
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 pattern that we have used elsewhere for allowed values is:
- lower cased
- use a comma separated list of allowed values, examples below
cmd/svcat/broker/register_cmd.go
Outdated
cmd.Flags().StringVar(®isterCmd.RelistBehavior, "relist-behavior", "", | ||
"Behavior for relisting the broker's catalogue. Manual/Duration") | ||
cmd.Flags().DurationVar(®isterCmd.RelistDuration, "relist-duration", 0*time.Second, | ||
"Interval to refetch broker catalog when relist-behavior is set to duration, specified in human readable format: 30s, 1m, 1h") |
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.
This implies that we only use relist-duration when the behavior is manual, is that right?
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.
Uh, what? Its the interval to (do thing) when relist behavior is set to duration. That means we only use it when the behavior is duration.
right?
cmd/svcat/broker/register_cmd.go
Outdated
if c.RelistBehavior != "" { | ||
c.RelistBehavior = strings.ToLower(c.RelistBehavior) | ||
if c.RelistBehavior != "duration" && c.RelistBehavior != "manual" { | ||
return fmt.Errorf("relist-behavior must be duration/manual") |
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.
Let's use "invalid --relist-duration value, allowed values are: duration, manual" to match our other error messages.
cmd/svcat/broker/register_cmd.go
Outdated
return fmt.Errorf("relist-behavior must be duration/manual") | ||
} | ||
} | ||
if c.RelistDuration != 0*time.Second && c.RelistBehavior != "duration" { |
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.
Is this something that the api server would accept? I am wondering if we are applying validations on the cli to values that the server would allow. Can you check please?
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.
api server drops the relist duration on the ground. I guess we can remove this.
cmd/svcat/broker/register_cmd.go
Outdated
return nil | ||
} | ||
|
||
// Run runs the command | ||
// Run calls out to the pkg lib to create the broker and displays the output |
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.
nit: let's not put the call pattern into the comment. How about // Run creates the broker and then displays the broker details
cmd/svcat/broker/register_cmd.go
Outdated
BearerSecret: c.BearerSecret, | ||
CAFile: c.CAFile, | ||
ClassRestrictions: c.ClassRestrictions, | ||
Namespace: c.Context.App.CurrentNamespace, |
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.
Do not directly use the current namespace, because that doesn't properly take into account all of the necessary logic. The Namespaced
struct handles defaulting this appropriately, and the final namespace can be found in c.Namespace
.
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.
how does that interact with throwing the global kubectl namespace flag when running in plugin mode?
b782122
to
e91bf56
Compare
redid the namespace stuff using namespaced |
e91bf56
to
8f9245a
Compare
cmd/svcat/broker/register_cmd.go
Outdated
} | ||
cmd := &cobra.Command{ | ||
Use: "register NAME --url URL", | ||
Use: "register NAME URL", |
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.
Please change this back to --url
.
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.
General consensus at the face to face and in the meeting before that was to move to positional arguments and get rid of mandatory flags. Do you want to bring this up again next week in the meeting to discuss?
cmd/svcat/broker/register_cmd.go
Outdated
return fmt.Errorf("invalid --relist-duration value, allowed values are: duration, manual") | ||
} | ||
} | ||
/** |
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.
Let's remove this dead code / comment.
@@ -0,0 +1 @@ | |||
foo |
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.
Best CA cert ever ⭐️
cmd/svcat/broker/register_cmd.go
Outdated
} | ||
cmd := &cobra.Command{ | ||
Use: "register NAME --url URL", |
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.
why did we change this? I'm not sure I really like the positional arguments like this. The cf
CLI does this, but I think kubernetes gets more into -- args vs positional things and I think we should stick with that.
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.
we discussed this at the face-to-face. We decided to switch to positional args as mandatory flags goes against unix command line convention.
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.
While this isn't the hill I want to die on 😝, I honestly do not remember that being officially decided at the F2F as you are recalling.
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.
@jberkhahn I apologize for this being so weird. I trust that we did decide that and I just forgot the details. Let's go with what you have here and I now crown you master and commander of the CLI so that we don't have to rely on my poor memory anymore!
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.
💂
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.
hahhahah I was thinking of a 👑 , jeremy immediately went to that ⛵️ movie and I think that's a beefeater? best title ever! 🙌
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 must have been on one of those bathroom breaks - - I too don't recall the position vs named arg discussion/decision.
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.
No? We also discussed this in the weekly meeting the week before the f2f and had the same consensus. We can bring it up again at the meeting next week if you prefer.
8f9245a
to
b3280e5
Compare
/hold |
@jberkhahn @jboyd01 @carolynvs I put this on hold for now, I feel like we should chat about it Monday since there seems to be some confusion about args. Let's just revisit the topic and then we can come back to this! |
b3280e5
to
9a46552
Compare
removed the changes in question
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.
/lgtm
9a46552
to
eeccfda
Compare
- add options object to pkg/svcat - change svcat register --url flag to positional argument
eeccfda
to
358d448
Compare
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jeremyrickard 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 |
@@ -48,27 +68,73 @@ func NewRegisterCmd(cxt *command.Context) *cobra.Command { | |||
cmd.Flags().StringVar(®isterCmd.URL, "url", "", | |||
"The broker URL (Required)") | |||
cmd.MarkFlagRequired("url") | |||
cmd.Flags().StringVar(®isterCmd.BasicSecret, "basic-secret", "", | |||
"A secret containing basic auth (username/password) information to connect to the broker") | |||
cmd.Flags().StringVar(®isterCmd.BearerSecret, "bearer-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.
Should basic-secret
and bearer-secret
not be basic-secret-name and bearer-secret-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.
We don't follow that convention for flags that indicate secrets for other commands - both provision and bind just use -secret
, not -secret-name
#1807
Also contains refactoring of register to change mandatory flags into positional args.
Also adds an options struct to pkg/svcat for containing the bajillion different flag options. This also makes the interface around Register() much more stable.
I'm centering validation in the cmd layer's Validate() method (from cobra). So pkg/svcat's Register() method will do strange things if you ask it to.