diff --git a/src/asdf-package/NOTES.md b/src/asdf-package/NOTES.md new file mode 100644 index 000000000..a4e69fafe --- /dev/null +++ b/src/asdf-package/NOTES.md @@ -0,0 +1,6 @@ +## Additional Notes + +- If version is excluded, latest is assumed. +- If repo is excluded, is assumed. +- If you are installing multiple versions of the same plugin, the last one in this list will be set as global version. +- Version matching is done using asdf's `latest:` format, so inputting `python:3.11` will install the latest stable version of Python 3.11 diff --git a/src/asdf-package/devcontainer-feature.json b/src/asdf-package/devcontainer-feature.json index 8e9ce4c9c..31c143075 100644 --- a/src/asdf-package/devcontainer-feature.json +++ b/src/asdf-package/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "asdf package", "id": "asdf-package", - "version": "1.0.8", + "version": "2.0.0", "description": "Installs an asdf package.", "documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/asdf-package", "installsAfter": [ @@ -15,24 +15,7 @@ "nomad" ], "default": "", - "description": "Select the asdf plugin to install." - }, - "version": { - "type": "string", - "proposals": [ - "latest" - ], - "default": "latest", - "description": "Select the version of the asdf plugin to install." - }, - "pluginRepo": { - "type": "string", - "proposals": [ - "https://github.com/grimoh/asdf-act.git", - "https://github.com/asdf-community/asdf-hashicorp.git" - ], - "default": "", - "description": "Select the asdf plugin repo to install (can remain empty in order to use the plugin short-name index https://github.com/asdf-vm/asdf-plugins)" + "description": "A space-separated list of one or more asdf plugins to install. Additionally, version and/or repository can be specified in the format 'name:version@repo'. " }, "latestVersionPattern": { "type": "string", diff --git a/src/asdf-package/install.sh b/src/asdf-package/install.sh index 7d5f22011..17f6cfe47 100755 --- a/src/asdf-package/install.sh +++ b/src/asdf-package/install.sh @@ -4,8 +4,6 @@ set -ex PLUGIN=${PLUGIN:-""} -VERSION=${VERSION:-"latest"} -PLUGINREPO=${PLUGINREPO:-""} LATESTVERSIONPATTERN=${LATESTVERSIONPATTERN:-""} # Clean up @@ -142,4 +140,33 @@ EOF fi } -install_via_asdf "$PLUGIN" "$VERSION" "$PLUGINREPO" \ No newline at end of file +set -- $PLUGIN +while [ -n "$1" ]; do + if [[ "$1" == *":"* ]] && [[ "$1" == *"@"* ]]; then + # Name, Version, and Repo + PLUGINNAME=$(echo $1 | awk -F ':' '{print $1}') + VERSION="latest:$(echo $1 | awk -F ':' '{print $2}' | awk -F '@' '{print $1}')" + PLUGINREPO=$(echo $1 | awk -F '@' '{print $2}') + elif [[ "$1" == *":"* ]]; then + # Name and Version + PLUGINNAME=$(echo $1 | awk -F ':' '{print $1}') + VERSION="latest:$(echo $1 | awk -F ':' '{print $2}')" + PLUGINREPO="" + elif [[ "$1" == *"@"* ]]; then + # Name and Repo + PLUGINNAME=$(echo $1 | awk -F '@' '{print $1}') + VERSION="latest" + PLUGINREPO=$(echo $1 | awk -F '@' '{print $2}') + else + # Name Only + PLUGINNAME="$1" + VERSION="latest" + PLUGINREPO="" + fi + if [ "$VERSION" = "latest:latest" ]; then + # This catches an edge case where users specifically put in 'name:latest' + VERSION="latest" + fi + install_via_asdf "$PLUGINNAME" "$VERSION" "$PLUGINREPO" + shift +done \ No newline at end of file diff --git a/test/asdf-package/install_act_and_rabbitmq.sh b/test/asdf-package/install_act_and_rabbitmq.sh new file mode 100644 index 000000000..dc5ce3ea2 --- /dev/null +++ b/test/asdf-package/install_act_and_rabbitmq.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + + +check "asdf list act" asdf list act +check "asdf list rabbitmq" asdf list rabbitmq +check "type rabbitmqctl" type rabbitmqctl + +reportResults diff --git a/test/asdf-package/install_python_with_partial_version.sh b/test/asdf-package/install_python_with_partial_version.sh new file mode 100644 index 000000000..75c52066d --- /dev/null +++ b/test/asdf-package/install_python_with_partial_version.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + + +check "asdf list python" asdf list python + + +reportResults diff --git a/test/asdf-package/scenarios.json b/test/asdf-package/scenarios.json index bfcf03999..dccf84bfd 100644 --- a/test/asdf-package/scenarios.json +++ b/test/asdf-package/scenarios.json @@ -2,10 +2,11 @@ "install_rabbitmq": { "image": "debian:bullseye", "features": { - "ghcr.io/devcontainers-contrib/features/apt-get-packages" : {"packages": "xz-utils"}, + "ghcr.io/devcontainers-contrib/features/apt-get-packages": { + "packages": "xz-utils" + }, "asdf-package": { - "version": "v3.12.0", - "plugin": "rabbitmq", + "plugin": "rabbitmq:v3.12.0", "latestVersionPattern": "v" } } @@ -14,8 +15,7 @@ "image": "debian:bullseye", "features": { "asdf-package": { - "version": "latest", - "plugin": "act" + "plugin": "act:latest" } } }, @@ -23,9 +23,7 @@ "image": "debian:bullseye", "features": { "asdf-package": { - "version": "latest", - "plugin": "act", - "pluginRepo": "https://github.com/grimoh/asdf-act.git" + "plugin": "act:latest@https://github.com/grimoh/asdf-act.git" } } }, @@ -33,8 +31,32 @@ "image": "mcr.microsoft.com/devcontainers/base:alpine-3.17", "features": { "asdf-package": { - "version": "latest", - "plugin": "terraform" + "plugin": "terraform:latest" + } + } + }, + "install_act_and_rabbitmq": { + "image": "debian:bullseye", + "features": { + "ghcr.io/devcontainers-contrib/features/apt-get-packages": { + "packages": "xz-utils" + }, + "asdf-package": { + "plugin": "act:latest rabbitmq:v3.12.0" + } + } + }, + "install_python_with_partial_version": { + "image": "debian:bullseye", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "upgradePackages": "true" + }, + "ghcr.io/devcontainers-contrib/features/apt-get-packages": { + "packages": "build-essential,libssl-dev,zlib1g-dev,libbz2-dev,libreadline-dev,libsqlite3-dev,curl,libncursesw5-dev,xz-utils,tk-dev,libxml2-dev,libxmlsec1-dev,libffi-dev,liblzma-dev" + }, + "asdf-package": { + "plugin": "python:3.11" } } }