Merge pull request #290 from dagger/fix-kube-example
stdlib/kubernetes: split source with dagger.#Artifact and string
This commit is contained in:
commit
ae0ef42556
@ -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 & {
|
||||||
source: yaml.Marshal(kubeSrc)
|
sourceInline: 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
|
||||||
|
@ -14,7 +14,10 @@ import (
|
|||||||
name: string
|
name: string
|
||||||
|
|
||||||
// Helm chart to install
|
// Helm chart to install
|
||||||
chart: string | dagger.#Artifact
|
chart: dagger.#Artifact
|
||||||
|
|
||||||
|
// Helm chart to install inlined
|
||||||
|
chartInline?: string
|
||||||
|
|
||||||
// Helm chart repository (defaults to stable)
|
// Helm chart repository (defaults to stable)
|
||||||
repository: *"https://charts.helm.sh/stable" | string
|
repository: *"https://charts.helm.sh/stable" | string
|
||||||
@ -86,7 +89,7 @@ import (
|
|||||||
content: kubeconfig
|
content: kubeconfig
|
||||||
mode: 0o600
|
mode: 0o600
|
||||||
},
|
},
|
||||||
if (chart & string) != _|_ {
|
if chartInline != _|_ {
|
||||||
op.#WriteFile & {
|
op.#WriteFile & {
|
||||||
dest: "/helm/chart"
|
dest: "/helm/chart"
|
||||||
content: chart
|
content: chart
|
||||||
@ -117,7 +120,7 @@ import (
|
|||||||
if (values & string) != _|_ {
|
if (values & string) != _|_ {
|
||||||
"/helm/values.yaml": values
|
"/helm/values.yaml": values
|
||||||
}
|
}
|
||||||
if (chart & dagger.#Artifact) != _|_ {
|
if chartInline == _|_ {
|
||||||
"/helm/chart": from: chart
|
"/helm/chart": from: chart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,12 @@ import (
|
|||||||
|
|
||||||
// Apply a Kubernetes configuration
|
// Apply a Kubernetes configuration
|
||||||
#Apply: {
|
#Apply: {
|
||||||
|
|
||||||
// Kubernetes config to deploy
|
// Kubernetes config to deploy
|
||||||
source: string | dagger.#Artifact
|
source: dagger.#Artifact
|
||||||
|
|
||||||
|
// Kubernetes config to deploy inlined in a string
|
||||||
|
sourceInline?: string
|
||||||
|
|
||||||
// Kubernetes Namespace to deploy to
|
// Kubernetes Namespace to deploy to
|
||||||
namespace: string
|
namespace: string
|
||||||
@ -59,6 +63,8 @@ import (
|
|||||||
|
|
||||||
#code: #"""
|
#code: #"""
|
||||||
kubectl create namespace "$KUBE_NAMESPACE" || true
|
kubectl create namespace "$KUBE_NAMESPACE" || true
|
||||||
|
ls -la /source
|
||||||
|
cat /source
|
||||||
kubectl --namespace "$KUBE_NAMESPACE" apply -R -f /source
|
kubectl --namespace "$KUBE_NAMESPACE" apply -R -f /source
|
||||||
"""#
|
"""#
|
||||||
|
|
||||||
@ -75,7 +81,7 @@ import (
|
|||||||
content: kubeconfig
|
content: kubeconfig
|
||||||
mode: 0o600
|
mode: 0o600
|
||||||
},
|
},
|
||||||
if (source & string) != _|_ {
|
if sourceInline != _|_ {
|
||||||
op.#WriteFile & {
|
op.#WriteFile & {
|
||||||
dest: "/source"
|
dest: "/source"
|
||||||
content: source
|
content: source
|
||||||
@ -95,7 +101,7 @@ import (
|
|||||||
KUBECONFIG: "/kubeconfig"
|
KUBECONFIG: "/kubeconfig"
|
||||||
KUBE_NAMESPACE: namespace
|
KUBE_NAMESPACE: namespace
|
||||||
}
|
}
|
||||||
if (source & dagger.#Artifact) != _|_ {
|
if sourceInline == _|_ {
|
||||||
mount: "/source": from: source
|
mount: "/source": from: source
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user