Skip to content

Commit

Permalink
fix: Stop using pointers as list elements when not really necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jul 8, 2024
1 parent 49451cd commit cee3c2c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/objecttemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type ObjectTemplateSpec struct {

// Matrix specifies the input matrix
// +required
Matrix []*MatrixEntry `json:"matrix"`
Matrix []MatrixEntry `json:"matrix"`

// Templates specifies a list of templates to render and deploy
// +required
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/texttemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type TextTemplateSpec struct {
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// +optional
Inputs []*TextTemplateInput `json:"inputs,omitempty"`
Inputs []TextTemplateInput `json:"inputs,omitempty"`

// +optional
Template *string `json:"template,omitempty"`
Expand Down
16 changes: 4 additions & 12 deletions api/v1alpha1/zz_generated.deepcopy.go

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

14 changes: 7 additions & 7 deletions controllers/objecttemplate_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func buildTestSecret(name string, namespace string, data map[string]string) *uns
}
}

func buildObjectTemplate(name string, namespace string, matrixEntries []*templatesv1alpha1.MatrixEntry, templates []templatesv1alpha1.Template) *templatesv1alpha1.ObjectTemplate {
func buildObjectTemplate(name string, namespace string, matrixEntries []templatesv1alpha1.MatrixEntry, templates []templatesv1alpha1.Template) *templatesv1alpha1.ObjectTemplate {
t := &templatesv1alpha1.ObjectTemplate{
TypeMeta: metav1.TypeMeta{
APIVersion: templatesv1alpha1.GroupVersion.String(),
Expand All @@ -86,8 +86,8 @@ func buildObjectTemplate(name string, namespace string, matrixEntries []*templat
return t
}

func buildMatrixListEntry(name string) *templatesv1alpha1.MatrixEntry {
return &templatesv1alpha1.MatrixEntry{
func buildMatrixListEntry(name string) templatesv1alpha1.MatrixEntry {
return templatesv1alpha1.MatrixEntry{
Name: name,
List: []runtime.RawExtension{
{
Expand All @@ -97,12 +97,12 @@ func buildMatrixListEntry(name string) *templatesv1alpha1.MatrixEntry {
}
}

func buildMatrixObjectEntry(name string, objName string, objNamespace string, objKind string, jsonPath string, expandLists bool) *templatesv1alpha1.MatrixEntry {
func buildMatrixObjectEntry(name string, objName string, objNamespace string, objKind string, jsonPath string, expandLists bool) templatesv1alpha1.MatrixEntry {
var jsonPathPtr *string
if jsonPath != "" {
jsonPathPtr = &jsonPath
}
return &templatesv1alpha1.MatrixEntry{
return templatesv1alpha1.MatrixEntry{
Name: name,
Object: &templatesv1alpha1.MatrixEntryObject{
Ref: templatesv1alpha1.ObjectRef{
Expand Down Expand Up @@ -207,7 +207,7 @@ var _ = Describe("ObjectTemplate controller", func() {
cmKey := client2.ObjectKey{Name: "cm1", Namespace: ns}

t := buildObjectTemplate(key.Name, key.Namespace,
[]*templatesv1alpha1.MatrixEntry{buildMatrixListEntry("m1")},
[]templatesv1alpha1.MatrixEntry{buildMatrixListEntry("m1")},
[]templatesv1alpha1.Template{
{Object: buildTestConfigMap(cmKey.Name, cmKey.Namespace, map[string]string{
"k1": `{{ matrix.m1.k1 + matrix.m1.k2 }}`,
Expand Down Expand Up @@ -271,7 +271,7 @@ var _ = Describe("ObjectTemplate controller", func() {
createRoleWithBinding("default", ns, []string{"configmaps"})

t := buildObjectTemplate(key.Name, key.Namespace,
[]*templatesv1alpha1.MatrixEntry{
[]templatesv1alpha1.MatrixEntry{
buildMatrixObjectEntry("m1", "m1", ns, "Secret", "", false),
},
[]templatesv1alpha1.Template{
Expand Down
24 changes: 16 additions & 8 deletions docs/api/template-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,10 @@ string
</div>
<h3 id="templates.kluctl.io/v1alpha1.MatrixEntry">MatrixEntry
</h3>
<p>
(<em>Appears on:</em>
<a href="#templates.kluctl.io/v1alpha1.ObjectTemplateSpec">ObjectTemplateSpec</a>)
</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
Expand Down Expand Up @@ -2242,8 +2246,8 @@ bool
<td>
<code>matrix</code><br>
<em>
<a href="#templates.kluctl.io/v1alpha1.*github.com/kluctl/template-controller/api/v1alpha1.MatrixEntry">
[]*github.com/kluctl/template-controller/api/v1alpha1.MatrixEntry
<a href="#templates.kluctl.io/v1alpha1.MatrixEntry">
[]MatrixEntry
</a>
</em>
</td>
Expand Down Expand Up @@ -2353,8 +2357,8 @@ bool
<td>
<code>matrix</code><br>
<em>
<a href="#templates.kluctl.io/v1alpha1.*github.com/kluctl/template-controller/api/v1alpha1.MatrixEntry">
[]*github.com/kluctl/template-controller/api/v1alpha1.MatrixEntry
<a href="#templates.kluctl.io/v1alpha1.MatrixEntry">
[]MatrixEntry
</a>
</em>
</td>
Expand Down Expand Up @@ -2669,8 +2673,8 @@ when reconciling this TextTemplate. If omitted, the &ldquo;default&rdquo; servic
<td>
<code>inputs</code><br>
<em>
<a href="#templates.kluctl.io/v1alpha1.*github.com/kluctl/template-controller/api/v1alpha1.TextTemplateInput">
[]*github.com/kluctl/template-controller/api/v1alpha1.TextTemplateInput
<a href="#templates.kluctl.io/v1alpha1.TextTemplateInput">
[]TextTemplateInput
</a>
</em>
</td>
Expand Down Expand Up @@ -2723,6 +2727,10 @@ TextTemplateStatus
</div>
<h3 id="templates.kluctl.io/v1alpha1.TextTemplateInput">TextTemplateInput
</h3>
<p>
(<em>Appears on:</em>
<a href="#templates.kluctl.io/v1alpha1.TextTemplateSpec">TextTemplateSpec</a>)
</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
Expand Down Expand Up @@ -2849,8 +2857,8 @@ when reconciling this TextTemplate. If omitted, the &ldquo;default&rdquo; servic
<td>
<code>inputs</code><br>
<em>
<a href="#templates.kluctl.io/v1alpha1.*github.com/kluctl/template-controller/api/v1alpha1.TextTemplateInput">
[]*github.com/kluctl/template-controller/api/v1alpha1.TextTemplateInput
<a href="#templates.kluctl.io/v1alpha1.TextTemplateInput">
[]TextTemplateInput
</a>
</em>
</td>
Expand Down

0 comments on commit cee3c2c

Please sign in to comment.