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

feat: allow string interpolation on resource options #597

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

chesedo
Copy link
Contributor

@chesedo chesedo commented Jan 26, 2023

This PR allows options passed to resources to be string interpolated. For example in this local_uri option, the password is being read from the Secrets.toml file

#[shuttle_service::main]
async fn main(
    #[shuttle_shared_db::Postgres(
        local_uri = "postgres://postgres:{secrets.password}@localhost:16695/postgres"
    )]
    pool: PgPool,
) -> shuttle_service::ShuttlePoem<impl poem::Endpoint> {
    ...
}

With #596, this closes #497

Copy link
Contributor

@oddgrd oddgrd left a comment

Choose a reason for hiding this comment

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

This is really cool! 🤩 This may be obvious, but what will the error be if it tries to interpolate a secret and it doesn't exist? It looks like it will always be interpolation error, should there also be a not found error if we check and it doesn't exist? Or we could just add a bit about making sure the secrets is added to Secrets.toml to the interpolation error message..

@chesedo
Copy link
Contributor Author

chesedo commented Jan 26, 2023

@oddgrd This is the error message:

Error: Failed to interpolate string: KeyError(Invalid key: secrets.passwor)

@chesedo
Copy link
Contributor Author

chesedo commented Jan 26, 2023

Now the error is 😄

Error: Failed to interpolate string. Is your Secrets.toml correct?

Caused by:
    KeyError(Invalid key: secrets.Password)

@chesedo chesedo merged commit 083cc6a into shuttle-hq:main Jan 26, 2023
@chesedo chesedo deleted the feat/resources_string_interpolation branch January 26, 2023 10:18
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

Successfully merging this pull request may close these issues.

Override provisioned resources on local runs
2 participants