-
Notifications
You must be signed in to change notification settings - Fork 41
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
Allow creating new space profiles by name #400
Conversation
9b1e730
to
58a9018
Compare
@@ -37,7 +37,7 @@ type Cmd struct { | |||
// AfterApply constructs and binds Upbound-specific context to any subcommands | |||
// that have Run() methods that receive it. | |||
func (c *Cmd) AfterApply(kongCtx *kong.Context) error { | |||
upCtx, err := upbound.NewFromFlags(c.Flags) | |||
upCtx, err := upbound.NewFromFlags(c.Flags, upbound.AllowMissingProfile()) |
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 fix the command description 10 lines above. This is not what the command is doing.
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.
And be very explicit that this overrides the current profile.
@@ -44,13 +44,10 @@ func (c *spaceCmd) AfterApply(kongCtx *kong.Context) error { | |||
} |
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 implement a proper one or two paragraph help text.
We should also choose a new profile name in |
cmd/up/profile/set.go
Outdated
p.Print(" and selected as the default profile") | ||
} | ||
p.Printf( | ||
"Profile %q updated to use context %q from the %s and selected as the default profile", |
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.
"context" is not a term. Maybe "talk to Spaces via the current Kubernetes context %q" ?
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 we check that it actually is a Spaces installation? We should.
cmd/up/profile/set_test.go
Outdated
return nil | ||
} | ||
|
||
func TestSpaceRun(t *testing.T) { |
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.
SpaceRun?
cmd/up/profile/set.go
Outdated
return errors.Wrap(err, errSetProfile) | ||
} | ||
if err := upCtx.Cfg.SetDefaultUpboundProfile(upCtx.ProfileName); err != nil { | ||
return errors.Wrap(err, errSetProfile) |
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.
technically selecting a profile is more than a set command should do. We have profile use
for that purpose.
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 strong opinion here. Just be very clear in the command documentation that profile selection happens.
cmd/up/profile/set_test.go
Outdated
Kube: upbound.KubeFlags{ | ||
Kubeconfig: kubeconfig, | ||
}, | ||
}, |
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: isn't the cmd always the same? Why not create it below in the loop?
@sttts I pushed some changes to address your comments, lmk what you think. Notably I put things back so that |
Created #404 for the |
cmd/up/profile/profile.go
Outdated
@@ -29,15 +29,15 @@ type Cmd struct { | |||
Use useCmd `cmd:"" help:"Set the default Upbound Profile to the given Profile."` | |||
View viewCmd `cmd:"" help:"View the Upbound Profile settings across profiles."` | |||
Config config.Cmd `cmd:"" help:"Interact with the current Upbound Profile's config."` | |||
Set setCmd `cmd:"" help:"Create an Upbound Profile."` | |||
Set setCmd `cmd:"" help:"Create or update an Upbound Profile."` |
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.
Set a profile (the current by default) to talk to a Space
? set
alone is not usable today. I would be explicit here, until we have another set
subcommand.
cmd/up/profile/space_help.txt
Outdated
A Space profile communicates with a Space using a Kubernetes context from a kubeconfig | ||
file. The kubeconfig and context may be selected using the --kubeconfig and | ||
--kubecontext flags. If --kubeconfig is not provided, then the profile will use | ||
the default kubeconfig at ~/.kube/config. If --kubecontext is not provided, then | ||
the profile will use the kubeconfig's current default context. |
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 Space profile communicates with a Space using a Kubernetes context from a kubeconfig | |
file. The kubeconfig and context may be selected using the --kubeconfig and | |
--kubecontext flags. If --kubeconfig is not provided, then the profile will use | |
the default kubeconfig at ~/.kube/config. If --kubecontext is not provided, then | |
the profile will use the kubeconfig's current default context. | |
Set a profile to be a Space profile. Use --profile to create a new profile. | |
By default the current profile is overwritten. | |
A Space profile communicates with a Space using a Kubernetes context from a kubeconfig | |
file. The kubeconfig and context may be selected using the --kubeconfig and | |
--kubecontext flags. If --kubeconfig is not provided, then the profile will use | |
the default kubeconfig at ~/.kube/config. If --kubecontext is not provided, then | |
the profile will use the kubeconfig's current default context. |
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.
Haven't looked deeply. The context name is stored, right? So the context selection happens on set space
, not when a Space profile is used. This is not very clear in the current text.
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.
Yeah that's correct. Good point, I'll clarify this.
@sttts Here's how help text looks after the latest push:
|
@branden perfect help text. Thanks! |
Only quesiton that is left is about checking that it is a Space kube context. Checking for e.g. the Then we are ready to go. |
The Spaces check is a little beyond scope technically. Approving. |
Description of your changes
This makes
up profile set space
accept a nonexistent--profile
. It will create that profile.Fixes #399.
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR, as appropriate.How has this code been tested
Added unit tests.