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

Support defining a KubeConfig Secret data key #615

Merged
merged 1 commit into from
Apr 29, 2022

Conversation

nstogner
Copy link
Contributor

@nstogner nstogner commented Apr 11, 2022

Fixes #613.

@nstogner nstogner force-pushed the secret-ref-key branch 2 times, most recently from 47cdf1d to 8d27221 Compare April 23, 2022 22:00
@nstogner
Copy link
Contributor Author

Looking for feedback on the code changes in this PR. NOTE: make test is failing due to crd doc generation. Not sure if this is b/c I am currently pulling in a non-tagged version of pkg/apis/meta (until the SecretKeyRefernce type makes its way into a tagged release).

@hiddeco
Copy link
Member

hiddeco commented Apr 26, 2022

I think that running make api-docs should be sufficient to deal with this. After running this, I get a

$ git status
On branch secret-ref-key
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   docs/api/kustomize.md

and make test succeeds.

@hiddeco hiddeco added the enhancement New feature or request label Apr 26, 2022
@hiddeco hiddeco self-requested a review April 26, 2022 20:51
controllers/kustomization_impersonation.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
api/go.mod Outdated Show resolved Hide resolved
@nstogner nstogner force-pushed the secret-ref-key branch 2 times, most recently from 4babc32 to d9c541f Compare April 27, 2022 13:10
@hiddeco hiddeco changed the title Add .spec.kubeConfig.secretRef.key Support defining a KubeConfig Secret data key Apr 28, 2022
@hiddeco hiddeco force-pushed the secret-ref-key branch 2 times, most recently from 3393f9d to 19f4971 Compare April 28, 2022 20:41
if len(kubeConfig) == 0 {
return nil, fmt.Errorf("KubeConfig secret '%s' doesn't contain a 'value' key ", secretName.String())
if key := ki.kustomization.Spec.KubeConfig.SecretRef.Key; key != "" {
kubeConfig = secret.Data[key]
Copy link
Member

@hiddeco hiddeco Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In retrospect also better for helm-controller.

If the user has declared their own configuration, it might be better to error out to let them know their configuration is not correct, including the key in the error string. This helps detecting typos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added error containing user-specified secret key name

@hiddeco hiddeco added this to the GA milestone Apr 29, 2022
Signed-off-by: Nick Stogner <nicholas.stogner@gmail.com>
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this 💯

Thanks a lot 🙇🏼‍♂️, and sorry for being a pain with nitpicks 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Support specifying a Secret key containing a kubeconfig
3 participants