From aa9fb906168e4baaf357164354e77f7e7b18e97b Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Sun, 22 Oct 2023 09:48:41 +0300 Subject: [PATCH 1/2] Refactor action schema Signed-off-by: Stefan Prodan --- .../pkg/timoni.sh/core/v1alpha1/action.cue | 22 ++++++++++--------- examples/minimal/templates/job.cue | 2 +- .../pkg/timoni.sh/core/v1alpha1/action.cue | 22 ++++++++++--------- examples/redis/templates/test.job.cue | 2 +- schemas/timoni.sh/core/v1alpha1/action.cue | 22 ++++++++++--------- 5 files changed, 38 insertions(+), 32 deletions(-) diff --git a/examples/minimal/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue b/examples/minimal/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue index 1dbcb9aa..2c579e99 100644 --- a/examples/minimal/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue +++ b/examples/minimal/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue @@ -3,22 +3,24 @@ package v1alpha1 -// Action holds a list of annotations for controlling +// Action holds the list of annotations for controlling // Timoni's apply behaviour of Kubernetes resources. -action: { +Action: { // Force annotation for recreating immutable resources such as Kubernetes Jobs. - force: { - "action.timoni.sh/force": enabled + 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": enabled + Oneoff: { + "action.timoni.sh/one-off": ActionStatus.Enabled } // Keep annotation for preventing Timoni's garbage collector from deleting resources. - keep: { - "action.timoni.sh/prune": disabled + Keep: { + "action.timoni.sh/prune": ActionStatus.Disabled } } -enabled: "enabled" -disabled: "disabled" +ActionStatus: { + Enabled: "enabled" + Disabled: "disabled" +} diff --git a/examples/minimal/templates/job.cue b/examples/minimal/templates/job.cue index 0602a10e..852c39c9 100644 --- a/examples/minimal/templates/job.cue +++ b/examples/minimal/templates/job.cue @@ -16,7 +16,7 @@ import ( metadata: name: "\(_config.metadata.name)-test" metadata: namespace: _config.metadata.namespace metadata: labels: _config.metadata.labels - metadata: annotations: timoniv1.action.force + metadata: annotations: timoniv1.Action.Force spec: batchv1.#JobSpec & { template: corev1.#PodTemplateSpec & { metadata: labels: _config.metadata.labels diff --git a/examples/redis/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue b/examples/redis/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue index 1dbcb9aa..2c579e99 100644 --- a/examples/redis/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue +++ b/examples/redis/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue @@ -3,22 +3,24 @@ package v1alpha1 -// Action holds a list of annotations for controlling +// Action holds the list of annotations for controlling // Timoni's apply behaviour of Kubernetes resources. -action: { +Action: { // Force annotation for recreating immutable resources such as Kubernetes Jobs. - force: { - "action.timoni.sh/force": enabled + 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": enabled + Oneoff: { + "action.timoni.sh/one-off": ActionStatus.Enabled } // Keep annotation for preventing Timoni's garbage collector from deleting resources. - keep: { - "action.timoni.sh/prune": disabled + Keep: { + "action.timoni.sh/prune": ActionStatus.Disabled } } -enabled: "enabled" -disabled: "disabled" +ActionStatus: { + Enabled: "enabled" + Disabled: "disabled" +} diff --git a/examples/redis/templates/test.job.cue b/examples/redis/templates/test.job.cue index e4656223..df467ba3 100644 --- a/examples/redis/templates/test.job.cue +++ b/examples/redis/templates/test.job.cue @@ -17,7 +17,7 @@ import ( name: "\(_config.metadata.name)-test" namespace: _config.metadata.namespace labels: _config.metadata.labels - annotations: timoniv1.action.force + annotations: timoniv1.Action.Force } spec: batchv1.#JobSpec & { template: corev1.#PodTemplateSpec & { diff --git a/schemas/timoni.sh/core/v1alpha1/action.cue b/schemas/timoni.sh/core/v1alpha1/action.cue index 1dbcb9aa..2c579e99 100644 --- a/schemas/timoni.sh/core/v1alpha1/action.cue +++ b/schemas/timoni.sh/core/v1alpha1/action.cue @@ -3,22 +3,24 @@ package v1alpha1 -// Action holds a list of annotations for controlling +// Action holds the list of annotations for controlling // Timoni's apply behaviour of Kubernetes resources. -action: { +Action: { // Force annotation for recreating immutable resources such as Kubernetes Jobs. - force: { - "action.timoni.sh/force": enabled + 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": enabled + Oneoff: { + "action.timoni.sh/one-off": ActionStatus.Enabled } // Keep annotation for preventing Timoni's garbage collector from deleting resources. - keep: { - "action.timoni.sh/prune": disabled + Keep: { + "action.timoni.sh/prune": ActionStatus.Disabled } } -enabled: "enabled" -disabled: "disabled" +ActionStatus: { + Enabled: "enabled" + Disabled: "disabled" +} From 356ed96573a6a0a1ed9bafa1c3b4b225c1d7135f Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Sun, 22 Oct 2023 09:49:32 +0300 Subject: [PATCH 2/2] Push clean schemas to GHCR Signed-off-by: Stefan Prodan --- Makefile | 11 ----------- schemas/timoni.ignore | 2 ++ 2 files changed, 2 insertions(+), 11 deletions(-) create mode 100644 schemas/timoni.ignore diff --git a/Makefile b/Makefile index 9d38c64d..4f3190fc 100644 --- a/Makefile +++ b/Makefile @@ -47,17 +47,6 @@ push-redis: build -a 'org.opencontainers.image.description=A timoni.sh module for deploying Redis master-replica clusters.' \ -a 'org.opencontainers.image.documentation=https://github.com/stefanprodan/timoni/blob/main/examples/redis/README.md' -SCHEMA_VER ?= "0.13.1" -push-schemas: build - ./bin/timoni artifact push oci://ghcr.io/stefanprodan/timoni/schemas \ - -f ./schemas -t $(SCHEMA_VER) -t latest \ - -a="org.opencontainers.image.source=https://github.com/stefanprodan/timoni" \ - -a="org.opencontainers.image.revision=$(shell git rev-parse HEAD)" \ - -a="org.opencontainers.image.licenses=Apache-2.0" \ - -a="org.opencontainers.image.documentation=https://timoni.sh" \ - -a="org.opencontainers.image.description=timoni.sh CUE schemas" \ - --content-type="cue.mod/pkg" - .PHONY: install install: ## Build and install the CLI binary. go install ./cmd/timoni diff --git a/schemas/timoni.ignore b/schemas/timoni.ignore new file mode 100644 index 00000000..4889eb39 --- /dev/null +++ b/schemas/timoni.ignore @@ -0,0 +1,2 @@ +/* +!*.cue