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

Flag not working: --Kubeconfig Flag doesn't work with Retina Create #258

Closed
Tatsinnit opened this issue Apr 11, 2024 · 0 comments · Fixed by #263
Closed

Flag not working: --Kubeconfig Flag doesn't work with Retina Create #258

Tatsinnit opened this issue Apr 11, 2024 · 0 comments · Fixed by #263
Assignees
Labels
area/captures lang/go The Go Programming Language priority/1 P1 type/bug Something isn't working
Milestone

Comments

@Tatsinnit
Copy link
Member

Tatsinnit commented Apr 11, 2024

Describe the bug

Thanks in advance for taking a look at this, upon supplying the --kubeconfig flag for retina create it still takes the current set cluster context rather then the supplied kubeconfig file context.

To Reproduce
Steps to reproduce the behavior:

  1. Set current cluster context to some AKS Cluster.
  2. Then Supply the retina create with new config.

Sample command:

kubectl retina capture create --host-path /mnt/capture --node-selectors "kubernetes.io/os=linux" --kubeconfig /path/to/aksclusterfoo

Please see screenshot below as to how get node works with --kubeconfig and the Crete retina output.

Screenshot 2024-04-12 at 5 52 36 AM

Expected behavior

  • The retina create should take the kubeconfig file path supplied to create retina agains that cluster.

Screenshots
If applicable, add screenshots to help explain your problem.

Screenshot 2024-04-12 at 5 52 36 AM Screenshot 2024-04-12 at 5 57 38 AM

Platform (please complete the following information):

  • OS: macOS 14.4.1 (23E224) + Kernel Version: Darwin 23.4.0
  • Kubernetes Version: 1.27 +
  • Host: AKS
  • Retina Version: v0.0.4 or Previous

Additional context

Add any other context about the problem here.

Reference: discovered as part of work when doing this: Azure/vscode-aks-tools#569

@rbtr rbtr added type/bug Something isn't working lang/go The Go Programming Language area/captures priority/1 P1 labels Apr 11, 2024
@rbtr rbtr moved this to In Progress in Retina Triage Board Apr 11, 2024
@rbtr rbtr self-assigned this Apr 12, 2024
@rbtr rbtr mentioned this issue Apr 12, 2024
7 tasks
@rbtr rbtr added this to the 1.0 milestone Apr 12, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 15, 2024
# Description

Changes the CLI command structure from Command method "constructors" to
direct struct initialization of package variables and flag/registration
init hooks.
 
This seems like a trivial syntactic difference, but due to the way that
Cobra initializes the CLI runtime (including things like binding flags),
it is critical that all Commands are already instantiated, and all flags
registered, by the time the CLI framework starts running.

In the previous pattern, for example, the flag for `--kubeconfig` was
bound in the constructor for the nested `capture create` Command and,
although Cobra detected and parsed the flag value correctly at runtime,
it was not _available_ inside that nested command execution and
evaluated to the zero-value.

Additionally, this is the Command/init pattern demonstrated in the
[Cobra
docs](https://github.com/spf13/cobra/blob/main/site/content/user_guide.md#create-rootcmd),
and we should stay aligned with their documented best-practices.

Finally I think it's much clearer the previous pattern, but I am used to
reading and writing Cobra-style CLIs 🙂

## Related Issue

I started investigating #258 and ended up here. Incidentally fixes #258.

## Checklist

- [x] I have read the [contributing
documentation](https://retina.sh/docs/contributing).
- [x] I signed and signed-off the commits (`git commit -S -s ...`). See
[this
documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
on signing commits.
- [x] I have correctly attributed the author(s) of the code.
- [x] I have tested the changes locally.
- [x] I have followed the project's style guidelines.
- [x] I have updated the documentation, if necessary.
- [x] I have added tests, if applicable.

## Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes
made.

## Additional Notes

Add any additional notes or context about the pull request here.

---

Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more
information on how to contribute to this project.

---------

Signed-off-by: Evan Baker <[email protected]>
@rbtr rbtr closed this as completed in #263 Apr 15, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Accepted in Retina Triage Board Apr 15, 2024
nddq pushed a commit that referenced this issue May 6, 2024
# Description

Changes the CLI command structure from Command method "constructors" to
direct struct initialization of package variables and flag/registration
init hooks.
 
This seems like a trivial syntactic difference, but due to the way that
Cobra initializes the CLI runtime (including things like binding flags),
it is critical that all Commands are already instantiated, and all flags
registered, by the time the CLI framework starts running.

In the previous pattern, for example, the flag for `--kubeconfig` was
bound in the constructor for the nested `capture create` Command and,
although Cobra detected and parsed the flag value correctly at runtime,
it was not _available_ inside that nested command execution and
evaluated to the zero-value.

Additionally, this is the Command/init pattern demonstrated in the
[Cobra
docs](https://github.com/spf13/cobra/blob/main/site/content/user_guide.md#create-rootcmd),
and we should stay aligned with their documented best-practices.

Finally I think it's much clearer the previous pattern, but I am used to
reading and writing Cobra-style CLIs 🙂

## Related Issue

I started investigating #258 and ended up here. Incidentally fixes #258.

## Checklist

- [x] I have read the [contributing
documentation](https://retina.sh/docs/contributing).
- [x] I signed and signed-off the commits (`git commit -S -s ...`). See
[this
documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
on signing commits.
- [x] I have correctly attributed the author(s) of the code.
- [x] I have tested the changes locally.
- [x] I have followed the project's style guidelines.
- [x] I have updated the documentation, if necessary.
- [x] I have added tests, if applicable.

## Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes
made.

## Additional Notes

Add any additional notes or context about the pull request here.

---

Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more
information on how to contribute to this project.

---------

Signed-off-by: Evan Baker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/captures lang/go The Go Programming Language priority/1 P1 type/bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants