This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/pkg/alpha.dagger.io/kubernetes/kustomize/kustomization.cue

100 lines
1.7 KiB
CUE
Raw Normal View History

// Kustomize config management
package kustomize
import (
"alpha.dagger.io/dagger/op"
"alpha.dagger.io/dagger"
"alpha.dagger.io/alpine"
)
#Kustomization: {
// Kustomize binary version
version: *"v3.8.7" | string @dagger(input)
#code: #"""
[ -e /usr/local/bin/kubectl ] || {
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash && mv kustomize /usr/local/bin
}
"""#
#up: [
op.#Load & {
from: alpine.#Image & {
package: bash: true
package: jq: true
package: curl: true
}
},
op.#WriteFile & {
dest: "/entrypoint.sh"
content: #code
},
op.#Exec & {
args: [
"/bin/bash",
"--noprofile",
"--norc",
"-eo",
"pipefail",
"/entrypoint.sh",
]
},
]
}
// Apply a Kubernetes Kustomize folder
#Kustomize: {
// Kubernetes source
source: dagger.#Artifact @dagger(input)
// Optional Kustomization file
kustomization: string @dagger(input)
// Kustomize binary version
version: *"v3.8.7" | string @dagger(input)
#code: #"""
cp /kustomization.yaml /source | true
mkdir -p /output
kustomize build /source >> /output/result.yaml
"""#
#up: [
op.#Load & {
from: #Kustomization & {"version": version}
},
op.#WriteFile & {
dest: "/entrypoint.sh"
content: #code
},
if kustomization != _|_ {
op.#WriteFile & {
dest: "/kustomization.yaml"
content: kustomization
mode: 0o600
}
},
op.#Exec & {
always: true
args: [
"/bin/bash",
"--noprofile",
"--norc",
"-eo",
"pipefail",
"/entrypoint.sh",
]
mount: "/source": from: source
},
op.#Subdir & {
dir: "/output"
},
]
}