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: support getting package versions from external files #3363

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

suzuki-shunsuke
Copy link
Member

@suzuki-shunsuke suzuki-shunsuke commented Dec 15, 2024

Close #3061

This pull request enables us to get package versions from external files.
This feature is useful when

  • Migrate any tool to aqua gradually
  • Support aqua and other tools

This pull request adds some fields to aqua.yaml's packages.

  • version_expr: An expr expression to read external files
  • version_expr_prefix: A prefix of version

e.g.

packages:
- name: hashicorp/terraform
  version_expr: |
    "v" + readFile('.terraform-version')
  version_expr: |
    readJSON('version.json').version
  version_expr_prefix: cli-
  version_expr: |
    readYAML('version.yaml').version

version_expr is evaluated using expr.
The following custom functions are available.

  • readFile("file path"): reads a file and returns a file content
  • readJSON("file path"): read and unmarshal a JSON file and returns an object
  • readYAML("file path"): read and unmarshal a YAML file and returns an object

Constraint of version_expr

Allowing to read external files is potentially risky in terms of security.
Malicious users can try to read secret files and expose secrets via log using version_expr.
To prevent such a threat, we restrict the evaluation result of version_expr.
It must match with the regular expression ^v?\d+\.\d+(\.\d+)*[.-]?((alpha|beta|dev|rc)[.-]?)?\d*.

@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Dec 15, 2024
@suzuki-shunsuke suzuki-shunsuke marked this pull request as ready for review December 15, 2024 13:54
@suzuki-shunsuke suzuki-shunsuke added this to the v2.39.1 milestone Dec 15, 2024
@suzuki-shunsuke
Copy link
Member Author

suzuki-shunsuke commented Dec 15, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support getting package versions from other files
1 participant