Skip to content

Commit eaabefb

Browse files
authored
Fix generated code not setting API payload for fields with type "union" (#628)
Issue #, if available: [2651](aws-controllers-k8s/community#2651) Description of changes: This PR fixes the following issues with `setSDKForUnion` function. - Fixes union member values not being set in the API payload. - Fixes the the ACK controller's not setting an ACK.Terminal condition if more than one union member is set. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 3756200 commit eaabefb

File tree

5 files changed

+6836
-4
lines changed

5 files changed

+6836
-4
lines changed

pkg/generate/code/set_sdk.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ func setSDKForUnion(
17861786
cfg, r,
17871787
indexedVarName,
17881788
memberShape,
1789-
indentLevel+2,
1789+
indentLevel+1,
17901790
)
17911791
out += setSDKForContainer(
17921792
cfg, r,
@@ -1797,12 +1797,16 @@ func setSDKForUnion(
17971797
memberShapeRef,
17981798
false,
17991799
op,
1800-
indentLevel+2,
1800+
indentLevel+1,
18011801
)
1802-
out += fmt.Sprintf("%s%s.Value = *%s\n", indent, elemVarName, indexedVarName)
1802+
out += fmt.Sprintf("%s\t%s.Value = *%s\n", indent, elemVarName, indexedVarName)
1803+
out += fmt.Sprintf("%s\t%s = %s\n", indent, targetVarName, elemVarName)
1804+
out += fmt.Sprintf("%s\tisInterfaceSet = true\n", indent)
18031805
}
18041806
default:
1805-
out += fmt.Sprintf("%s%s.Value = *%s\n", indent, elemVarName, sourceAdaptedVarName)
1807+
out += fmt.Sprintf("%s\t%s.Value = *%s\n", indent, elemVarName, sourceAdaptedVarName)
1808+
out += fmt.Sprintf("%s\t%s = %s\n", indent, targetVarName, elemVarName)
1809+
out += fmt.Sprintf("%s\tisInterfaceSet = true\n", indent)
18061810
}
18071811
if memberShape.RealType == "union" {
18081812
memberShapeRef.Shape.Type = "structure"

0 commit comments

Comments
 (0)