Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/generate/ack/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func APIs(
crdFileName := strcase.ToSnake(crd.Kind) + ".go"
crdVars := &templateCRDVars{
metaVars,
m.SDKAPI,
crd,
}
if err = ts.Add(crdFileName, "apis/crd.go.tpl", crdVars); err != nil {
Expand All @@ -105,5 +106,6 @@ type templateAPIVars struct {
// code for a single top-level resource's API definition
type templateCRDVars struct {
templateset.MetaVars
CRD *ackmodel.CRD
SDKAPI *ackmodel.SDKAPI
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might consider adding this to the "root" templateset.MetaVars at some point in the future.

CRD *ackmodel.CRD
}
9 changes: 9 additions & 0 deletions pkg/generate/ack/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
ackgenconfig "github.com/aws-controllers-k8s/code-generator/pkg/generate/config"
"github.com/aws-controllers-k8s/code-generator/pkg/generate/templateset"
ackmodel "github.com/aws-controllers-k8s/code-generator/pkg/model"
awssdkmodel "github.com/aws/aws-sdk-go/private/model/api"
)

var (
Expand Down Expand Up @@ -93,6 +94,12 @@ var (
"GoCodeSetDeleteInput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
return code.SetSDK(r.Config(), r, ackmodel.OpTypeDelete, sourceVarName, targetVarName, indentLevel)
},
"GoCodeSetSDKForStruct": func(r *ackmodel.CRD, targetFieldName string, targetVarName string, targetShapeRef *awssdkmodel.ShapeRef, sourceFieldPath string, sourceVarName string, indentLevel int) string {
return code.SetSDKForStruct(r.Config(), r, targetFieldName, targetVarName, targetShapeRef, sourceFieldPath, sourceVarName, indentLevel)
},
"GoCodeSetResourceForStruct": func(r *ackmodel.CRD, targetFieldName string, targetVarName string, targetShapeRef *awssdkmodel.ShapeRef, sourceVarName string, sourceShapeRef *awssdkmodel.ShapeRef, indentLevel int) string {
return code.SetResourceForStruct(r.Config(), r, targetFieldName, targetVarName, targetShapeRef, sourceVarName, sourceShapeRef, indentLevel)
},
"GoCodeCompare": func(r *ackmodel.CRD, deltaVarName string, sourceVarName string, targetVarName string, indentLevel int) string {
return code.CompareResource(r.Config(), r, deltaVarName, sourceVarName, targetVarName, indentLevel)
},
Expand Down Expand Up @@ -132,6 +139,7 @@ func Controller(
controllerFuncMap["Hook"] = func(r *ackmodel.CRD, hookID string) string {
crdVars := &templateCRDVars{
metaVars,
m.SDKAPI,
r,
}
code, err := ResourceHookCode(templateBasePaths, r, hookID, crdVars, controllerFuncMap)
Expand Down Expand Up @@ -165,6 +173,7 @@ func Controller(
tplPath := filepath.Join("pkg/resource", target)
crdVars := &templateCRDVars{
metaVars,
m.SDKAPI,
crd,
}
if err = ts.Add(outPath, tplPath, crdVars); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/generate/code/set_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ func setResourceForContainer(
) string {
switch sourceShapeRef.Shape.Type {
case "structure":
return setResourceForStruct(
return SetResourceForStruct(
cfg, r,
targetFieldName,
targetVarName,
Expand Down Expand Up @@ -1031,9 +1031,9 @@ func setResourceForContainer(
}
}

// setResourceForStruct returns a string of Go code that sets a target variable
// SetResourceForStruct returns a string of Go code that sets a target variable
// value to a source variable when the type of the source variable is a struct.
func setResourceForStruct(
func SetResourceForStruct(
cfg *ackgenconfig.Config,
r *model.CRD,
// The name of the CR field we're outputting for
Expand Down
6 changes: 3 additions & 3 deletions pkg/generate/code/set_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ func setSDKForContainer(
) string {
switch targetShapeRef.Shape.Type {
case "structure":
return setSDKForStruct(
return SetSDKForStruct(
cfg, r,
targetFieldName,
targetVarName,
Expand Down Expand Up @@ -874,9 +874,9 @@ func setSDKForSecret(
return out
}

// setSDKForStruct returns a string of Go code that sets a target variable
// SetSDKForStruct returns a string of Go code that sets a target variable
// value to a source variable when the type of the source variable is a struct.
func setSDKForStruct(
func SetSDKForStruct(
cfg *ackgenconfig.Config,
r *model.CRD,
// The name of the CR field we're outputting for
Expand Down