diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 8260cfd01..ffb107f87 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -61,6 +61,9 @@ jobs: run: | docker build -t ${PODINFO_IMAGE_URL}:${PODINFO_VERSION} --build-arg "REVISION=${GITHUB_SHA}" -f Dockerfile.xx . kind load docker-image ${PODINFO_IMAGE_URL}:${PODINFO_VERSION} + - name: Vet module + run: | + timoni mod vet ./timoni/podinfo --debug - name: Build module run: | timoni mod push ./timoni/podinfo ${PODINFO_MODULE_URL} -v ${PODINFO_VERSION} diff --git a/timoni/podinfo/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue b/timoni/podinfo/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue new file mode 100644 index 000000000..2c579e99d --- /dev/null +++ b/timoni/podinfo/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue @@ -0,0 +1,26 @@ +// Copyright 2023 Stefan Prodan +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +// Action holds the list of annotations for controlling +// Timoni's apply behaviour of Kubernetes resources. +Action: { + // Force annotation for recreating immutable resources such as Kubernetes Jobs. + Force: { + "action.timoni.sh/force": ActionStatus.Enabled + } + // One-off annotation for appling resources only if they don't exist on the cluster. + Oneoff: { + "action.timoni.sh/one-off": ActionStatus.Enabled + } + // Keep annotation for preventing Timoni's garbage collector from deleting resources. + Keep: { + "action.timoni.sh/prune": ActionStatus.Disabled + } +} + +ActionStatus: { + Enabled: "enabled" + Disabled: "disabled" +} diff --git a/timoni/podinfo/test_tool.cue b/timoni/podinfo/debug_tool.cue similarity index 69% rename from timoni/podinfo/test_tool.cue rename to timoni/podinfo/debug_tool.cue index f7a56928f..ba09afe50 100644 --- a/timoni/podinfo/test_tool.cue +++ b/timoni/podinfo/debug_tool.cue @@ -6,21 +6,23 @@ import ( "text/tabwriter" ) +_resources: timoni.apply.app + // The build command generates the Kubernetes manifests and prints the multi-docs YAML to stdout. -// Example 'cue cmd -t test -t name=test -t namespace=test -t mv=6.5.0 -t kv=1.28.0 build'. +// Example 'cue cmd -t debug -t name=podinfo -t namespace=test -t mv=1.0.0 -t kv=1.28.0 build'. command: build: { task: print: cli.Print & { - text: yaml.MarshalStream(timoni.apply.all) + text: yaml.MarshalStream(_resources) } } // The ls command prints a table with the Kubernetes resources kind, namespace, name and version. -// Example 'cue cmd -t test -t name=test -t namespace=test -t mv=6.5.0 -t kv=1.28.0 ls'. +// Example 'cue cmd -t debug -t name=podinfo -t namespace=test -t mv=1.0.0 -t kv=1.28.0 ls'. command: ls: { task: print: cli.Print & { text: tabwriter.Write([ "RESOURCE \tAPI VERSION", - for r in timoni.apply.all { + for r in _resources { if r.metadata.namespace == _|_ { "\(r.kind)/\(r.metadata.name) \t\(r.apiVersion)" } diff --git a/timoni/podinfo/test_values.cue b/timoni/podinfo/debug_values.cue similarity index 78% rename from timoni/podinfo/test_values.cue rename to timoni/podinfo/debug_values.cue index 5a8f239b5..1c7db762b 100644 --- a/timoni/podinfo/test_values.cue +++ b/timoni/podinfo/debug_values.cue @@ -1,8 +1,16 @@ -@if(test) +@if(debug) package main +// Values used by debug_tool.cue. +// Debug example 'cue cmd -t debug -t name=podinfo -t namespace=test -t mv=1.0.0 -t kv=1.28.0 build'. values: { + image: { + repository: "docker.io/stefanprodan/podinfo" + tag: "latest" + digest: "" + } + ui: backend: "http://backend.default.svc.cluster.local/echo" metadata: { @@ -23,7 +31,7 @@ values: { annotations: "cert-manager.io/cluster-issuer": "letsencrypt" } - monitoring: enabled: false + monitoring: enabled: true _mcpu: 100 _mem: 128 diff --git a/timoni/podinfo/timoni.cue b/timoni/podinfo/timoni.cue index 638ffac9b..cfe32e003 100644 --- a/timoni/podinfo/timoni.cue +++ b/timoni/podinfo/timoni.cue @@ -45,5 +45,5 @@ timoni: { // Pass Kubernetes resources outputted by the instance // to Timoni's multi-step apply. - apply: all: [ for obj in instance.objects {obj}] + apply: app: [ for obj in instance.objects {obj}] } diff --git a/timoni/podinfo/values.cue b/timoni/podinfo/values.cue index 2a245babd..bbc04df7f 100644 --- a/timoni/podinfo/values.cue +++ b/timoni/podinfo/values.cue @@ -1,6 +1,8 @@ -// Code generated by timoni. DO NOT EDIT. +// Code generated by timoni. // Note that this file must have no imports and all values must be concrete. +@if(!debug) + package main // Defaults