#!/bin/bash -e set -o pipefail function kapply() { for f in "$@"; do kubectl apply --server-side \ -f<(envsubst "$(env | sed 's/^/$/')" < "manifests/$f") done }; export -f kapply function kcreatesec() { kubectl apply --server-side \ -f<(kubectl create secret generic --dry-run=client -oyaml "$@") }; export -f kcreatesec function kcreatecm() { kubectl apply --server-side \ -f<(kubectl create configmap --dry-run=client -oyaml "$@") }; export -f kcreatecm function kgseckey() { local sec="$1"; shift local key="$1"; shift kubectl get secret "$sec" -ojson | jq -re ".data.\"$key\"" | base64 -d }; export -f kgseckey function kgcmkey() { local cm="$1"; shift local key="$1"; shift kubectl get configmap "$cm" -ojson | jq -re ".data.\"$key\"" }; export -f kgcmkey kcreatecm element --from-file=config/config.json kapply common/app.yaml kubectl rollout restart deployment app