Skip to content

Commit 338d010

Browse files
authored
Merge pull request #34 from surajkota/before_delta
Handle nil fields in response from describe API output - readOne and readMany
2 parents 7edaa44 + 27d64b2 commit 338d010

File tree

2 files changed

+377
-1
lines changed

2 files changed

+377
-1
lines changed

pkg/generate/code/set_resource.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ func SetResource(
288288
indentLevel+1,
289289
)
290290
}
291+
out += fmt.Sprintf(
292+
"%s} else {\n", indent,
293+
)
294+
out += fmt.Sprintf(
295+
"%s%s%s.%s = nil\n", indent, indent,
296+
targetAdaptedVarName, f.Names.Camel,
297+
)
291298
out += fmt.Sprintf(
292299
"%s}\n", indent,
293300
)
@@ -340,6 +347,8 @@ func ListMemberNameInReadManyOutput(
340347
// }
341348
// if elem.AtRestEncryptionEnabled != nil {
342349
// ko.Status.AtRestEncryptionEnabled = elem.AtRestEncryptionEnabled
350+
// } else {
351+
// ko.Status.AtRestEncryptionEnabled = nil
343352
// }
344353
// ...
345354
// if elem.CacheClusterId != nil {
@@ -349,6 +358,8 @@ func ListMemberNameInReadManyOutput(
349358
// }
350359
// }
351360
// r.ko.Spec.CacheClusterID = elem.CacheClusterId
361+
// } else {
362+
// r.ko.Spec.CacheClusterID = nil
352363
// }
353364
// found = true
354365
// }
@@ -545,7 +556,14 @@ func setResourceReadMany(
545556
)
546557
}
547558
out += fmt.Sprintf(
548-
"%s\t}\n", indent,
559+
"%s%s} else {\n", indent, indent,
560+
)
561+
out += fmt.Sprintf(
562+
"%s%s%s%s.%s = nil\n", indent, indent, indent,
563+
targetAdaptedVarName, f.Names.Camel,
564+
)
565+
out += fmt.Sprintf(
566+
"%s%s}\n", indent, indent,
549567
)
550568
}
551569
// When we don't have custom matching/filtering logic for the list

0 commit comments

Comments
 (0)