Skip to content

Commit 876449d

Browse files
author
Nicholas Thomson
committed
Add explicit cast to slice append
1 parent 238a858 commit 876449d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/generate/code/resource_reference.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func ResolveReferencesForField(field *model.Field, sourceVarName string, indentL
257257

258258
outPrefix += getReferencedStateForField(field, indentLevel+idx)
259259

260-
outPrefix += fmt.Sprintf("%s\t%s = append(%s, obj.%s)\n", indent, targetVarName, targetVarName, field.FieldConfig.References.Path)
260+
outPrefix += fmt.Sprintf("%s\t%s = append(%s, (%s)obj.%s)\n", indent, targetVarName, targetVarName, field.ShapeRef.Shape.MemberRef.GoType(), field.FieldConfig.References.Path)
261261
outPrefix += fmt.Sprintf("%s}\n", indent)
262262
case ("map"):
263263
panic("references cannot be within a map")

pkg/generate/code/resource_reference_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func Test_ResolveReferencesForField_SliceOfReferences(t *testing.T) {
279279
if err := getReferencedResourceState_SecurityGroup(ctx, apiReader, obj, *arr.Name, namespace); err != nil {
280280
return err
281281
}
282-
ko.Spec.SecurityGroupIDs = append(ko.Spec.SecurityGroupIDs, obj.Status.ID)
282+
ko.Spec.SecurityGroupIDs = append(ko.Spec.SecurityGroupIDs, (*string)obj.Status.ID)
283283
}
284284
`
285285

0 commit comments

Comments
 (0)