Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Allow arbitrary values as template source
Browse files Browse the repository at this point in the history
  • Loading branch information
adracus committed Sep 9, 2021
1 parent 5401a41 commit 4a25eef
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/template_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -47,6 +48,9 @@ type TemplateSource struct {
Name string `json:"name"`
// ObjectReference is a reference to an object to serve as source.
Object *ObjectReference `json:"object,omitempty"`
// Value is a literal yaml value to use as source.
// +optional
Value apiextensionsv1.JSON `json:"value,omitempty"`
}

// ObjectReference references an object in a specific api version.
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion charts/template-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: template-operator
description: A Helm chart for the template operator
type: application
version: 0.1.1
version: 0.1.2
appVersion: 0.1.0
engine: gotpl
home: https://github.com/onmetal/template-operator
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/template.onmetal.de_templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ spec:
- kind
- name
type: object
value:
description: Value is a literal yaml value to use as source.
x-kubernetes-preserve-unknown-fields: true
required:
- name
type: object
Expand Down
2 changes: 1 addition & 1 deletion controllers/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (r *TemplateReconciler) resolveSources(ctx context.Context, logger logr.Log

values[src.Name] = u.Object
default:
return nil, fmt.Errorf("invalid source definition %q", src.Name)
values[src.Name] = src.Value
}
}

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/onsi/gomega v1.16.0
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
k8s.io/api v0.22.1
k8s.io/apiextensions-apiserver v0.22.1
k8s.io/apimachinery v0.22.1
k8s.io/client-go v0.22.1
sigs.k8s.io/controller-runtime v0.10.0
Expand Down

0 comments on commit 4a25eef

Please sign in to comment.