Skip to content

Commit

Permalink
Standardize-new-features (#506)
Browse files Browse the repository at this point in the history
* chore: standardize direnv feature

* chore: standardize kubectx-kubens feature
  • Loading branch information
danielbraun89 authored Aug 20, 2023
1 parent 9c1e139 commit 0c1d2bd
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 58 deletions.
7 changes: 4 additions & 3 deletions src/direnv/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -17,3 +16,5 @@ directory.
| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | Select the version to install. | string | latest |


34 changes: 19 additions & 15 deletions src/direnv/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
12 changes: 8 additions & 4 deletions src/direnv/install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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!'

4 changes: 2 additions & 2 deletions src/direnv/library_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions src/kubectx-kubens/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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`._
18 changes: 9 additions & 9 deletions src/kubectx-kubens/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
25 changes: 12 additions & 13 deletions src/kubectx-kubens/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env bash

KUBECTX_KUBENS_VERSION="${VERSION:-"latest"}"
#!/bin/bash -i

set -e

Expand All @@ -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!"
2 changes: 1 addition & 1 deletion src/kubectx-kubens/library_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/direnv/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"test": {
"test_defaults_debian": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"direnv": {}
Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions test/kubectx-kubens/test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0c1d2bd

Please sign in to comment.