-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
Adding google cloud auth per exec #328
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments
} | ||
} else { | ||
return Err(ConfigError::AuthExec(format!("no token or command provided. Authoring mechanism {:} not supported", provider.name)).into()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this else case happening when token.is_some(), don't you need another is_none check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, this is supposed to be the else for the previous block. will fix.
kube/src/config/file_config.rs
Outdated
format!("Can't lookup {:?} in result of command: not an object", item) | ||
).into()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, hacky. This at least makes it easy to understand, but it probably won't work well if people use a more complicated JSONPath selector?
How would you feel like using https://crates.io/crates/jsonpath_lib ? It looks like a good swap-in.
We can probably benefit from selector helpers using that anyway in the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't want to add any dependency before sending it up, but if that is fine with you I am happy to add this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, this feels like one of those libraries that matches very well anyway :-)
Hey! Thanks a lot for this. Will definitely want this in here. Just left some comments on a few things. Also have one request if it's possible; a way to test it. I know it's not great to have to have a gcp cluster for testing, so maybe a test config embedded in that file which causes a shellout to a local script that just echoes some static json? |
Good idea. How about just using |
Yeah, |
@clux addressed your suggestions: now uses the jsonpath-lib and has a test for the feature. do you mind publishing a release soon after? I'd like to use this is a cli and it would be nice to not depend on git for it :) . |
Awesome, tyvm! I only left a few small questions there for my own sanity. But error handling and code looks great. |
so, I found one more quirk ... even though I get an access_token immediately, it sometimes refuses to use that with an error message, telling me to try again later – and seconds after it worked. Not sure, if we can/want to do anything about that ... |
Does that error cause a whole re-authentication cycle? We don't write to our local config, but Is there something you need to wait for in gcp before it's valid? |
At any rate, I am happy to merge this as it stands and make a release today. Though would be good to keep track of any upcoming work needed for avoiding re-authing. Have linked #84 which seem covered by this PR. |
I'll merge it for now anyway, we can tackle the other things when we get to it. Thanks again for your work! |
Released in 0.43.0 :-) |
Looks like the latest
gcloud
-setup uses some exec-path-features in thekubectl
config system, that is not yet implemented. This PR implements it. If there is not access-token nor id-token given, but a command specified, that command is run with the configured parameters and the output is searched (considered to bejson
) with the path configured. The token is then used. Errors are thrown as appropriate.Example kubectl config: