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

Allow API keys to be set by an environment variable #79

Closed
sloria opened this issue Jan 20, 2019 · 6 comments
Closed

Allow API keys to be set by an environment variable #79

sloria opened this issue Jan 20, 2019 · 6 comments

Comments

@sloria
Copy link
Contributor

sloria commented Jan 20, 2019

Use case: I'd like to add all-repos.json to source control without committing my API_KEY.

    "source_settings":  {
        "api_key": "$GITHUB_API_KEY",
        "org": "marshmallow-code"
    }
@asottile
Copy link
Owner

I don't really want to support arbitrary templating / complex configuration loading schemes (it's the reason json is chosen as the configuration format)

@sloria
Copy link
Contributor Author

sloria commented Jan 20, 2019

Fair enough. What about an additional option then, e.g. "api_key_var": "GITHUB_API_KEY", that is mutually exclusive of "api_key"?

@asottile
Copy link
Owner

feels like that'll open a bunch of new edge cases and error cases -- I'd really rather keep this simple, I don't think that checking in the configuration is the right answer here.

If you want templating, you could always implement it with sed or such:

sed "s/API_KEY/${API_KEY}/g" all-repos.template.json > all-repos.json

check in the template and a little wrapper script / make target / whatever and you're good to go

@asottile
Copy link
Owner

plus you'll hit this wall with git-managed files:

if mode != 0o600:

@sloria
Copy link
Contributor Author

sloria commented Jan 20, 2019

OK, I'll just use the .template.json workaround for now. Thanks for the suggestion.

@sloria sloria closed this as completed Jan 20, 2019
@jfly
Copy link

jfly commented May 15, 2024

For anyone else who lands here, it looks like all-repos does now have support for reading API key from env vars =) b3d2d9e

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

3 participants