Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.

Update feature asdf-package to allow installing multiple packages #498

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/asdf-package/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Additional Notes

- If version is excluded, latest is assumed.
- If repo is excluded, <https://github.com/asdf-vm/asdf-plugins> 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:<version>` format, so inputting `python:3.11` will install the latest stable version of Python 3.11
21 changes: 2 additions & 19 deletions src/asdf-package/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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",
Expand Down
33 changes: 30 additions & 3 deletions src/asdf-package/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
set -ex

PLUGIN=${PLUGIN:-""}
VERSION=${VERSION:-"latest"}
PLUGINREPO=${PLUGINREPO:-""}
LATESTVERSIONPATTERN=${LATESTVERSIONPATTERN:-""}

# Clean up
Expand Down Expand Up @@ -142,4 +140,33 @@ EOF
fi
}

install_via_asdf "$PLUGIN" "$VERSION" "$PLUGINREPO"
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
12 changes: 12 additions & 0 deletions test/asdf-package/install_act_and_rabbitmq.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions test/asdf-package/install_python_with_partial_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

source dev-container-features-test-lib


check "asdf list python" asdf list python


reportResults
42 changes: 32 additions & 10 deletions test/asdf-package/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand All @@ -14,27 +15,48 @@
"image": "debian:bullseye",
"features": {
"asdf-package": {
"version": "latest",
"plugin": "act"
"plugin": "act:latest"
}
}
},
"install_act_with_repo": {
"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"
}
}
},
"install_terraform_alpine": {
"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"
}
}
}
Expand Down