-
Notifications
You must be signed in to change notification settings - Fork 80
feat: add vault-cli module with optional token configuration #575
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
Conversation
2c450c7 to
060db3f
Compare
d5811bc to
c8a597c
Compare
c8a597c to
3ae221e
Compare
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.
Pull request overview
This PR introduces a new vault-cli module that provides Vault CLI installation with optional token and namespace configuration. The module serves as a foundational component intended to reduce code duplication across existing vault modules (vault-github, vault-jwt, vault-token) in future updates.
Key Changes:
- Adds Vault CLI installation with automatic version detection and multi-OS support
- Implements optional token and namespace authentication via environment variables
- Introduces semantic version validation for the Vault CLI version parameter
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| registry/coder/modules/vault-cli/run.sh | Bash script implementing Vault CLI installation with OS detection, architecture mapping, and custom installation directory support |
| registry/coder/modules/vault-cli/main.tf | Terraform module configuration with conditional environment variable resources for token and namespace |
| registry/coder/modules/vault-cli/main.tftest.hcl | Comprehensive test suite covering various configuration scenarios including token, namespace, versioning, and validation cases |
| registry/coder/modules/vault-cli/README.md | Module documentation with usage examples for different authentication scenarios and related module references |
3a41d0d to
dba2115
Compare
0cd22f6 to
fce6422
Compare
…ation Closes #50 This adds a new vault-cli module that: - Installs the Vault CLI using the official HashiCorp releases API - Uses jq to parse API response when available, falls back to sed - Fetches download URL directly from API (with fallback to constructed URL) - Optionally configures token authentication if provided - Optionally configures Vault Enterprise namespace if provided - Sets up VAULT_ADDR environment variable - Conditionally sets VAULT_TOKEN environment variable when token is provided - Conditionally sets VAULT_NAMESPACE environment variable when namespace is provided - Validates vault_cli_version must be 'latest' or a semantic version without v prefix The module can be used standalone for just CLI installation, or with a token and/or namespace for authentication scenarios.
fce6422 to
e1f4a9a
Compare
|
given run.sh has reqs like jq, unzip, wget/curl etc, maybe this should be noted in README.md so consumers know what is needed to use this upfront? |
Address review feedback: - Combine fetch_stdout() and fetch() into single fetch() function - fetch <url> outputs to stdout, fetch <url> <dest> writes to file - HTTP client detection is cached and reused for both cases - Fixes issue where curl was used explicitly for API calls but fetch() function supported wget/busybox
README validation requires Terraform code block in h1 section
…ments
The $${} syntax is Terraform template escaping which shellcheck
doesn't understand. Added disable directive for both case statements
in the fetch() function.
rowansmithau
left a comment
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.
tested myself locally with and without supplying a vault token, looks good to me
Closes #50
This adds a new
vault-climodule that:VAULT_ADDRenvironment variableVAULT_TOKENenvironment variable when token is providedVAULT_NAMESPACEenvironment variable when namespace is providedvault_cli_versionmust belatestor a semantic version (x.y.z)The module can be used standalone for just CLI installation, or with a token and/or namespace for authentication scenarios.
Follow-up
As a follow-up, we will update the other vault modules (
vault-github,vault-jwt,vault-token) to use this module for CLI installation, reducing code duplication.