Skip to content

Commit 825cb75

Browse files
author
Nicholas Thomson
committed
Add method docs
1 parent d45e6b5 commit 825cb75

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

pkg/model/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (m *Model) GetCRDs() ([]*CRD, error) {
159159
} else if fieldConfig.CustomField != nil {
160160
customField := fieldConfig.CustomField
161161
if customField.MemberShape != "" {
162-
memberShapeRef, found = m.SDKAPI.GetCustomArrayRef(customField.MemberShape)
162+
memberShapeRef, found = m.SDKAPI.GetCustomListRef(customField.MemberShape)
163163
} else {
164164
memberShapeRef, found = m.SDKAPI.GetCustomMapRef(customField.ValueShape)
165165
}
@@ -251,7 +251,7 @@ func (m *Model) GetCRDs() ([]*CRD, error) {
251251
} else if fieldConfig.CustomField != nil {
252252
customField := fieldConfig.CustomField
253253
if customField.MemberShape != "" {
254-
memberShapeRef, found = m.SDKAPI.GetCustomArrayRef(customField.MemberShape)
254+
memberShapeRef, found = m.SDKAPI.GetCustomListRef(customField.MemberShape)
255255
} else {
256256
memberShapeRef, found = m.SDKAPI.GetCustomMapRef(customField.ValueShape)
257257
}

pkg/sdk/custom_shapes.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ var (
2525
)
2626

2727
const (
28-
ShapeNameTemplateArray = "%sList"
29-
ShapeNameTemplateMap = "%sMap"
28+
ShapeNameTemplateList = "%sList"
29+
ShapeNameTemplateMap = "%sMap"
3030
)
3131

3232
type CustomShape struct {
@@ -57,8 +57,8 @@ func (h *Helper) InjectCustomShapes(sdkapi *SDKAPI) error {
5757
sdkapi.CustomShapes = append(sdkapi.CustomShapes, customShape)
5858
}
5959

60-
for _, memberShape := range h.getCustomArrayFieldMembers() {
61-
customShape, err := injector.newArray(memberShape)
60+
for _, memberShape := range h.getCustomListFieldMembers() {
61+
customShape, err := injector.newList(memberShape)
6262
if err != nil {
6363
return err
6464
}
@@ -70,7 +70,9 @@ func (h *Helper) InjectCustomShapes(sdkapi *SDKAPI) error {
7070
return nil
7171
}
7272

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 {
7476
members := []string{}
7577

7678
for _, resource := range h.cfg.Resources {
@@ -84,6 +86,8 @@ func (h *Helper) getCustomArrayFieldMembers() []string {
8486
return members
8587
}
8688

89+
// getCustomMapFieldMembers finds all of the custom map fields that need to be
90+
// generated as defined in the generator config.
8791
func (h *Helper) getCustomMapFieldMembers() []string {
8892
members := []string{}
8993

@@ -98,6 +102,8 @@ func (h *Helper) getCustomMapFieldMembers() []string {
98102
return members
99103
}
100104

105+
// createShapeRefForMember creates a minimal ShapeRef type to encapsulate a
106+
// shape.
101107
func (i *customShapeInjector) createShapeRefForMember(shape *awssdkmodel.Shape) *awssdkmodel.ShapeRef {
102108
return &awssdkmodel.ShapeRef{
103109
API: i.sdkAPI.API,
@@ -107,6 +113,8 @@ func (i *customShapeInjector) createShapeRefForMember(shape *awssdkmodel.Shape)
107113
}
108114
}
109115

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.
110118
func (i *customShapeInjector) newMap(valueShapeName string) (*CustomShape, error) {
111119
valueShape, exists := i.sdkAPI.API.Shapes[valueShapeName]
112120
if !exists {
@@ -136,14 +144,16 @@ func (i *customShapeInjector) newMap(valueShapeName string) (*CustomShape, error
136144
return &CustomShape{shape, shapeRef, nil, &valueShapeName}, nil
137145
}
138146

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) {
140150
memberShape, exists := i.sdkAPI.API.Shapes[memberShapeName]
141151
if !exists {
142152
return nil, ErrMemberShapeNotFound
143153
}
144154
memberShapeRef := i.createShapeRefForMember(memberShape)
145155

146-
shapeName := fmt.Sprintf(ShapeNameTemplateArray, memberShape.ShapeName)
156+
shapeName := fmt.Sprintf(ShapeNameTemplateList, memberShape.ShapeName)
147157
documentation := ""
148158

149159
shape := &awssdkmodel.Shape{

pkg/sdk/helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *operations.Operation
240240
return &opMap
241241
}
242242

243-
// GetCustomArrayRef finds a ShapeRef for a supplied custom slice field
244-
func (a *SDKAPI) GetCustomArrayRef(memberShapeName string) (*awssdkmodel.ShapeRef, bool) {
243+
// GetCustomListRef finds a ShapeRef for a supplied custom slice field
244+
func (a *SDKAPI) GetCustomListRef(memberShapeName string) (*awssdkmodel.ShapeRef, bool) {
245245
for _, shape := range a.CustomShapes {
246246
if shape.MemberShapeName != nil && *shape.MemberShapeName == memberShapeName {
247247
return shape.ShapeRef, true

0 commit comments

Comments
 (0)