Skip to content
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

ctx: Ignore empty path components in non-interactive mode #593

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

adamwg
Copy link
Member

@adamwg adamwg commented Jul 31, 2024

Description of your changes

Allow for trailing slashes (and also, as a side-effect, duplicate slashes) in
non-interactive mode by ignoring any empty path components when we parse the
path. This is especially helpful since we print a trailing slash on the path
when a user selects a context other than a control plane (space or group).

Fixes #581

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
    - [ ] Added backport release-x.y labels to auto-backport this PR, as appropriate.

How has this code been tested

Manual testing with various non-interactive invocations:

[awg/ignore-empty-trailing//up]% up ctx upbound/upbound-aws-us-east-1
Kubeconfig context "upbound": Upbound upbound/upbound-aws-us-east-1/
[awg/ignore-empty-trailing//up]% up ctx upbound/upbound-aws-us-east-1/
Kubeconfig context "upbound": Upbound upbound/upbound-aws-us-east-1/
[awg/ignore-empty-trailing//up]% up ctx upbound/upbound-aws-us-east-1/default/
Switched kubeconfig context to: Upbound upbound/upbound-aws-us-east-1/default/
[awg/ignore-empty-trailing//up]% up ctx upbound/upbound-aws-us-east-1///default///
Kubeconfig context "upbound": Upbound upbound/upbound-aws-us-east-1/default/
[awg/ignore-empty-trailing//up]% up ctx upbound/upbound-aws-us-east-1///default///test
Switched kubeconfig context to: Upbound upbound/upbound-aws-us-east-1/default/test
[awg/ignore-empty-trailing//up]% up ctx upbound/upbound-aws-us-east-1///default///test///
Kubeconfig context "upbound": Upbound upbound/upbound-aws-us-east-1/default/test

Allow for trailing slashes (and also, as a side-effect, duplicate slashes) in
non-interactive mode by ignoring any empty path components when we parse the
path. This is especially helpful since we print a trailing slash on the path
when a user selects a context other than a control plane (space or group).

Fixes #581

Signed-off-by: Adam Wolfe Gordon <[email protected]>
@adamwg adamwg merged commit a0923b8 into main Aug 1, 2024
7 checks passed
@adamwg adamwg deleted the awg/ignore-empty-trailing branch August 1, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

up ctx upbound/upbound-aws-us-east-1/ fails
3 participants