mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-08-23 22:16:48 +00:00
Added kubectx installer
See https://github.com/ahmetb/kubectx Implementation for #173 Collaborative work of Nico Kerschbaumer and me
This commit is contained in:
committed by
AJ ONeal
parent
76cb2a6346
commit
36b751dc3c
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: Kubectx
|
||||
homepage: https://github.com/ahmetb/kubectx
|
||||
tagline: |
|
||||
kubectx: kubectx is a utility to manage and switch between kubectl contexts.
|
||||
---
|
||||
|
||||
### Updating `kubectx`
|
||||
|
||||
`webi kubectx@stable`
|
||||
|
||||
Use the `@beta` tag for pre-releases.
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
> `kubectx` kubectx helps you switch between Kubernetes clusters back and forth
|
||||
|
||||
To run kubectx:
|
||||
|
||||
```bash
|
||||
kubectx
|
||||
```
|
||||
|
||||
### Command line arguments
|
||||
|
||||
```bash
|
||||
USAGE:
|
||||
kubectx : list the contexts
|
||||
kubectx <NAME> : switch to context <NAME>
|
||||
kubectx - : switch to the previous context
|
||||
kubectx -c, --current : show the current context name
|
||||
kubectx <NEW_NAME>=<NAME> : rename context <NAME> to <NEW_NAME>
|
||||
kubectx <NEW_NAME>=. : rename current-context to <NEW_NAME>
|
||||
kubectx -d <NAME> : delete context <NAME> ('.' for current-context)
|
||||
(this command won't delete the user/cluster entry
|
||||
that is used by the context)
|
||||
kubectx -u, --unset : unset the current context
|
||||
```
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
###################
|
||||
# Install kubectx #
|
||||
###################
|
||||
|
||||
# Every package should define these variables
|
||||
$pkg_cmd_name = "kubectx"
|
||||
|
||||
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\kubectx.exe"
|
||||
$pkg_dst = "$pkg_dst_cmd"
|
||||
|
||||
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\kubectx-v$Env:WEBI_VERSION\bin\kubectx.exe"
|
||||
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\kubectx-v$Env:WEBI_VERSION\bin"
|
||||
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\kubectx-v$Env:WEBI_VERSION"
|
||||
$pkg_src = "$pkg_src_cmd"
|
||||
|
||||
$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
|
||||
|
||||
# Fetch archive
|
||||
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
|
||||
{
|
||||
# TODO: arch detection
|
||||
echo "Downloading kubectx from $Env:WEBI_PKG_URL to $pkg_download"
|
||||
& curl.exe -A -L "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
|
||||
& move "$pkg_download.part" "$pkg_download"
|
||||
}
|
||||
|
||||
IF (!(Test-Path -Path "$pkg_src_cmd"))
|
||||
{
|
||||
echo "Installing kubectx"
|
||||
|
||||
# TODO: create package-specific temp directory
|
||||
# Enter tmp
|
||||
pushd .local\tmp
|
||||
|
||||
# Remove any leftover tmp cruft
|
||||
Remove-Item -Path ".\kubectx-v*" -Recurse -ErrorAction Ignore
|
||||
Remove-Item -Path ".\kubectx.exe" -Recurse -ErrorAction Ignore
|
||||
|
||||
# Unpack archive file into this temporary directory
|
||||
# Windows BSD-tar handles zip. Imagine that.
|
||||
echo "Unpacking $pkg_download"
|
||||
& tar xf "$pkg_download"
|
||||
|
||||
# Settle unpacked archive into place
|
||||
echo "Install Location: $pkg_src_cmd"
|
||||
New-Item "$pkg_src_bin" -ItemType Directory -Force
|
||||
Move-Item -Path "kubectx.exe" -Destination "$pkg_src_bin"
|
||||
|
||||
# Exit tmp
|
||||
popd
|
||||
}
|
||||
|
||||
echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
|
||||
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore
|
||||
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
|
||||
Remove-Item -Path "$pkg_src" -Recurse -ErrorAction Ignore
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
{
|
||||
set -e
|
||||
set -u
|
||||
|
||||
###################
|
||||
# Install kubectx #
|
||||
###################
|
||||
|
||||
# Every package should define these 6 variables
|
||||
pkg_cmd_name="kubectx"
|
||||
|
||||
pkg_dst_cmd="$HOME/.local/bin/kubectx"
|
||||
pkg_dst="$pkg_dst_cmd"
|
||||
|
||||
pkg_src_cmd="$HOME/.local/opt/kubectx-v$WEBI_VERSION/bin/kubectx"
|
||||
pkg_src_dir="$HOME/.local/opt/kubectx-v$WEBI_VERSION"
|
||||
pkg_src="$pkg_src_cmd"
|
||||
|
||||
# pkg_install must be defined by every package
|
||||
pkg_install() {
|
||||
# e.g. ~/.local/opt/kubectx-v0.99.9/bin
|
||||
mkdir -p "$(dirname $pkg_src_cmd)"
|
||||
|
||||
# mv ./kubectx-*/kubectx ~/.local/opt/kubectx-v0.99.9/bin/kubectx
|
||||
mv kubectx "$pkg_src_cmd"
|
||||
}
|
||||
|
||||
# pkg_get_current_version is recommended, but (soon) not required
|
||||
pkg_get_current_version() {
|
||||
# 'kubectx' has no version parameter
|
||||
echo
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var github = require('../_common/github.js');
|
||||
var owner = 'ahmetb';
|
||||
var repo = 'kubectx';
|
||||
|
||||
/******************************************************************************/
|
||||
/** Note: Delete this Comment! **/
|
||||
/** **/
|
||||
/** Need a an example that filters out miscellaneous release files? **/
|
||||
/** See `deno`, `gitea`, or `caddy` **/
|
||||
/** **/
|
||||
/******************************************************************************/
|
||||
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports(require('@root/request')).then(function (all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user