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
Andrea Luzzardi 282759c0e5 cue modules: move stdlib to pkg/alpha.dagger.io
In preparation for Europa, we will vendor multiple CUE modules:

- `pkg/alpha.dagger.io`: legacy non-europa packages
- `pkg/dagger.io`: core Europa packages
- `pkg/universe.dagger.io`: Europa universe

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2022-01-11 13:16:37 -08:00

100 lines
1.7 KiB
CUE

// 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"
},
]
}