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

[auth] Allow to construct CredentialsFile from plain &str #200

Closed
benjaminch opened this issue Oct 11, 2023 · 1 comment
Closed

[auth] Allow to construct CredentialsFile from plain &str #200

benjaminch opened this issue Oct 11, 2023 · 1 comment

Comments

@benjaminch
Copy link
Contributor

Hi there! :)

Context

I would be super nice to be able to construct CredentialsFile from plain &str instead of having to pass a file path (eventually have to create a file) or set an environment variable.
Let's say you have the credentials json content already, it's not very handy to put its content to a file or to set an environment variable in order to construct CredentialsFile.

Proposal

Having a new function in CredentialsFile taking a plain &str (meant to be credentials json content) and returning a CredentialsFile:

pub async fn new_from_str(str: &str) -> Result<Self, Error> {
    Ok(serde_json::from_str(str)?)
}

One can then use the API this way:

const CREDENTIALS_FILE_CONTENT: &str = "<CREDENTIALS_FILE_CONTENT_GOES_HERE>";

let credentials_file = CredentialsFile::new_from_str(CREDENTIALS_FILE_CONTENT).await;

Thanks a lot :)

benjaminch added a commit to Qovery/google-cloud-rust that referenced this issue Oct 11, 2023
benjaminch added a commit to Qovery/google-cloud-rust that referenced this issue Oct 11, 2023
benjaminch added a commit to Qovery/google-cloud-rust that referenced this issue Oct 12, 2023
benjaminch added a commit to Qovery/google-cloud-rust that referenced this issue Oct 13, 2023
benjaminch added a commit to Qovery/google-cloud-rust that referenced this issue Oct 13, 2023
@benjaminch
Copy link
Contributor Author

Merged ! #201

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

1 participant