Skip to content

Commit

Permalink
chore: standardize kubectx-kubens feature
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbraun89 authored Aug 20, 2023
1 parent 454f473 commit d93e78c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 deletions.
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
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 d93e78c

Please sign in to comment.