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

Patch pack #1 #3

Merged
merged 7 commits into from
Aug 8, 2024
Merged
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: 5 additions & 1 deletion src/localstack-cli/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ This Feature should work on recent versions of Debian/Ubuntu-based distributions

`bash` is required to execute the `install.sh` script.

`cdklocal` option requires `npm` to be installed which is not handled by this feature. All other tools are installed by `pipx` which is installed via package manager or the Python installation. The latter can be combined with the Python feature.
`cdklocal` option requires `npm` to be installed which is not handled by this feature.
All other tools are installed by `pipx` which is installed via package manager or the Python installation. The latter can be combined with the Python feature.

> [!NOTE]
> None of the wrapped tool(s) (ie Terraform, Pulumi or AWS CLI...etc), are handled by this feature, to install the underlying tool(s) please use the respective feature from the [DevContainer Feature Community Index](https://containers.dev/features).
8 changes: 7 additions & 1 deletion src/localstack-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"lts",
"latest",
"stable",
"3.6.0",
"3.5.0",
"3.4.0",
"3.3.0",
Expand Down Expand Up @@ -57,6 +58,11 @@
},
"installsAfter": [
"ghcr.io/devcontainers/features/python",
"ghcr.io/devcontainers/features/node"
"ghcr.io/devcontainers/features/node",
"ghcr.io/devcontainers/features/aws-cli",
"ghcr.io/devcontainers-contrib/features/aws-cdk",
"ghcr.io/customink/codespaces-features/sam-cli",
"ghcr.io/devcontainers-contrib/features/pulumi",
"ghcr.io/devcontainers/features/terraform"
]
}
49 changes: 48 additions & 1 deletion src/localstack-cli/install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,25 @@ pkg_mgr_update() {
esac
}

add_backports() {
case ${ID} in
debian)
echo "deb http://ftp.debian.org/debian ${VERSION_CODENAME}-backports main" |
tee /etc/apt/sources.list.d/backports.list
;;
ubuntu)
echo "deb http://archive.ubuntu.com/ubuntu ${VERSION_CODENAME}-backports main" |
tee /etc/apt/sources.list.d/backports.list
;;
esac
}

# Checks if packages are installed and installs them if not
check_packages() {
case ${ADJUSTED_ID} in
debian)
if ! dpkg -s "$@" > /dev/null 2>&1; then
add_backports
pkg_mgr_update
${INSTALL_CMD} "$@"
fi
Expand Down Expand Up @@ -157,11 +171,41 @@ install_with_complete_python_installation() {
set -e
}

warn() {
echo "WARNING: $1 not found on PATH, though local wrapper is being installed"
}

is_tool() {
! type $1 &> /dev/null
return $?
}

check_tool() {
local tool=$(eval echo "\$$1")
case $tool in
awscli-local)
is_tool aws && warn awscli
;;
aws-cdk-local)
is_tool cdk && warn aws-cdk
;;
pulumi-local)
is_tool pulumi && warn pulumi
;;
terraform-local)
(is_tool terraform || is_tool tofu) && warn terraform/tofu
;;
aws-sam-cli-local)
is_tool sam && warn aws-sam-cli
;;
esac
}

install_tool() {
local tool=$(eval echo "\$$1")
case $tool in
aws-cdk-local)
npm install -g $tool aws-cdk
npm install -g $tool
;;
*)
PIPX_HOME="/usr/local/pipx" \
Expand All @@ -173,10 +217,13 @@ install_tool() {

install_tools() {
for tool in ${TOOLS[@]}; do
check_tool $tool
install_tool $tool
done
}

add_backports

install_using_pip_strategy

install_tools
Expand Down
4 changes: 2 additions & 2 deletions test/localstack-cli/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version_lts": {
"image": "mcr.microsoft.com/devcontainers/base:bookworm",
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
"user": "vscode",
"features": {
"localstack-cli": {
Expand All @@ -9,7 +9,7 @@
}
},
"version_none": {
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"image": "mcr.microsoft.com/devcontainers/base:focal",
"user": "vscode",
"features": {
"localstack-cli": {
Expand Down
Loading