Skip to content

Commit

Permalink
Merge pull request #227 from stefanprodan/actions-schema
Browse files Browse the repository at this point in the history
Refactor action cue schema
  • Loading branch information
stefanprodan authored Oct 22, 2023
2 parents 0f5848e + 356ed96 commit 5a2a33b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 43 deletions.
11 changes: 0 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions examples/minimal/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion examples/minimal/templates/job.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions examples/redis/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion examples/redis/templates/test.job.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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 & {
Expand Down
2 changes: 2 additions & 0 deletions schemas/timoni.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*
!*.cue
22 changes: 12 additions & 10 deletions schemas/timoni.sh/core/v1alpha1/action.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 5a2a33b

Please sign in to comment.