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

add cmd-drop-env to AuthProviderConfig #1074

Merged
merged 1 commit into from Nov 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions kube-client/src/client/auth/mod.rs
Expand Up @@ -363,9 +363,16 @@ fn token_from_gcp_provider(provider: &AuthProviderConfig) -> Result<ProviderToke
// Command-based token source
if let Some(cmd) = provider.config.get("cmd-path") {
let params = provider.config.get("cmd-args").cloned().unwrap_or_default();

// NB: This property does currently not exist upstream in client-go
// See https://github.com/kube-rs/kube/issues/1060
let drop_env = provider.config.get("cmd-drop-env").cloned().unwrap_or_default();
Copy link
Member

@clux clux Nov 19, 2022

Choose a reason for hiding this comment

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

This is basically just a freestyle property through the upstream map: https://github.com/kubernetes/client-go/blob/7697067af71046b18e03dbda04e01a5bb17f9809/tools/clientcmd/api/types.go#L167-L172 right?

I'm OK with it, but would add a comment that it's a non-standard property that's not used in client-go/kubectl if there's no upstream equivalent for it.

// TODO splitting args by space is not safe
let output = Command::new(cmd)
let mut command = Command::new(cmd);
// Do not pass the following env vars to the command
for env in drop_env.trim().split(' ') {
command.env_remove(env);
}
let output = command
.args(params.trim().split(' '))
.output()
.map_err(|e| Error::AuthExec(format!("Executing {:} failed: {:?}", cmd, e)))?;
Expand Down