Some fields of the CRDs allow to use Go templates which are rendered by the operator. You can find some explanations on how to use them in here.

Cluster Template

The tenant field .spec.clusterTemplate defines a template which is used to set default values for clusters of this tenant.

The template will only be applied to fields of the cluster which aren’t already set (empty or nil). It’s for example not possible to set the displayName of a cluster if it already defines one.

All string fields within this allow to use Go templates which are rendered by the operator. As input data to the template rendering, the instance of the cluster on which the template is being applied on can be used. This data is a Go type defined here.

Since it’s a Go type, only exported fields (uppercase) can be accessed.

Since the metav1.TypeMeta (.metadata in YAML) is an embedded struct, you must access it’s fields directly (and not via .Metadata as in YAML). For example the name is accessed with {{ .Name }}.

To access a map in Go templates (like .Annotations) you have to use the index function. For example an annotation is accessed with {{ index .Annotations "syn.tools/name" }}.

Some examples of how to access different values:

apiVersion: syn.tools/v1alpha1
kind: Tenant
  name: t-aezoo6
  displayName: Big Corp.
      name: vshn-gitlab
    path: syn-dev/customers
    repoName: t-aezoo6
      name: '{{ index .Annotations "syn.tools/name"}}'
      creation: '{{ .CreationTimestamp }}'
        name: secret-{{ .Spec.TenantRef.Name }}
      path: cluster-catalogs/{{ index .Spec.Facts "cloud"}}
      repoName: catalog-{{ .Name }}