-
Notifications
You must be signed in to change notification settings - Fork 394
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
✨ kubectl support ../../ & ..:..: #3088
Conversation
We need bigger story to refactor all this function to support syntax like:
basically make it recursive and enable replace |
/test pull-kcp-test-e2e-shared |
@sttts is this missing smth? |
Overall idea as per community meeting:
|
defer func() { | ||
if err == nil { | ||
_, err = fmt.Fprintf(o.Out, "Note: 'kubectl ws' now matches 'cd' semantics: go to home workspace. 'kubectl ws -' to go back. 'kubectl ws .' to print current workspace.\n") | ||
} | ||
}() | ||
fallthrough | ||
|
||
case "~", home: | ||
homeWorkspace, err := o.kcpClusterClient.Cluster(core.RootCluster.Path()).TenancyV1alpha1().Workspaces().Get(ctx, "~", metav1.GetOptions{}) | ||
case o.Name == "~" || o.Name == home: |
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.
what about ~: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.
added support, just no test as need second run on it :/
~ not being resolved in tests to check if workspace exists gets bit complex in tests :./
@@ -407,7 +407,7 @@ func TestUse(t *testing.T) { | |||
AuthInfos: map[string]*clientcmdapi.AuthInfo{"test": {Token: "test"}}, | |||
}, | |||
destination: "root:foo:bar", | |||
wantStdout: []string{"Current workspace is \"root:foo:bar\""}, | |||
wantStdout: []string{"Current workspace is ':root:foo:bar'"}, |
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.
am not convinced we want to print out the :
at all. Let's keep the output always foo:bar:abc
. The :
prefix is only for navigation.
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.
was one the line with this, so this pushes swings to same :) will remove
918199a
to
1230514
Compare
|
||
case ".": | ||
cfg, err := o.ClientConfig.ClientConfig() | ||
case strings.Contains(o.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.
this one looks fishy. Could see = ".."
, but anything beyond that needs some more logic, e.g. for ./../foo/../bar
.
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, this is not supported yet. Code code quite convoluted and wanna move it to separate pr. So this is not yet supported
// system is bit different. Usually when moving to system workspaces you | ||
// need to have special access and "if workspace exists" checks fails. | ||
// If merged to "absolute path check" code gets convoluted :/ | ||
case strings.HasPrefix(o.Name, ":system"): |
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 have a constant for system
somewhere I believe.
Also here HasPrefix
seems fishy. We have to properly split by ":"
.
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.
Idea was not to trigger this path is somebody created root:system
or foo:bar:system
in any ways. So only way to access system
from cli is to be explicit - :system
.
Basically don't want this code path to be triggered by mistake by users.
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.
My comment was about using string comparison. Convert it to a logical cluster path and operate on 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.
Updated but this does not make it prettier in my opinion :D
/retest |
@sttts you ok merge without |
|
||
return currentWorkspace(o.Out, newServerHost, shortWorkspaceOutput(o.ShortWorkspaceOutput), nil) | ||
// LEGACY(mjudeikis): Remove once everybody gets used to this | ||
if o.Name == "home" || strings.HasPrefix(o.Name, core.RootCluster.String()+":") { |
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.
o.Name == home
?
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.
Hmm, that case is below. Did we have special "home" logic?
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 did. I just kept it here. Maybe not needed anymore?
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
✨ cli/workspace: implement full relative paths including . and ..
/lgtm |
LGTM label has been added. Git tree hash: bc436de3187f91a2036b315af462186fc0202c49
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sttts 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 |
Summary
Enables to go back more than 1 workspace at the time
ws use ../../
Enables to use
tree
in rootless clusters.Missing parts:
../../foo
multiple actions together does not workRelated issue(s)
Release Notes