Merge branch 'master' of github.com:HariSekhon/DevOps-Bash-tools

pull/4/head
Hari Sekhon 1 year ago
commit bdd499a49c

@ -211,7 +211,7 @@ if [ "${K8S_NAMESPACE:-}" ]; then
kubectl_opts+=(-n "$K8S_NAMESPACE")
fi
# TODO: might split this later
oc_opts=("${kubectl_opts[@]}")
oc_opts=("${kubectl_opts[@]:-}")
# ============================================================================ #
@ -236,9 +236,9 @@ k(){
# more efficient than forking to check history every time
if [ -n "$KUBERNETES_CLI" ]; then
case "$KUBERNETES_CLI" in
kubectl) opts+=("${kubectl_opts[@]}")
kubectl) opts+=("${kubectl_opts[@]:-}")
;;
oc) opts+=("${oc_opts[@]}")
oc) opts+=("${oc_opts[@]:-}")
;;
*) echo "invalid command '$KUBERNETES_CLI' listed in \$KUBERNETES_CLI (must be either 'kubectl' or 'oc' depending on whether you are using straight Kubernetes or OpenShift). Fix the variable or unset it to auto-detect when calling the k() function"
return
@ -251,7 +251,7 @@ k(){
openshift) command oc "${oc_opts[@]}" "$@"
export KUBERNETES_CLI=oc
;;
k8s|*) command kubectl "${kubectl_opts[@]}" "$@"
k8s|*) command kubectl "${kubectl_opts[@]:-}" "$@"
export KUBERNETES_CLI=kubectl
;;
esac
@ -390,7 +390,7 @@ watchpods(){
echo
echo 'Pods:'
echo
kubectl " "${kubectl_opts[@]}" " get pods " "${k8s_get_pod_opts[@]}" " 2>&1
kubectl " "${kubectl_opts[@]:-}" " get pods " "${k8s_get_pod_opts[@]:-}" " 2>&1
echo
"
}

@ -40,7 +40,7 @@
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
if [ "$1" = "${BASH_SOURCE[0]##*/}" ]; then
if [ "${1##*/}" = "${BASH_SOURCE[0]##*/}" ]; then
shift
fi

@ -26,6 +26,8 @@ Installs the Helm Charts from one or more Kustomize kustomization.yaml files usi
All arguments are passed straight to yq and must be kustomization.yaml files or valid --options
If SKIP_EXISTING_HELM_INSTALLATIONS is set to any value, then will skip those installations (useful for CI/CD retries without failing on existing installation from previous run)
If SKIP_ERRORS is set to any value, will ignore failures to install each helm chart, such as webhooks failing to contact cert-manager (useful for CI/CD runs where you just want the charts installed to test outdated release versions such as https://github.com/HariSekhon/Kubernetes-configs/actions/workflows/kustomize-nova.yaml)
Uses adjacent script kustomize_parse_helm_charts.sh and is used in CI/CD GitHub Actions for repo:
@ -49,17 +51,33 @@ type -P yq &>/dev/null || "$srcdir/setup/install_yq.sh"
# if there are no repositories to show will return exit code 1 so || :
helm_repos="$(helm repo list -o yaml | yq -r '.[] | [.name, .url] | @tsv' || :)"
if [ -n "${SKIP_EXISTING_HELM_INSTALLATIONS:-}" ]; then
helm_installations="$(helm ls -A -o json | jq -r '.[].name')"
fi
"$srcdir/kustomize_parse_helm_charts.sh" "$@" |
while read -r repo_url name version values_file; do
if [ -n "${SKIP_EXISTING_HELM_INSTALLATIONS:-}" ]; then
if grep -Fxq "$name" <<< "$helm_installations"; then
timestamp "Skipping existing Helm installation: $name"
continue
fi
fi
if [ "$values_file" = null ]; then
values_file=""
fi
if ! grep -Eq "^$name[[:space:]]+$repo_url[[:space:]]*$" <<< "$helm_repos"; then
if ! grep -Eq "^${name}[[:space:]]+${repo_url}[[:space:]]*$" <<< "$helm_repos"; then
timestamp "Adding Helm repo '$repo_url' as name '$name'"
# might fail here if you've already installed a repo with this name, in which case, fix your repos, we don't want to remove/modify your existing repos
helm repo add "$name" "$repo_url"
fi
timestamp "Installing Helm chart '$name' version '$version' from '$repo_url'"
if [ -n "${SKIP_ERRORS:-1}" ]; then
set +e
fi
helm install "$name" "$name/$name" --version "$version" --create-namespace --namespace "$name" ${values_file:+--values "$values_file"}
if [ -n "${SKIP_ERRORS:-1}" ]; then
set -e
fi
echo
done

@ -45,14 +45,20 @@ help_usage "$@"
version="${1:-latest}"
os="$(get_os)"
arch="$(arch)"
ext="tar.gz"
if [ "$os" = darwin ]; then
os=macOS
if [ "$(arch)" = arm64 ]; then
echo "GitHub CLI doesn't support ARM architecture yet, skipping..."
exit 0
fi
ext="zip"
#if [ "$arch" = arm64 ]; then
# #echo "GitHub CLI doesn't support ARM architecture yet, skipping... use brew to install GitHub CLI"
# #exit 0
#
# # amd64 binaries work too
# arch=amd64
#fi
fi
export RUN_VERSION_ARG=1
"$srcdir/../github_install_binary.sh" cli/cli "gh_{version}_${os}_{arch}.tar.gz" "$version" "gh_{version}_${os}_{arch}/bin/gh"
"$srcdir/../github_install_binary.sh" cli/cli "gh_{version}_${os}_${arch}.$ext" "$version" "gh_{version}_${os}_${arch}/bin/gh"

Loading…
Cancel
Save