Skip to content

Commit 2faac0a

Browse files
authored
Merge pull request #36 from A-Hilaly/lambda
Fix delta code generation for nested structs shapes
2 parents 38c3b3f + aeed8b3 commit 2faac0a

File tree

5 files changed

+1022
-50
lines changed

5 files changed

+1022
-50
lines changed

pkg/generate/code/compare.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,9 @@ func compareStruct(
543543
compareConfig,
544544
memberShape,
545545
deltaVarName,
546-
memberFieldPath,
547546
firstResAdaptedVarName,
548547
secondResAdaptedVarName,
548+
memberFieldPath,
549549
indentLevel,
550550
)
551551
case "list":
@@ -555,9 +555,9 @@ func compareStruct(
555555
compareConfig,
556556
memberShape,
557557
deltaVarName,
558-
memberFieldPath,
559558
firstResAdaptedVarName,
560559
secondResAdaptedVarName,
560+
memberFieldPath,
561561
indentLevel,
562562
)
563563
case "map":
@@ -567,9 +567,9 @@ func compareStruct(
567567
compareConfig,
568568
memberShape,
569569
deltaVarName,
570-
memberFieldPath,
571570
firstResAdaptedVarName,
572571
secondResAdaptedVarName,
572+
memberFieldPath,
573573
indentLevel,
574574
)
575575
default:

pkg/generate/code/compare_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,48 @@ func TestCompareResource_S3_Bucket(t *testing.T) {
103103
),
104104
)
105105
}
106+
107+
func TestCompareResource_Lambda_CodeSigningConfig(t *testing.T) {
108+
assert := assert.New(t)
109+
require := require.New(t)
110+
111+
g := testutil.NewGeneratorForService(t, "lambda")
112+
113+
crd := testutil.GetCRDByName(t, g, "CodeSigningConfig")
114+
require.NotNil(crd)
115+
116+
expected := `
117+
if ackcompare.HasNilDifference(a.ko.Spec.AllowedPublishers, b.ko.Spec.AllowedPublishers) {
118+
delta.Add("Spec.AllowedPublishers", a.ko.Spec.AllowedPublishers, b.ko.Spec.AllowedPublishers)
119+
} else if a.ko.Spec.AllowedPublishers != nil && b.ko.Spec.AllowedPublishers != nil {
120+
121+
if !ackcompare.SliceStringPEqual(a.ko.Spec.AllowedPublishers.SigningProfileVersionARNs, b.ko.Spec.AllowedPublishers.SigningProfileVersionARNs) {
122+
delta.Add("Spec.AllowedPublishers.SigningProfileVersionARNs", a.ko.Spec.AllowedPublishers.SigningProfileVersionARNs, b.ko.Spec.AllowedPublishers.SigningProfileVersionARNs)
123+
}
124+
}
125+
if ackcompare.HasNilDifference(a.ko.Spec.CodeSigningPolicies, b.ko.Spec.CodeSigningPolicies) {
126+
delta.Add("Spec.CodeSigningPolicies", a.ko.Spec.CodeSigningPolicies, b.ko.Spec.CodeSigningPolicies)
127+
} else if a.ko.Spec.CodeSigningPolicies != nil && b.ko.Spec.CodeSigningPolicies != nil {
128+
if ackcompare.HasNilDifference(a.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment, b.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment) {
129+
delta.Add("Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment", a.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment, b.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment)
130+
} else if a.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment != nil && b.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment != nil {
131+
if *a.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment != *b.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment {
132+
delta.Add("Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment", a.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment, b.ko.Spec.CodeSigningPolicies.UntrustedArtifactOnDeployment)
133+
}
134+
}
135+
}
136+
if ackcompare.HasNilDifference(a.ko.Spec.Description, b.ko.Spec.Description) {
137+
delta.Add("Spec.Description", a.ko.Spec.Description, b.ko.Spec.Description)
138+
} else if a.ko.Spec.Description != nil && b.ko.Spec.Description != nil {
139+
if *a.ko.Spec.Description != *b.ko.Spec.Description {
140+
delta.Add("Spec.Description", a.ko.Spec.Description, b.ko.Spec.Description)
141+
}
142+
}
143+
`
144+
assert.Equal(
145+
expected,
146+
code.CompareResource(
147+
crd.Config(), crd, "delta", "a.ko", "b.ko", 1,
148+
),
149+
)
150+
}

pkg/generate/lambda_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,18 @@ func TestLambda_Function(t *testing.T) {
5858

5959
expSpecFieldCamel := []string{
6060
"Code",
61+
"CodeSigningConfigARN",
6162
"DeadLetterConfig",
6263
"Description",
6364
"Environment",
6465
"FileSystemConfigs",
6566
"FunctionName",
6667
"Handler",
68+
"ImageConfig",
6769
"KMSKeyARN",
6870
"Layers",
6971
"MemorySize",
72+
"PackageType",
7073
"Publish",
7174
"Role",
7275
"Runtime",
@@ -84,12 +87,15 @@ func TestLambda_Function(t *testing.T) {
8487
"CodeSHA256",
8588
"CodeSize",
8689
// "FunctionArn", <-- ACKMetadata.ARN
90+
"ImageConfigResponse",
8791
"LastModified",
8892
"LastUpdateStatus",
8993
"LastUpdateStatusReason",
9094
"LastUpdateStatusReasonCode",
9195
"MasterARN",
9296
"RevisionID",
97+
"SigningJobARN",
98+
"SigningProfileVersionARN",
9399
"State",
94100
"StateReason",
95101
"StateReasonCode",

0 commit comments

Comments
 (0)