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

config: Support opting into GitHub token auth #409

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

abhinav
Copy link
Contributor

@abhinav abhinav commented Jun 13, 2024

Adds a new per-project configuration to hermit.hcl
allowing opting GitHub owner/repo patterns to opt into
token-based authentication instead of anonymous.
For example:

github-auth-token {
  match = ["cashapp/*"]
}

The option accepts any number of glob patterns,
allowing for fine-grained control over which dependencies
get authenticated requests.

This will make it possible to use Hermit with private repositories
without distributing a custom build.

The plumbing for this required a small amount of refactoring:
The new hermit.LoadEnvInfo inspects a Hermit environment
and loads the configuration, but does not open the environment.
The information is later passed to the old hermit.OpenEnv function.

This separation is necessary because cache and state are inputs to
OpenEnv, but we need to inspect the environment configuration to decide
on their inputs.

Resolves #406

Adds a new per-project configuration to hermit.hcl
allowing opting GitHub owner/repo patterns to opt into
token-based authentication instead of anonymous.
For example:

    github-auth-token {
      match = ["cashapp/*"]
    }

The option accepts any number of glob patterns,
allowing for fine-grained control over which dependencies
get authenticated requests.

This will make it possible to use Hermit with private repositories
without distributing a custom build.

The plumbing for this required a small amount of refactoring:
The new hermit.LoadEnvInfo inspects a Hermit environment
and loads the configuration, but does not open the environment.
The information is later passed to the old hermit.OpenEnv function.

This separation is necessary because cache and state are inputs to
OpenEnv, but we need to inspect the environment configuration to decide
on their inputs.

Resolves cashapp#406
@@ -275,40 +283,67 @@ func readConfig(configFile string) (*Config, error) {
return config, nil
}

// EnvInfo holds information about the current Hermit environment.
type EnvInfo struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice nice

@alecthomas alecthomas merged commit 76fa17e into cashapp:master Jun 21, 2024
6 checks passed
@alecthomas
Copy link
Collaborator

Thanks!

@abhinav abhinav deleted the gh-private-release branch June 21, 2024 15:24
abhinav added a commit to abhinav/hermit that referenced this pull request Jun 21, 2024
PR cashapp#409 added support for opting packages into GitHub token
authentication with a `github-token-auth` block in `bin/hermit.hcl`.

This adds information about this feature to the private releases
documentation, and adds an entry to the config reference.
spicykay pushed a commit to spicykay/hermit that referenced this pull request Aug 23, 2024
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.

Opt-in to use GitHub API to fetch releases
2 participants