kubernetes #Resources definition now support secret kubeconfig

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau 2021-09-22 19:03:58 +02:00
parent 7497b116ea
commit 1f5a9a9fa9
No known key found for this signature in database
GPG Key ID: 3C9847D981AAC1BF

View File

@ -65,7 +65,7 @@ import (
version: dagger.#Input & {*"v1.19.9" | string} version: dagger.#Input & {*"v1.19.9" | string}
// Kube config file // Kube config file
kubeconfig: dagger.#Input & {string} kubeconfig: dagger.#Input & {string | dagger.#Secret}
#code: #""" #code: #"""
kubectl create namespace "$KUBE_NAMESPACE" > /dev/null 2>&1 || true kubectl create namespace "$KUBE_NAMESPACE" > /dev/null 2>&1 || true
@ -89,11 +89,15 @@ import (
dest: "/entrypoint.sh" dest: "/entrypoint.sh"
content: #code content: #code
}, },
op.#WriteFile & {
dest: "/kubeconfig" if (kubeconfig & string) != _|_ {
content: kubeconfig op.#WriteFile & {
mode: 0o600 dest: "/kubeconfig"
content: kubeconfig
mode: 0o600
},
}, },
if manifest != null { if manifest != null {
op.#WriteFile & { op.#WriteFile & {
dest: "/source" dest: "/source"
@ -120,6 +124,9 @@ import (
if manifest == null && source != null { if manifest == null && source != null {
mount: "/source": from: source mount: "/source": from: source
} }
if (kubeconfig & dagger.#Secret) != _|_ {
mount: "/kubeconfig": secret: kubeconfig
}
}, },
] ]
} }