Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions templates/pkg/resource/references.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ func resolveReferenceFor{{ $field.FieldPathWithUnderscore }}(
}
return nil
}
{{ else if not $isList -}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm mistaken, isNested could be false here.... so better to do this?

{{ if $isNested and (not $isList) -}}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary, it is always going to be true here because of L132.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I missed that! :)

if ko.Spec.{{ $field.ReferenceFieldPath }} != nil &&
ko.Spec.{{ $field.ReferenceFieldPath }}.From != nil {
arr := ko.Spec.{{ $field.ReferenceFieldPath }}.From
{{ template "read_referenced_resource_and_validate" $field }}
referencedValue := string(*obj.{{ $field.FieldConfig.References.Path }})
ko.Spec.{{ $field.Path }} = &referencedValue
}
return nil
}
{{ else }}
{{ $parentField := index .CRD.Fields $fp.String }}
{{ if eq $parentField.ShapeRef.Shape.Type "list" -}}
Expand Down