Skip to content

Commit 353e723

Browse files
committed
Add comparison support for blob type fields
Currently the code-generator panics whenever a CRD/type field is of type blob (array of bytes). This PR adds support for blob type comparison.
1 parent ea1222d commit 353e723

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

pkg/generate/code/compare.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ func compareScalar(
323323
"%sif *%s != *%s {\n",
324324
indent, firstResVarName, secondResVarName,
325325
)
326+
case "blob":
327+
out += fmt.Sprintf(
328+
"%sif !bytes.Equal(%s, %s) {\n",
329+
indent, firstResVarName, secondResVarName,
330+
)
326331
case "timestamp":
327332
// if !a.ko.Spec.CreatedAt.Equal(b.ko.Spec.CreatedAt) {
328333
out += fmt.Sprintf(

pkg/model/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func (m *Model) getShapeCleanGoType(shape *awssdkmodel.Shape) string {
346346
// If it's a map type we need to set the GoType to the cleaned-up
347347
// Camel-cased name
348348
return "map[string]" + m.getShapeCleanGoType(shape.ValueRef.Shape)
349-
case "list", "array", "blob":
349+
case "list", "array":
350350
// If it's a list type, we need to set the GoType to the cleaned-up
351351
// Camel-cased name
352352
return "[]" + m.getShapeCleanGoType(shape.MemberRef.Shape)

templates/pkg/resource/delta.go.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
package {{ .CRD.Names.Snake }}
44

55
import (
6+
"bytes"
67
"reflect"
78

89
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
910
)
1011

1112
// Hack to avoid import errors during build...
1213
var (
14+
_ = &bytes.Buffer{}
1315
_ = &reflect.Method{}
1416
)
1517

0 commit comments

Comments
 (0)