stdlib: kubernetes: misc fixes
- `source` is now optional - `sourceInline` renamed to `manifest` - `kubeconfig` is a `string` rather than a `dagger.#Secret` Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
413dec63a0
commit
2e748c9c31
@ -37,9 +37,9 @@ cluster: eks.#KubeConfig & {
|
||||
|
||||
// Example of a simple `kubectl apply` using a simple config
|
||||
kubeApply: kubernetes.#Apply & {
|
||||
sourceInline: yaml.Marshal(kubeSrc)
|
||||
namespace: "test"
|
||||
kubeconfig: cluster.kubeconfig
|
||||
manifest: yaml.Marshal(kubeSrc)
|
||||
namespace: "test"
|
||||
kubeconfig: cluster.kubeconfig
|
||||
}
|
||||
|
||||
// Example of a `helm install` using a local chart
|
||||
|
@ -47,22 +47,23 @@ import (
|
||||
#Apply: {
|
||||
|
||||
// Kubernetes config to deploy
|
||||
source: dagger.#Artifact @dagger(input)
|
||||
source?: dagger.#Artifact @dagger(input)
|
||||
|
||||
// Kubernetes config to deploy inlined in a string
|
||||
sourceInline?: string @dagger(input)
|
||||
// Kubernetes manifest to deploy inlined in a string
|
||||
manifest?: string @dagger(input)
|
||||
|
||||
// Kubernetes Namespace to deploy to
|
||||
namespace: string @dagger(input)
|
||||
namespace: *"default" | string @dagger(input)
|
||||
|
||||
// Version of kubectl client
|
||||
version: *"v1.19.9" | string @dagger(input)
|
||||
|
||||
// Kube config file
|
||||
kubeconfig: dagger.#Secret @dagger(input)
|
||||
// FIXME: should be `dagger.#Secret`
|
||||
kubeconfig: string @dagger(input)
|
||||
|
||||
#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
|
||||
"""#
|
||||
|
||||
@ -79,10 +80,10 @@ import (
|
||||
content: kubeconfig
|
||||
mode: 0o600
|
||||
},
|
||||
if sourceInline != _|_ {
|
||||
if manifest != _|_ {
|
||||
op.#WriteFile & {
|
||||
dest: "/source"
|
||||
content: sourceInline
|
||||
content: manifest
|
||||
}
|
||||
},
|
||||
op.#Exec & {
|
||||
@ -99,7 +100,7 @@ import (
|
||||
KUBECONFIG: "/kubeconfig"
|
||||
KUBE_NAMESPACE: namespace
|
||||
}
|
||||
if sourceInline == _|_ {
|
||||
if manifest == _|_ {
|
||||
mount: "/source": from: source
|
||||
}
|
||||
},
|
||||
|
@ -34,9 +34,9 @@ TestKubeApply: {
|
||||
|
||||
// Apply deployment
|
||||
apply: kubernetes.#Apply & {
|
||||
kubeconfig: config.contents
|
||||
namespace: "dagger-test"
|
||||
sourceInline: yaml.Marshal(kubeSrc)
|
||||
kubeconfig: config.contents
|
||||
namespace: "dagger-test"
|
||||
manifest: yaml.Marshal(kubeSrc)
|
||||
}
|
||||
|
||||
// Verify deployment
|
||||
|
Reference in New Issue
Block a user