File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ type Config struct {
25
25
// Resources contains generator instructions for individual CRDs within an
26
26
// API
27
27
Resources map [string ]ResourceConfig `json:"resources"`
28
+ // MarkerShapes contains fields associated with empty structs used as markers
29
+ MarkerShapes []string `json:"marker_shapes,omitempty"`
28
30
// CRDs to ignore. ACK generator would skip these resources.
29
31
Ignore IgnoreSpec `json:"ignore"`
30
32
// Contains generator instructions for individual API operations.
@@ -151,6 +153,17 @@ func (c *Config) GetCustomMapFieldMembers() []string {
151
153
return members
152
154
}
153
155
156
+ // IsMarkerShape returns true if a given shape name is a marker shape,
157
+ // otherwise returns false
158
+ func (c * Config ) IsMarkerShape (shapeName string ) bool {
159
+ for _ , markerShape := range c .MarkerShapes {
160
+ if markerShape == shapeName {
161
+ return true
162
+ }
163
+ }
164
+ return false
165
+ }
166
+
154
167
// New returns a new Config object given a supplied
155
168
// path to a config file
156
169
func New (
Original file line number Diff line number Diff line change @@ -1388,8 +1388,13 @@ func varEmptyConstructorK8sType(
1388
1388
1389
1389
switch shape .Type {
1390
1390
case "structure" :
1391
- // f0 := &svcapitypes.BookData{}
1392
- out += fmt .Sprintf ("%s%s := &%s{}\n " , indent , varName , goType )
1391
+ if r .Config ().IsMarkerShape (shape .ShapeName ) {
1392
+ // f0 := []byte{}
1393
+ out += fmt .Sprintf ("%s%s := []byte{}\n " , indent , varName )
1394
+ } else {
1395
+ // f0 := &svcapitypes.BookData{}
1396
+ out += fmt .Sprintf ("%s%s := &%s{}\n " , indent , varName , goType )
1397
+ }
1393
1398
case "list" , "map" :
1394
1399
// f0 := []*string{}
1395
1400
out += fmt .Sprintf ("%s%s := %s{}\n " , indent , varName , goType )
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package model
16
16
import (
17
17
"errors"
18
18
"fmt"
19
+ "slices"
19
20
"sort"
20
21
"strings"
21
22
@@ -395,6 +396,11 @@ func (m *Model) IsShapeUsedInCRDs(shapeName string) bool {
395
396
return false
396
397
}
397
398
399
+ // IsMarkerShape return true if the supplied shape name is a marker shape
400
+ func (m * Model ) IsMarkerShape (shapeName string ) bool {
401
+ return slices .Contains (m .cfg .MarkerShapes , shapeName )
402
+ }
403
+
398
404
// GetTypeDefs returns a slice of `TypeDef` pointers
399
405
func (m * Model ) GetTypeDefs () ([]* TypeDef , error ) {
400
406
if m .typeDefs != nil {
@@ -471,6 +477,12 @@ func (m *Model) getShapeCleanGoType(shape *awssdkmodel.Shape) string {
471
477
// otherwise there is no DeepCopy support
472
478
return "*metav1.Time"
473
479
case "structure" :
480
+ if len (shape .MemberRefs ) == 0 {
481
+ if m .cfg .IsMarkerShape (shape .ShapeName ) {
482
+ return "[]byte"
483
+ }
484
+ panic (fmt .Sprintf ("structure %s has no fields, either configure it as a `marker_shape` or manually set the field type" , shape .ShapeName ))
485
+ }
474
486
// There are shapes that are called things like DBProxyStatus that are
475
487
// fields in a DBProxy CRD... we need to ensure the type names don't
476
488
// conflict. Also, the name of the Go type in the generated code is
You can’t perform that action at this time.
0 commit comments