Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions pkg/generate/code/synced.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ func scalarFieldEqual(
) string {
out := ""
fieldPath := fmt.Sprintf("%s.%s", resVarName, *condCfg.Path)

// if r.ko.Status.Status == nil
out += fmt.Sprintf("\tif %s == nil {\n", fieldPath)
// return false, nil
out += "\t\treturn false, nil\n"
// }
out += "\t}\n"
valuesSlice := ""
switch goType {
case "string":
Expand Down Expand Up @@ -174,9 +179,8 @@ func fieldPathSafeEqual(
subFieldPath := rootPath
for index, shape := range shapes {
if index == len(shapes)-1 {
// Some aws-sdk-go scalar shapes don't contain the real name of a shape
// In this case we use the full path given in condition.Path
subFieldPath = fmt.Sprintf("%s.%s", resVarName, *condCfg.Path)
// We would check for nil in scalarFieldEqual method so no need to loop anymore
break
} else {
subFieldPath += "." + shape.Shape.ShapeName
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/generate/code/synced_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,23 @@ func TestSyncedLambdaFunction(t *testing.T) {
require.NotNil(crd)

expectedSyncedConditions := `
if r.ko.Status.State == nil {
return false, nil
}
stateCandidates := []string{"AVAILABLE", "ACTIVE"}
if !ackutil.InStrings(*r.ko.Status.State, stateCandidates) {
return false, nil
}
if r.ko.Status.LastUpdateStatus == nil {
return false, nil
}
lastUpdateStatusCandidates := []string{"AVAILABLE", "ACTIVE"}
if !ackutil.InStrings(*r.ko.Status.LastUpdateStatus, lastUpdateStatusCandidates) {
return false, nil
}
if r.ko.Status.CodeSize == nil {
return false, nil
}
codeSizeCandidates := []int{1, 2}
if !ackutil.InStrings(*r.ko.Status.CodeSize, codeSizeCandidates) {
return false, nil
Expand All @@ -64,6 +73,9 @@ func TestSyncedDynamodbTable(t *testing.T) {
require.NotNil(crd)

expectedSyncedConditions := `
if r.ko.Status.TableStatus == nil {
return false, nil
}
tableStatusCandidates := []string{"AVAILABLE", "ACTIVE"}
if !ackutil.InStrings(*r.ko.Status.TableStatus, tableStatusCandidates) {
return false, nil
Expand All @@ -78,6 +90,9 @@ func TestSyncedDynamodbTable(t *testing.T) {
if !ackutil.InStrings(*r.ko.Spec.ProvisionedThroughput.ReadCapacityUnits, provisionedThroughputCandidates) {
return false, nil
}
if r.ko.Status.ItemCount == nil {
return false, nil
}
itemCountCandidates := []int{0}
if !ackutil.InStrings(*r.ko.Status.ItemCount, itemCountCandidates) {
return false, nil
Expand Down