Skip to content

Commit

Permalink
Merge pull request #293 from stefanprodan/objref
Browse files Browse the repository at this point in the history
Add `#ObjectReference` to Timoni's CUE schemas
  • Loading branch information
stefanprodan authored Dec 21, 2023
2 parents c4c685a + 9a56cc1 commit 6e82434
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ timoni -n default delete minimal
| `metadata: labels:` | `{[ string]: string}` | `{}` | Common labels for all resources |
| `metadata: annotations:` | `{[ string]: string}` | `{}` | Common annotations for all resources |
| `podAnnotations:` | `{[ string]: string}` | `{}` | Annotations applied to pods |
| `imagePullSecrets:` | `[...corev1.LocalObjectReference]` | `[]` | [Kubernetes image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) |
| `imagePullSecrets:` | `[...timoniv1.ObjectReference]` | `[]` | [Kubernetes image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) |
| `tolerations:` | `[ ...corev1.#Toleration]` | `[]` | [Kubernetes toleration](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration) |
| `affinity:` | `corev1.#Affinity` | `{}` | [Kubernetes affinity and anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) |
| `resources:` | `timoniv1.#ResourceRequirements` | `{}` | [Kubernetes resource requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) |
Expand Down
21 changes: 21 additions & 0 deletions examples/minimal/cue.mod/pkg/timoni.sh/core/v1alpha1/object.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2023 Stefan Prodan
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import "strings"

// ObjectReference is a reference to a Kubernetes object.
#ObjectReference: {
// Name of the referent.
name!: string & strings.MaxRunes(256)

// Namespace of the referent.
namespace?: string & strings.MaxRunes(256)

// API version of the referent.
apiVersion?: string & strings.MaxRunes(256)

// Kind of the referent.
kind?: string & strings.MaxRunes(256)
}
2 changes: 1 addition & 1 deletion examples/minimal/templates/config.cue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import (
// Pod optional settings.
podAnnotations?: {[string]: string}
podSecurityContext?: corev1.#PodSecurityContext
imagePullSecrets?: [...corev1.LocalObjectReference]
imagePullSecrets?: [...timoniv1.ObjectReference]
tolerations?: [...corev1.#Toleration]
affinity?: corev1.#Affinity
topologySpreadConstraints?: [...corev1.#TopologySpreadConstraint]
Expand Down
2 changes: 2 additions & 0 deletions schemas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The Timoni's CUE schemas are included in the modules generated with `timoni mod
with automatic generation of `app.kubernetes.io/component` label.
- `#Selector` - Schema for generating Kubernetes label selectors
with automatic generation of `app.kubernetes.io/name` label.
- `#ObjectReference` - Schema for generating Kubernetes object references
based on `apiVersion`, `kind`, `name` and `namespace`.

### Container Image

Expand Down
21 changes: 21 additions & 0 deletions schemas/timoni.sh/core/v1alpha1/object.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2023 Stefan Prodan
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import "strings"

// ObjectReference is a reference to a Kubernetes object.
#ObjectReference: {
// Name of the referent.
name!: string & strings.MaxRunes(256)

// Namespace of the referent.
namespace?: string & strings.MaxRunes(256)

// API version of the referent.
apiVersion?: string & strings.MaxRunes(256)

// Kind of the referent.
kind?: string & strings.MaxRunes(256)
}

0 comments on commit 6e82434

Please sign in to comment.