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

Ability to directly specify the auth token #72

Open
jemerald opened this issue Jul 30, 2020 · 3 comments
Open

Ability to directly specify the auth token #72

jemerald opened this issue Jul 30, 2020 · 3 comments

Comments

@jemerald
Copy link

Currently the withKubeConfig function only accepts Jenkins credentialsId, but our company requires actual user's token when deploying to production (as a mean to restrict the users that can deploy to production).

So out pipeline would prompt the user to enter his token before deploying to production.

Is it possible to add an extra parameter in the plugin to allow passing in the token directly?

@maxlaverse
Copy link
Collaborator

Hi @jemerald,
This use case is not supported currently
As a workaround have you thought about executing kubectl config set-credentials --token=$USER_INPUT as the first command within the withKubeConfig() block ?

@jemerald
Copy link
Author

I have thought about that, however it has 2 problems:

  1. expose the token on the job's console log, which is not desirable.
  2. kubectl config set-credentials --token=$USER_INPUT doesn't actually work as we need to specify the username kubectl config set-credentials <username> --token=$USER_INPUT. Looking at the file content it looks like withKubeConfig uses the credentialsId as the username, but that's an implementation detail of the plugin that we probably shouldn't rely on.

We are current using this workaround:

def kubeConfig = readYaml file: env.KUBECONFIG
kubeConfig.users[0].user.token = authToken
writeYaml file: env.KUBECONFIG, data: kubeConfig, overwrite: true

However this workaround is still a little coupled to the structure of the config file.

Will you consider adding support for passing in the token to withKubeConfig?

@maxlaverse
Copy link
Collaborator

However this workaround is still a little coupled to the structure of the config file.

Agreed

Will you consider adding support for passing in the token to withKubeConfig?

The purpose of this plugin is to help configure kubectl, so it would make sense to have this feature integrated in the plugin if users need it. I'm not sure how quick I would find time to implement it myself however

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

No branches or pull requests

2 participants