diff --git a/src/ansible-galaxy/NOTES.md b/src/ansible-galaxy/NOTES.md deleted file mode 100644 index 7ead7ca..0000000 --- a/src/ansible-galaxy/NOTES.md +++ /dev/null @@ -1,5 +0,0 @@ - - -## OS Support - -This Feature should work on recent versions of Debian/Ubuntu-based distributions. Requires Ansible. diff --git a/src/ansible-galaxy/devcontainer-feature.json b/src/ansible-galaxy/devcontainer-feature.json deleted file mode 100644 index b1ab95b..0000000 --- a/src/ansible-galaxy/devcontainer-feature.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "ansible-galaxy", - "version": "0.0.1", - "name": "Ansible galaxy collections", - "documentationURL": "https://github.com/framctr/devcontainer-features/tree/main/src/ansible-galaxy", - "description": "Install ansible galaxy collections.", - "options": { - "collections": { - "type": "string", - "default": "", - "description": "Install collections (space separated)" - } - }, - "installsAfter": [ - "ghcr.io/devcontainers-contrib/features/ansible" - ] -} \ No newline at end of file diff --git a/src/ansible-galaxy/install.sh b/src/ansible-galaxy/install.sh deleted file mode 100644 index 9729037..0000000 --- a/src/ansible-galaxy/install.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -set -e - -echo "------------------------------------------------------------------------------------------------------------------------------------" -echo Which ansible? -which ansible -echo "------------------------------------------------------------------------------------------------------------------------------------" - -if [ -n "${COLLECTIONS}" ] ; then - ansible-galaxy collection install ${COLLECTIONS} -fi - -echo 'Done!' \ No newline at end of file diff --git a/src/krew/NOTES.md b/src/krew/NOTES.md deleted file mode 100644 index 1a874cc..0000000 --- a/src/krew/NOTES.md +++ /dev/null @@ -1,5 +0,0 @@ - - -## OS Support - -This Feature should work on recent versions of Debian/Ubuntu-based distributions. diff --git a/src/krew/devcontainer-feature.json b/src/krew/devcontainer-feature.json deleted file mode 100644 index 5593811..0000000 --- a/src/krew/devcontainer-feature.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "krew", - "version": "0.0.1", - "name": "krew", - "documentationURL": "https://github.com/framctr/devcontainer-features/tree/main/src/krew", - "description": "Install krew.", - "options": { - "version": { - "type": "string", - "proposals": [ - "latest" - ], - "default": "latest", - "description": "Select or enter a krew version." - } - }, - "containerEnv": { - "PATH": "${KREW_ROOT:-$HOME/.krew}/bin:${PATH}" - }, - "installsAfter": [ - "ghcr.io/devcontainers/features/kubectl-helm-minikube", - "ghcr.io/devcontainers/features/common-utils" - ] -} \ No newline at end of file diff --git a/src/krew/install.sh b/src/krew/install.sh deleted file mode 100644 index e2f43d5..0000000 --- a/src/krew/install.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -set -e - -echo "------------------------------------------------------------------------------------------------------------------------------------" -printenv -echo "------------------------------------------------------------------------------------------------------------------------------------" - -su - "${_REMOTE_USER}" && whoami - -echo whami -whoami - -. ./library_scripts.sh - -# nanolayer is a cli utility which keeps container layers as small as possible -# source code: https://github.com/devcontainers-contrib/nanolayer -# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations, -# and if missing - will download a temporary copy that automatically get deleted at the end -# of the script -ensure_nanolayer nanolayer_location "v0.5.4" - -if [ "${VERSION}" = "latest" ] ; then - VERSION=$(curl -s https://api.github.com/repos/kubernetes-sigs/krew/releases/latest | grep "tag_name" | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ') -fi - -# $nanolayer_location \ -# install \ -# devcontainer-feature \ -# "ghcr.io/devcontainers-contrib/features/gh-release:1.0.23" \ -# --option repo='kubernetes-sigs/krew' --option binaryNames='kubectl-krew' --option version="$VERSION" - -( - whoami - set -x; cd "$(mktemp -d)" && - OS="$(uname | tr '[:upper:]' '[:lower:]')" && - ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" && - KREW="krew-${OS}_${ARCH}" && - curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" && - tar zxvf "${KREW}.tar.gz" && - ./"${KREW}" install krew -) - -if [ -n "$_REMOTE_USER" ] ; then - mv /root/.krew/ $_REMOTE_USER_HOME/ - tree $_REMOTE_USER_HOME/ - chown -R $_REMOTE_USER $_REMOTE_USER_HOME/.krew/ - echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:${PATH}"' >> "$_REMOTE_USER_HOME/.bashrc" -else - echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:${PATH}"' >> "$HOME/.bashrc" -fi - - -find / -name kubectl-krew 2> /dev/null - -echo 'Done!' \ No newline at end of file diff --git a/src/krew/library_scripts.sh b/src/krew/library_scripts.sh deleted file mode 100644 index 67da78a..0000000 --- a/src/krew/library_scripts.sh +++ /dev/null @@ -1,170 +0,0 @@ - - -clean_download() { - # The purpose of this function is to download a file with minimal impact on container layer size - # this means if no valid downloader is found (curl or wget) then we install a downloader (currently wget) in a - # temporary manner, and making sure to - # 1. uninstall the downloader at the return of the function - # 2. revert back any changes to the package installer database/cache (for example apt-get lists) - # The above steps will minimize the leftovers being created while installing the downloader - # Supported distros: - # debian/ubuntu/alpine - - url=$1 - output_location=$2 - tempdir=$(mktemp -d) - downloader_installed="" - - _apt_get_install() { - tempdir=$1 - - # copy current state of apt list - in order to revert back later (minimize contianer layer size) - cp -p -R /var/lib/apt/lists $tempdir - apt-get update -y - apt-get -y install --no-install-recommends wget ca-certificates - } - - _apt_get_cleanup() { - tempdir=$1 - - echo "removing wget" - apt-get -y purge wget --auto-remove - - echo "revert back apt lists" - rm -rf /var/lib/apt/lists/* - rm -r /var/lib/apt/lists && mv $tempdir/lists /var/lib/apt/lists - } - - _apk_install() { - tempdir=$1 - # copy current state of apk cache - in order to revert back later (minimize contianer layer size) - cp -p -R /var/cache/apk $tempdir - - apk add --no-cache wget - } - - _apk_cleanup() { - tempdir=$1 - - echo "removing wget" - apk del wget - } - # try to use either wget or curl if one of them already installer - if type curl >/dev/null 2>&1; then - downloader=curl - elif type wget >/dev/null 2>&1; then - downloader=wget - else - downloader="" - fi - - # in case none of them is installed, install wget temporarly - if [ -z $downloader ] ; then - if [ -x "/usr/bin/apt-get" ] ; then - _apt_get_install $tempdir - elif [ -x "/sbin/apk" ] ; then - _apk_install $tempdir - else - echo "distro not supported" - exit 1 - fi - downloader="wget" - downloader_installed="true" - fi - - if [ $downloader = "wget" ] ; then - wget -q $url -O $output_location - else - curl -sfL $url -o $output_location - fi - - # NOTE: the cleanup procedure was not implemented using `trap X RETURN` only because - # alpine lack bash, and RETURN is not a valid signal under sh shell - if ! [ -z $downloader_installed ] ; then - if [ -x "/usr/bin/apt-get" ] ; then - _apt_get_cleanup $tempdir - elif [ -x "/sbin/apk" ] ; then - _apk_cleanup $tempdir - else - echo "distro not supported" - exit 1 - fi - fi - -} - - -ensure_nanolayer() { - # Ensure existance of the nanolayer cli program - local variable_name=$1 - - local required_version=$2 - - local __nanolayer_location="" - - # If possible - try to use an already installed nanolayer - if [ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]; then - if [ -z "${NANOLAYER_CLI_LOCATION}" ]; then - if type nanolayer >/dev/null 2>&1; then - echo "Found a pre-existing nanolayer in PATH" - __nanolayer_location=nanolayer - fi - elif [ -f "${NANOLAYER_CLI_LOCATION}" ] && [ -x "${NANOLAYER_CLI_LOCATION}" ] ; then - __nanolayer_location=${NANOLAYER_CLI_LOCATION} - echo "Found a pre-existing nanolayer which were given in env variable: $__nanolayer_location" - fi - - # make sure its of the required version - if ! [ -z "${__nanolayer_location}" ]; then - local current_version - current_version=$($__nanolayer_location --version) - - - if ! [ $current_version == $required_version ]; then - echo "skipping usage of pre-existing nanolayer. (required version $required_version does not match existing version $current_version)" - __nanolayer_location="" - fi - fi - - fi - - # If not previuse installation found, download it temporarly and delete at the end of the script - if [ -z "${__nanolayer_location}" ]; then - - if [ "$(uname -sm)" = 'Linux x86_64' ] || [ "$(uname -sm)" = "Linux aarch64" ]; then - tmp_dir=$(mktemp -d -t nanolayer-XXXXXXXXXX) - - clean_up () { - ARG=$? - rm -rf $tmp_dir - exit $ARG - } - trap clean_up EXIT - - - if [ -x "/sbin/apk" ] ; then - clib_type=musl - else - clib_type=gnu - fi - - tar_filename=nanolayer-"$(uname -m)"-unknown-linux-$clib_type.tgz - - # clean download will minimize leftover in case a downloaderlike wget or curl need to be installed - clean_download https://github.com/devcontainers-contrib/cli/releases/download/$required_version/$tar_filename $tmp_dir/$tar_filename - - tar xfzv $tmp_dir/$tar_filename -C "$tmp_dir" - chmod a+x $tmp_dir/nanolayer - __nanolayer_location=$tmp_dir/nanolayer - - - else - echo "No binaries compiled for non-x86-linux architectures yet: $(uname -m)" - exit 1 - fi - fi - - # Expose outside the resolved location - export ${variable_name}=$__nanolayer_location - -} \ No newline at end of file diff --git a/test/ansible-galaxy/check_version.sh b/test/ansible-galaxy/check_version.sh deleted file mode 100644 index e501b55..0000000 --- a/test/ansible-galaxy/check_version.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# This test file will be executed against an auto-generated devcontainer.json - -set -e - -# Optional: Import test library bundled with the devcontainer CLI -# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib -# Provides the 'check' and 'reportResults' commands. -source dev-container-features-test-lib - -check "execute command" bash -c "ansible-galaxy collection list | grep cloud.terraform" -check "execute command" bash -c "ansible-galaxy collection list | grep openstack.cloud" - -# Report result -# If any of the checks above exited with a non-zero exit code, the test will fail. -reportResults \ No newline at end of file diff --git a/test/ansible-galaxy/scenarios.json b/test/ansible-galaxy/scenarios.json deleted file mode 100644 index 076ac7b..0000000 --- a/test/ansible-galaxy/scenarios.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "check_version": { - "image": "mcr.microsoft.com/devcontainers/base:ubuntu", - "features": { - "ghcr.io/devcontainers-contrib/features/ansible": {}, - "ansible-galaxy": { - "collections": "cloud.terraform openstack.cloud" - } - }, - "remoteUser": "vscode" - } -} \ No newline at end of file diff --git a/test/krew/check_version.sh b/test/krew/check_version.sh deleted file mode 100644 index 65fbe34..0000000 --- a/test/krew/check_version.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# This test file will be executed against an auto-generated devcontainer.json - -set -e - -# Optional: Import test library bundled with the devcontainer CLI -# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib -# Provides the 'check' and 'reportResults' commands. -source dev-container-features-test-lib - -echo --------------------------------------------------------------------------------------- -check "execute command" bash -c "printenv" -check "execute command" bash -c "ls -la ${KREW_ROOT:-$HOME/.krew}/bin" -check "execute command" bash -c "ls -la ${KREW_ROOT:-$HOME/.krew}" -check "execute command" bash -c "ls -la ${KREW_ROOT:-$HOME}" -check "execute command" bash -c "whoami" -echo --------------------------------------------------------------------------------------- - -check "execute command" bash -c "kubectl-krew version" - -# Report result -# If any of the checks above exited with a non-zero exit code, the test will fail. -reportResults \ No newline at end of file diff --git a/test/krew/scenarios.json b/test/krew/scenarios.json deleted file mode 100644 index 3222ea9..0000000 --- a/test/krew/scenarios.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "check_version": { - "image": "mcr.microsoft.com/devcontainers/base:ubuntu", - "features": { - "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { - "version": "latest", - "helm": "none", - "minikube": "none" - }, - "krew": { - "version": "latest" - } - }, - "remoteEnv": { - "PATH": "${containerEnv:PATH}:${KREW_ROOT:-$HOME/.krew}/bin" - }, - "remoteUser": "vscode" - } -} \ No newline at end of file diff --git a/test/krew/test.sh b/test/krew/test.sh deleted file mode 100644 index 56d82fd..0000000 --- a/test/krew/test.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# This test file will be executed against an auto-generated devcontainer.json - -set -e - -# Optional: Import test library bundled with the devcontainer CLI -# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib -# Provides the 'check' and 'reportResults' commands. -source dev-container-features-test-lib - -check "execute command" bash -c "/root/.krew/bin/kubectl-krew version" - -# Report result -# If any of the checks above exited with a non-zero exit code, the test will fail. -reportResults \ No newline at end of file