25
25
)
26
26
27
27
const (
28
- ShapeNameTemplateArray = "%sList"
29
- ShapeNameTemplateMap = "%sMap"
28
+ ShapeNameTemplateList = "%sList"
29
+ ShapeNameTemplateMap = "%sMap"
30
30
)
31
31
32
32
type CustomShape struct {
@@ -57,8 +57,8 @@ func (h *Helper) InjectCustomShapes(sdkapi *SDKAPI) error {
57
57
sdkapi .CustomShapes = append (sdkapi .CustomShapes , customShape )
58
58
}
59
59
60
- for _ , memberShape := range h .getCustomArrayFieldMembers () {
61
- customShape , err := injector .newArray (memberShape )
60
+ for _ , memberShape := range h .getCustomListFieldMembers () {
61
+ customShape , err := injector .newList (memberShape )
62
62
if err != nil {
63
63
return err
64
64
}
@@ -70,7 +70,9 @@ func (h *Helper) InjectCustomShapes(sdkapi *SDKAPI) error {
70
70
return nil
71
71
}
72
72
73
- func (h * Helper ) getCustomArrayFieldMembers () []string {
73
+ // getCustomListFieldMembers finds all of the custom list fields that need to
74
+ // be generated as defined in the generator config.
75
+ func (h * Helper ) getCustomListFieldMembers () []string {
74
76
members := []string {}
75
77
76
78
for _ , resource := range h .cfg .Resources {
@@ -84,6 +86,8 @@ func (h *Helper) getCustomArrayFieldMembers() []string {
84
86
return members
85
87
}
86
88
89
+ // getCustomMapFieldMembers finds all of the custom map fields that need to be
90
+ // generated as defined in the generator config.
87
91
func (h * Helper ) getCustomMapFieldMembers () []string {
88
92
members := []string {}
89
93
@@ -98,6 +102,8 @@ func (h *Helper) getCustomMapFieldMembers() []string {
98
102
return members
99
103
}
100
104
105
+ // createShapeRefForMember creates a minimal ShapeRef type to encapsulate a
106
+ // shape.
101
107
func (i * customShapeInjector ) createShapeRefForMember (shape * awssdkmodel.Shape ) * awssdkmodel.ShapeRef {
102
108
return & awssdkmodel.ShapeRef {
103
109
API : i .sdkAPI .API ,
@@ -107,6 +113,8 @@ func (i *customShapeInjector) createShapeRefForMember(shape *awssdkmodel.Shape)
107
113
}
108
114
}
109
115
116
+ // newList loads a shape given its name and creates a custom shape that is a
117
+ // map with strings as keys and that shape as the value.
110
118
func (i * customShapeInjector ) newMap (valueShapeName string ) (* CustomShape , error ) {
111
119
valueShape , exists := i .sdkAPI .API .Shapes [valueShapeName ]
112
120
if ! exists {
@@ -136,14 +144,16 @@ func (i *customShapeInjector) newMap(valueShapeName string) (*CustomShape, error
136
144
return & CustomShape {shape , shapeRef , nil , & valueShapeName }, nil
137
145
}
138
146
139
- func (i * customShapeInjector ) newArray (memberShapeName string ) (* CustomShape , error ) {
147
+ // newList loads a shape given its name and creates a custom shape that is a
148
+ // list of that shape.
149
+ func (i * customShapeInjector ) newList (memberShapeName string ) (* CustomShape , error ) {
140
150
memberShape , exists := i .sdkAPI .API .Shapes [memberShapeName ]
141
151
if ! exists {
142
152
return nil , ErrMemberShapeNotFound
143
153
}
144
154
memberShapeRef := i .createShapeRefForMember (memberShape )
145
155
146
- shapeName := fmt .Sprintf (ShapeNameTemplateArray , memberShape .ShapeName )
156
+ shapeName := fmt .Sprintf (ShapeNameTemplateList , memberShape .ShapeName )
147
157
documentation := ""
148
158
149
159
shape := & awssdkmodel.Shape {
0 commit comments