Merge pull request #536 from aluzzardi/kubernetes-fixes

stdlib: kubernetes: misc fixes
This commit is contained in:
Andrea Luzzardi 2021-06-01 19:50:11 -07:00 committed by GitHub
commit 6aded2d3d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 15 deletions

View File

@ -37,9 +37,9 @@ cluster: eks.#KubeConfig & {
// Example of a simple `kubectl apply` using a simple config // Example of a simple `kubectl apply` using a simple config
kubeApply: kubernetes.#Apply & { kubeApply: kubernetes.#Apply & {
sourceInline: yaml.Marshal(kubeSrc) manifest: yaml.Marshal(kubeSrc)
namespace: "test" namespace: "test"
kubeconfig: cluster.kubeconfig kubeconfig: cluster.kubeconfig
} }
// Example of a `helm install` using a local chart // Example of a `helm install` using a local chart

View File

@ -47,22 +47,23 @@ import (
#Apply: { #Apply: {
// Kubernetes config to deploy // Kubernetes config to deploy
source: dagger.#Artifact @dagger(input) source?: dagger.#Artifact @dagger(input)
// Kubernetes config to deploy inlined in a string // Kubernetes manifest to deploy inlined in a string
sourceInline?: string @dagger(input) manifest?: string @dagger(input)
// Kubernetes Namespace to deploy to // Kubernetes Namespace to deploy to
namespace: string @dagger(input) namespace: *"default" | string @dagger(input)
// Version of kubectl client // Version of kubectl client
version: *"v1.19.9" | string @dagger(input) version: *"v1.19.9" | string @dagger(input)
// Kube config file // Kube config file
kubeconfig: dagger.#Secret @dagger(input) // FIXME: should be `dagger.#Secret`
kubeconfig: string @dagger(input)
#code: #""" #code: #"""
kubectl create namespace "$KUBE_NAMESPACE" || true kubectl create namespace "$KUBE_NAMESPACE" > /dev/null 2>&1 || true
kubectl --namespace "$KUBE_NAMESPACE" apply -R -f /source kubectl --namespace "$KUBE_NAMESPACE" apply -R -f /source
"""# """#
@ -79,10 +80,10 @@ import (
content: kubeconfig content: kubeconfig
mode: 0o600 mode: 0o600
}, },
if sourceInline != _|_ { if manifest != _|_ {
op.#WriteFile & { op.#WriteFile & {
dest: "/source" dest: "/source"
content: sourceInline content: manifest
} }
}, },
op.#Exec & { op.#Exec & {
@ -99,7 +100,7 @@ import (
KUBECONFIG: "/kubeconfig" KUBECONFIG: "/kubeconfig"
KUBE_NAMESPACE: namespace KUBE_NAMESPACE: namespace
} }
if sourceInline == _|_ { if manifest == _|_ {
mount: "/source": from: source mount: "/source": from: source
} }
}, },

View File

@ -34,9 +34,9 @@ TestKubeApply: {
// Apply deployment // Apply deployment
apply: kubernetes.#Apply & { apply: kubernetes.#Apply & {
kubeconfig: config.contents kubeconfig: config.contents
namespace: "dagger-test" namespace: "dagger-test"
sourceInline: yaml.Marshal(kubeSrc) manifest: yaml.Marshal(kubeSrc)
} }
// Verify deployment // Verify deployment