-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
325 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: ['*'] | ||
tags: ['!v*'] | ||
workflow_call: {} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: orbit-online/upkg-install@v1 | ||
- name: Run ShellCheck | ||
uses: ludeeus/action-shellcheck@master | ||
env: | ||
SHELLCHECK_OPTS: -x | ||
with: | ||
ignore_paths: .upkg | ||
- name: Show --help menus | ||
run: for cmd in bin/*; do ! grep -q docopt "$cmd" || "$cmd" --help; done | ||
env: | ||
PKIDBURL: "https://example.org" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/.upkg/ | ||
/.upkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck source-path=.. | ||
|
||
pkidb_k8s_secrets() { | ||
set -eo pipefail; shopt -s inherit_errexit | ||
local pkgroot; pkgroot=$(realpath "$(dirname "$(realpath "${BASH_SOURCE[0]}")")/..") | ||
PATH=$("$pkgroot/.upkg/.bin/path_prepend" "$pkgroot/.upkg/.bin") | ||
source "$pkgroot/common.sh" | ||
DOC="pkidb-k8s-secrets - Retrieve CAs via fingerprint and create k8s secrets from them | ||
Usage: | ||
pkidb-k8s-secrets [--namespace=NS] FINGERPRINT... | ||
Notes: | ||
* Make sure to specify \$PKIDBURL | ||
* The namespace can also be specified via \$POD_NAMESPACE | ||
" | ||
# docopt parser below, refresh this parser with `docopt.sh pkidb-k8s-secrets` | ||
# shellcheck disable=2016,2086,2317,1090,1091,2034,2154 | ||
docopt() { source "$pkgroot/.upkg/docopt-lib.sh/docopt-lib.sh" '2.0.0' || { | ||
ret=$?;printf -- "exit %d\n" "$ret";exit "$ret";};set -e | ||
trimmed_doc=${DOC:0:238};usage=${DOC:82:58};digest=8eced;options=(' --namespac'\ | ||
'e 1');node_0(){ value __namespace 0;};node_1(){ value FINGERPRINT a true;} | ||
node_2(){ optional 0;};node_3(){ repeatable 1;};node_4(){ sequence 2 3;};cat \ | ||
<<<' docopt_exit() { [[ -n $1 ]] && printf "%s\n" "$1" >&2;printf "%s\n" \ | ||
"${DOC:82:58}" >&2;exit 1;}';local varnames=(__namespace FINGERPRINT) varname | ||
for varname in "${varnames[@]}"; do unset "var_$varname";done;parse 4 "$@" | ||
local p=${DOCOPT_PREFIX:-''};for varname in "${varnames[@]}"; do unset \ | ||
"$p$varname";done;if declare -p var_FINGERPRINT >/dev/null 2>&1; then eval \ | ||
$p'FINGERPRINT=("${var_FINGERPRINT[@]}")';else eval $p'FINGERPRINT=()';fi;eval \ | ||
$p'__namespace=${var___namespace:-};';local docopt_i=1;[[ $BASH_VERSION =~ \ | ||
^4.3 ]] && docopt_i=2;for ((;docopt_i>0;docopt_i--)); do for varname in \ | ||
"${varnames[@]}"; do declare -p "$p$varname";done;done;} | ||
# docopt parser above, complete command for generating this parser is `docopt.sh --library='"$pkgroot/.upkg/docopt-lib.sh/docopt-lib.sh"' pkidb-k8s-secrets` | ||
eval "$(docopt "$@")" | ||
|
||
# shellcheck disable=2154 | ||
local fingerprint namespace=$__namespace cert secret_name | ||
[[ -n $namespace ]] || namespace=${POD_NAMESPACE:?"Either --namespace or \$POD_NAMESPACE must be specified"} | ||
# shellcheck disable=2153 | ||
for fingerprint in "${FINGERPRINT[@]}"; do | ||
secret_name=${fingerprint,,} | ||
cert=$("$pkgroot/bin/pkidb-ca" "$fingerprint") | ||
printf ' | ||
apiVersion: v1 | ||
kind: Secret | ||
type: Opaque | ||
metadata: | ||
name: %s | ||
namespace: %s | ||
data: | ||
ca.crt: %s | ||
' "$secret_name" "$namespace" "$(base64 -w0 <<<"$cert")" | kubectl apply -f - | LOGPROGRAM=kubectl tee_info | ||
done | ||
} | ||
|
||
pkidb_k8s_secrets "$@" |
Oops, something went wrong.