From 0c1d2bd5bc93bcd4e8521e0fc8045db1cc1dc1d8 Mon Sep 17 00:00:00 2001 From: Daniel Braun Date: Sun, 20 Aug 2023 13:34:13 +0300 Subject: [PATCH] Standardize-new-features (#506) * chore: standardize direnv feature * chore: standardize kubectx-kubens feature --- src/direnv/README.md | 7 ++-- src/direnv/devcontainer-feature.json | 34 +++++++++++-------- src/direnv/install.sh | 12 ++++--- src/direnv/library_scripts.sh | 4 +-- src/kubectx-kubens/README.md | 6 +--- src/kubectx-kubens/devcontainer-feature.json | 18 +++++----- src/kubectx-kubens/install.sh | 25 +++++++------- src/kubectx-kubens/library_scripts.sh | 2 +- test/direnv/scenarios.json | 2 +- .../{test.sh => test_defaults_debian.sh} | 0 test/kubectx-kubens/test.sh | 9 +++-- 11 files changed, 61 insertions(+), 58 deletions(-) mode change 100644 => 100755 src/direnv/install.sh rename test/direnv/{test.sh => test_defaults_debian.sh} (100%) mode change 100644 => 100755 diff --git a/src/direnv/README.md b/src/direnv/README.md index 324ccf9d9..8654d47eb 100644 --- a/src/direnv/README.md +++ b/src/direnv/README.md @@ -1,8 +1,7 @@ + # Direnv (via Github Releases) (direnv) -direnv is an extension for your shell. It augments existing shells with a new -feature that can load and unload environment variables depending on the current -directory. +direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory. ## Example DevContainer Usage @@ -17,3 +16,5 @@ directory. | Options Id | Description | Type | Default Value | |-----|-----|-----|-----| | version | Select the version to install. | string | latest | + + diff --git a/src/direnv/devcontainer-feature.json b/src/direnv/devcontainer-feature.json index f32db7773..a72365bea 100644 --- a/src/direnv/devcontainer-feature.json +++ b/src/direnv/devcontainer-feature.json @@ -1,16 +1,20 @@ { - "id": "direnv", - "version": "1.0.6", - "name": "Direnv (via Github Releases)", - "documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/direnv", - "description": "direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.", - "options": { - "version": { - "default": "latest", - "description": "Select the version to install.", - "proposals": ["latest"], - "type": "string" - } - }, - "installsAfter": ["ghcr.io/devcontainers-contrib/features/gh-release"] -} + "id": "direnv", + "version": "1.0.0", + "name": "Direnv (via Github Releases)", + "documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/direnv", + "description": "direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.", + "options": { + "version": { + "default": "latest", + "description": "Select the version to install.", + "proposals": [ + "latest" + ], + "type": "string" + } + }, + "installsAfter": [ + "ghcr.io/devcontainers-contrib/features/gh-release" + ] +} \ No newline at end of file diff --git a/src/direnv/install.sh b/src/direnv/install.sh old mode 100644 new mode 100755 index facb346ca..ecb0924cf --- a/src/direnv/install.sh +++ b/src/direnv/install.sh @@ -6,15 +6,19 @@ source ./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 +# `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.4.39" +ensure_nanolayer nanolayer_location "v0.4.46" + $nanolayer_location \ install \ devcontainer-feature \ - "ghcr.io/devcontainers-contrib/features/gh-release:1.0.17" \ + "ghcr.io/devcontainers-contrib/features/gh-release:1.0.18" \ --option repo='direnv/direnv' --option binaryNames='direnv' --option version="$VERSION" + + echo 'Done!' + diff --git a/src/direnv/library_scripts.sh b/src/direnv/library_scripts.sh index 8662e70e1..8f9bd9a0e 100644 --- a/src/direnv/library_scripts.sh +++ b/src/direnv/library_scripts.sh @@ -2,7 +2,7 @@ clean_download() { - # The purpose of this function is to download a file with minimal impact on contaier layer size + # 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 @@ -116,7 +116,7 @@ ensure_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 varialbe: $nanolayer_location" + echo "Found a pre-existing nanolayer which were given in env variable: $nanolayer_location" fi # make sure its of the required version diff --git a/src/kubectx-kubens/README.md b/src/kubectx-kubens/README.md index bf2c98f48..1fde5ccdd 100644 --- a/src/kubectx-kubens/README.md +++ b/src/kubectx-kubens/README.md @@ -3,7 +3,7 @@ kubectx is a tool to switch between contexts (clusters) on kubectl faster. kubens is a tool to switch between Kubernetes namespaces (and configure them for kubectl) easily. -## Example Usage +## Example DevContainer Usage ```json "features": { @@ -18,7 +18,3 @@ kubectx is a tool to switch between contexts (clusters) on kubectl faster. kuben | version | Select the version you would like to install (will apply for for both kubectx and kubens.) | string | latest | - ---- - -_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/devcontainers-contrib/features/blob/main/src/kubectx-kubens/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/kubectx-kubens/devcontainer-feature.json b/src/kubectx-kubens/devcontainer-feature.json index 792bc344e..de1181ae6 100644 --- a/src/kubectx-kubens/devcontainer-feature.json +++ b/src/kubectx-kubens/devcontainer-feature.json @@ -1,21 +1,21 @@ { - "name": "Kubectx and Kubens (via Github Releases)", "id": "kubectx-kubens", "version": "1.0.3", + "name": "Kubectx and Kubens (via Github Releases)", + "documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/kubectx-kubens", "description": "kubectx is a tool to switch between contexts (clusters) on kubectl faster. kubens is a tool to switch between Kubernetes namespaces (and configure them for kubectl) easily.", - "documentationURL": "https://github.com/devcontainers-contrib/features/tree/main/src/kubectx-kubens", - "installsAfter": [ - "ghcr.io/devcontainers/features/kubectl-helm-minikube:latest" - ], "options": { "version": { - "type": "string", + "default": "latest", + "description": "Select the version you would like to install (will apply for for both kubectx and kubens.)", "proposals": [ "latest", "0.9.4" ], - "default": "latest", - "description": "Select the version you would like to install (will apply for for both kubectx and kubens.)" + "type": "string" } - } + }, + "installsAfter": [ + "ghcr.io/devcontainers-contrib/features/gh-release" + ] } \ No newline at end of file diff --git a/src/kubectx-kubens/install.sh b/src/kubectx-kubens/install.sh index 30fc2b01b..a72202f99 100755 --- a/src/kubectx-kubens/install.sh +++ b/src/kubectx-kubens/install.sh @@ -1,6 +1,4 @@ -#!/usr/bin/env bash - -KUBECTX_KUBENS_VERSION="${VERSION:-"latest"}" +#!/bin/bash -i set -e @@ -11,23 +9,24 @@ source ./library_scripts.sh # `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.4.45" +ensure_nanolayer nanolayer_location "v0.4.46" -if [ "$(id -u)" -ne 0 ]; then - echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' - exit 1 -fi $nanolayer_location \ install \ devcontainer-feature \ - "ghcr.io/devcontainers-contrib/features/gh-release:1" \ - --option repo='ahmetb/kubectx' --option binaryNames='kubectx' --option version="$KUBECTX_KUBENS_VERSION" --option assetRegex="kubectx.*" + "ghcr.io/devcontainers-contrib/features/gh-release:1.0.18" \ + --option repo='ahmetb/kubectx' --option binaryNames='kubectx' --option assetRegex='kubectx.*' --option version="$VERSION" + + $nanolayer_location \ install \ devcontainer-feature \ - "ghcr.io/devcontainers-contrib/features/gh-release:1" \ - --option repo='ahmetb/kubectx' --option binaryNames='kubens' --option version="$KUBECTX_KUBENS_VERSION" --option assetRegex="kubens.*" + "ghcr.io/devcontainers-contrib/features/gh-release:1.0.18" \ + --option repo='ahmetb/kubectx' --option binaryNames='kubens' --option assetRegex='kubens.*' --option version="$VERSION" + + + +echo 'Done!' -echo "Done!" diff --git a/src/kubectx-kubens/library_scripts.sh b/src/kubectx-kubens/library_scripts.sh index cff083da2..8f9bd9a0e 100644 --- a/src/kubectx-kubens/library_scripts.sh +++ b/src/kubectx-kubens/library_scripts.sh @@ -2,7 +2,7 @@ clean_download() { - # The purpose of this function is to download a file with minimal impact on contaier layer size + # 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 diff --git a/test/direnv/scenarios.json b/test/direnv/scenarios.json index f2e0d2d16..d73612ead 100644 --- a/test/direnv/scenarios.json +++ b/test/direnv/scenarios.json @@ -1,5 +1,5 @@ { - "test": { + "test_defaults_debian": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { "direnv": {} diff --git a/test/direnv/test.sh b/test/direnv/test_defaults_debian.sh old mode 100644 new mode 100755 similarity index 100% rename from test/direnv/test.sh rename to test/direnv/test_defaults_debian.sh diff --git a/test/kubectx-kubens/test.sh b/test/kubectx-kubens/test.sh index 190ff2681..f051b421a 100755 --- a/test/kubectx-kubens/test.sh +++ b/test/kubectx-kubens/test.sh @@ -1,12 +1,11 @@ -#!/bin/bash +#!/bin/bash -i set -e source dev-container-features-test-lib -# we are simply checking version for now. -# full operability depends on the existance of kubectl. -check "kubectx version" kubectx --version -check "kubens version" kubens --version +check "kubectx --version" kubectx --version + +check "kubens --version" kubens --version reportResults