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

A dictionary of templated variables in registry and query mechanizm #1673

Closed
Tracked by #1666
suzuki-shunsuke opened this issue Feb 26, 2023 Discussed in #1496 · 1 comment
Closed
Tracked by #1666

A dictionary of templated variables in registry and query mechanizm #1673

suzuki-shunsuke opened this issue Feb 26, 2023 Discussed in #1496 · 1 comment
Labels
enhancement New feature or request

Comments

@suzuki-shunsuke
Copy link
Member

Discussed in https://github.com/orgs/aquaproj/discussions/1496

Originally posted by iilyak December 30, 2022
Some of the packages require setting of environment variables to make them work. For example golang require GOPATH (for old versions of go), java require JAVA_PATH. I set environment variables in .envrc (and use https://direnv.net/ to load them).

For Java specifically I have following line.

export JAVA_HOME=$(dirname $(dirname $(expand_path $(aqua which java) "/")))

My concern is that the user of the package need to know the layout of the package.

The idea is to let aqua define a dictionary and have a mechanism to get values from dictionary.

packages:
  - name: java/openjdk
    type: http
    repo_owner: openjdk
    repo_name: jdk
    description: JDK main-line development https://openjdk.org/projects/jdk
    replacements:
      amd64: x64
      arm64: aarch64
      darwin: macos
    environment:
      - name: "JAVA_HOME"
        value: jdk-{{.Version}}.jdk/Contents/Home

Currently aqua doesn't care about fields it doesn't know about. So I changed the registry.yaml as described above and used https://github.com/TomWright/dasel to extract the values.

❯ dasel -f registry.yaml -r yaml 'packages.all().filter(and(equal(type(),object),equal(name,java/openjdk))).environment'
- name: JAVA_HOME
  value: jdk-{{.Version}}.jdk/Contents/Home/bin/

This doesn't solve my problem for two reasons.

  1. the value need to be rendered
  2. in order to invoke dasel the user need to know the structure of registry.yaml.

I am thinking about the possibility of a query mechanism in the aqua itself.

> aqua env java/openjdk
{
    "JAVA_HOME": "/Users/iilyak/.local/share/aquaproj-aqua/pkgs/http/download.java.net/java/GA/jdk18.0.2.1/db379da656dc47308e138f21b33976fa/1/GPL/openjdk-18.0.2.1_macos-aarch64_bin.tar.gz/jdk-18.0.2.1.jdk/Contents/Home",
    "FOO": "something" 
}

> aqua env --format yaml java/openjdk
JAVA_HOME: "/Users/iilyak/.local/share/aquaproj-aqua/pkgs/http/download.java.net/java/GA/jdk18.0.2.1/db379da656dc47308e138f21b33976fa/1/GPL/openjdk-18.0.2.1_macos-aarch64_bin.tar.gz/jdk-18.0.2.1.jdk/Contents/Home"
FOO: something

> aqua env java/openjdk JAVA_HOME
/Users/iilyak/.local/share/aquaproj-aqua/pkgs/http/download.java.net/java/GA/jdk18.0.2.1/db379da656dc47308e138f21b33976fa/1/GPL/openjdk-18.0.2.1_macos-aarch64_bin.tar.gz/jdk-18.0.2.1.jdk/Contents/Home

> aqua env --format yaml java/openjdk JAVA_HOME
JAVA_HOME: "/Users/iilyak/.local/share/aquaproj-aqua/pkgs/http/download.java.net/java/GA/jdk18.0.2.1/db379da656dc47308e138f21b33976fa/1/GPL/openjdk-18.0.2.1_macos-aarch64_bin.tar.gz/jdk-18.0.2.1.jdk/Contents/Home"

> aqua env --format shell java/openjdk
JAVA_HOME=/Users/iilyak/.local/share/aquaproj-aqua/pkgs/http/download.java.net/java/GA/jdk18.0.2.1/db379da656dc47308e138f21b33976fa/1/GPL/openjdk-18.0.2.1_macos-aarch64_bin.tar.gz/jdk-18.0.2.1.jdk/Contents/Home
FOO=something

> aqua env keys java/openjdk
JAVA_HOME
FOO

Then I can use the following in my .envrc

IFS=$'\n'; for entry in $(aqua env --format bash java/openjdk); do     export $entry; done

I can also use it to set variables in fish:

export (aqua env --format bash java/openjdk)
```</div>
@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Feb 26, 2023
@suzuki-shunsuke
Copy link
Member Author

#1496 (comment)

Thank you for your proposal.

Unfortunately, we don't work on this proposal soon, because

  1. aqua should be simple and easy to use so that we can introduce aqua in your teams, projects, and organizations easily. New users should be able to use aqua without high learning cost. So we should be careful to add new commands and increase the learning cost
  2. Currently, we are working on another issues so we don't have enough time to consider this proposal
  3. This feature is unneeded for almost packages, so the priority is low

On the other hand, this proposal is interesting so we'll consider when we have a time.
We have to design simple user interface.

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

No branches or pull requests

1 participant