Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timoni: Add debug values and vet module in CI #314

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
26 changes: 26 additions & 0 deletions timoni/podinfo/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue
Original file line number Diff line number Diff line change
@@ -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"
}
10 changes: 6 additions & 4 deletions timoni/podinfo/test_tool.cue → timoni/podinfo/debug_tool.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
Expand Down
12 changes: 10 additions & 2 deletions timoni/podinfo/test_values.cue → timoni/podinfo/debug_values.cue
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -23,7 +31,7 @@ values: {
annotations: "cert-manager.io/cluster-issuer": "letsencrypt"
}

monitoring: enabled: false
monitoring: enabled: true

_mcpu: 100
_mem: 128
Expand Down
2 changes: 1 addition & 1 deletion timoni/podinfo/timoni.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
}
4 changes: 3 additions & 1 deletion timoni/podinfo/values.cue
Original file line number Diff line number Diff line change
@@ -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
Expand Down