#!/usr/bin/env bash
# Define custom bash functions that can be passed around to sub-envs
shopt -s expand_aliases

helm() {
  docker run -t --rm -e HELM_EXPERIMENTAL_OCI="$HELM_EXPERIMENTAL_OCI" -v $(pwd):/apps -w /apps -v ~/.kube:/root/.kube -v ~/.helm:/root/.helm -v ~/.config/helm:/root/.config/helm -v ~/.cache/helm:/root/.cache/helm alpine/helm:3.2.3 "$@"
}
export -f helm

helm_for_gcp() {
  docker run -t --rm -e HELM_EXPERIMENTAL_OCI="$HELM_EXPERIMENTAL_OCI" -v $(pwd):/apps -w /apps -v ~/.kube:/root/.kube -v ~/.helm:/root/.helm -v ~/.config:/root/.config -v ~/.cache:/root/.cache alpine/helm:3.2.3 "$@"
}
export -f helm_for_gcp

kubectl() {
    docker run -a stdout --rm -v $(pwd):/apps -w /apps alpine/k8s:1.18.2 kubectl "$@"
}
export -f kubectl

kubectl_noattach() {
    docker run --rm -v $(pwd):/apps -w /apps alpine/k8s:1.18.2 kubectl "$@"
}
export -f kubectl_noattach

kubectl_stdin() {
    docker run -a stdin --rm -v $(pwd):/apps -w /apps alpine/k8s:1.18.2 kubectl "$@"
}
export -f kubectl_stdin
