Skip to content

Commit 679d5cc

Browse files
committed
chore: apply review feedback
Signed-off-by: doxsch <28098153+doxsch@users.noreply.github.com>
1 parent 4703c1f commit 679d5cc

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

example/inline-templates/composition.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ spec:
1616
kind: GoTemplate
1717
source: Inline
1818
inline:
19-
templates: []
19+
templates: [] # Kustomize will add the templates here

input/v1beta1/input.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ const (
4949
EnvironmentSource TemplateSource = "Environment"
5050
)
5151

52-
// TemplateSourceInline defines the structure of the inline source.
52+
// TemplateSourceInline defines the structure of the inline source. Allows specifying either a single inline template or multiple templates, but not both.
53+
// +kubebuilder:validation:XValidation:rule="(has(self.template) ? 1 : 0) + (has(self.templates) ? 1 : 0) == 1",message="Exactly one of 'template' or 'templates' must be set"
5354
type TemplateSourceInline struct {
5455
Template string `json:"template,omitempty"`
5556
Templates []string `json:"templates,omitempty"`

package/input/gotemplating.fn.crossplane.io_gotemplates.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ spec:
6363
type: string
6464
type: array
6565
type: object
66+
x-kubernetes-validations:
67+
- message: Exactly one of 'template' or 'templates' must be set
68+
rule: '(has(self.template) ? 1 : 0) + (has(self.templates) ? 1 : 0)
69+
== 1'
6670
kind:
6771
description: |-
6872
Kind is a string value representing the REST resource this object represents.

template.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"path/filepath"
66
"strings"
77

8-
"google.golang.org/protobuf/types/known/structpb"
9-
108
"github.com/crossplane-contrib/function-go-templating/input/v1beta1"
119
"google.golang.org/protobuf/types/known/structpb"
1210

0 commit comments

Comments
 (0)