Documentation ¶
Index ¶
- Constants
- Variables
- func ReplacePkgName(subject string, apiPkgName string, replacePkgAlias string, keepPointer bool) string
- type Attr
- type CRD
- func (r *CRD) AddPrintableColumn(field *Field, jsonPath string) *PrinterColumn
- func (r *CRD) AddSpecField(memberNames names.Names, shapeRef *awssdkmodel.ShapeRef) *Field
- func (r *CRD) AddSpecPrintableColumn(field *Field) *PrinterColumn
- func (r *CRD) AddStatusField(memberNames names.Names, shapeRef *awssdkmodel.ShapeRef) *Field
- func (r *CRD) AddStatusPrintableColumn(field *Field) *PrinterColumn
- func (r *CRD) AddTypeImport(packagePath string, alias string)
- func (r *CRD) CompareIgnoredFields() []string
- func (r *CRD) Config() *ackgenconfig.Config
- func (r *CRD) CustomUpdateMethodName() string
- func (r *CRD) ExceptionCode(httpStatusCode int) string
- func (r *CRD) GetCustomImplementation(op *awssdkmodel.Operation) string
- func (r *CRD) HasShapeAsMember(toFind string) bool
- func (r *CRD) InputFieldRename(opID string, origFieldName string) (string, bool)
- func (r *CRD) IsPrimaryARNField(fieldName string) bool
- func (r *CRD) ListOpMatchFieldNames() []string
- func (r *CRD) NameField() string
- func (r *CRD) SDKAPIPackageName() string
- func (r *CRD) SetAttributesSingleAttribute() bool
- func (r *CRD) SetOutputCustomMethodName(op *awssdkmodel.Operation) *string
- func (r *CRD) SpecFieldNames() []string
- func (r *CRD) TerminalExceptionCodes() []string
- func (r *CRD) TypeRenames() map[string]string
- func (r *CRD) UnpackAttributes()
- func (r *CRD) UnpacksAttributesMap() bool
- func (r *CRD) UpdateConditionsCustomMethodName() string
- type EnumDef
- type EnumValue
- type Field
- type OpType
- type OperationMap
- type Ops
- type PrinterColumn
- type SDKAPI
- func (a *SDKAPI) APIGroup() string
- func (a *SDKAPI) CRDNames(cfg *ackgenconfig.Config) []names.Names
- func (a *SDKAPI) GetInputShapeRef(opID string, path string) (*awssdkmodel.ShapeRef, bool)
- func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap
- func (a *SDKAPI) GetOutputShapeRef(opID string, path string) (*awssdkmodel.ShapeRef, bool)
- func (a *SDKAPI) GetPayloads() []string
- func (a *SDKAPI) GetServiceFullName() string
- func (a *SDKAPI) GetTypeRenames(cfg *ackgenconfig.Config) map[string]string
- func (a *SDKAPI) HasConflictingTypeName(typeName string, cfg *ackgenconfig.Config) bool
- func (a *SDKAPI) SDKAPIInterfaceTypeName() string
- func (a *SDKAPI) ServiceID() string
- func (a *SDKAPI) ServiceIDClean() string
- type SDKHelper
- type TypeDef
Constants ¶
const ( // ConflictingNameSuffix is appended to type names when they overlap with // well-known common struct names for things like a CRD itself, or its // Spec/Status subfield struct type name. ConflictingNameSuffix = "_SDK" )
Variables ¶
Functions ¶
func ReplacePkgName ¶
func ReplacePkgName( subject string, apiPkgName string, replacePkgAlias string, keepPointer bool, ) string
ReplacePkgName accepts a type string (`subject`), as returned by `aws-sdk-go/private/model/api:Shape.GoTypeWithPkgName()` and replaces the package name of the aws-sdk-go SDK API (e.g. "ecr" for the ECR API) with a different package alias, typically the string "svcsdk" which is the alias we use in our Go code generating functions that get placed into files like `services/$SERVICE/pkg/resource/$RESOURCE/sdk.go`.
As an example, if ReplacePkgName() is called with the following parameters:
subject: "*ecr.Repository" apiPkgName: "ecr" replacePkgAlias: "svcsdk" keepPointer: true
the returned string would be "*svcsdk.Repository"
Why do we need to do this? Well, the Go code-generating functions return strings of Go code that construct various aws-sdk-go "service API shapes".
For example, the `github.com/aws/aws-sdk-go/services/ecr.DescribeRepositoriesResponse` struct returns a slice of `github.com/aws/aws-sdk-go/services/ecr.Repository` structs. The `aws-sdk-go/private/model/api.Shape` object that represents these `Repository` structs has a `GoTypeWithPkgName()` method that returns the string "*ecr.Repository". But because in our `templates/pkg/resource/sdk.go.tpl` file [0], you will note that we always alias the aws-sdk-go "service api" package as "svcsdk". So, we need a way to replace the "ecr." in the type string with "svcsdk.".
Types ¶
type CRD ¶
type CRD struct { Names names.Names Kind string Plural string // Ops are the CRUD operations controlling this resource Ops Ops // AdditionalPrinterColumns is an array of PrinterColumn objects // representing the printer column settings for the CRD // AdditionalPrinterColumns field. AdditionalPrinterColumns []*PrinterColumn // SpecFields is a map, keyed by the **original SDK member name** of // Field objects representing those fields in the CRD's Spec struct // field. SpecFields map[string]*Field // StatusFields is a map, keyed by the **original SDK member name** of // Field objects representing those fields in the CRD's Status struct // field. Note that there are no fields in StatusFields that are also in // SpecFields. StatusFields map[string]*Field // TypeImports is a map, keyed by an import string, with the map value // being the import alias TypeImports map[string]string // ShortNames represent the CRD list of aliases. Short names allow shorter // strings to match a CR on the CLI. ShortNames []string // contains filtered or unexported fields }
CRD describes a single top-level resource in an AWS service API
func NewCRD ¶
NewCRD returns a pointer to a new `ackmodel.CRD` struct that describes a single top-level resource in an AWS service API
func (*CRD) AddPrintableColumn ¶
func (r *CRD) AddPrintableColumn( field *Field, jsonPath string, ) *PrinterColumn
AddPrintableColumn adds an entry to the list of additional printer columns using the given path and field types.
func (*CRD) AddSpecField ¶
AddSpecField adds a new Field of a given name and shape into the Spec field of a CRD
func (*CRD) AddSpecPrintableColumn ¶
func (r *CRD) AddSpecPrintableColumn( field *Field, ) *PrinterColumn
AddSpecPrintableColumn adds an entry to the list of additional printer columns using the path of the given spec field.
func (*CRD) AddStatusField ¶
AddStatusField adds a new Field of a given name and shape into the Status field of a CRD
func (*CRD) AddStatusPrintableColumn ¶
func (r *CRD) AddStatusPrintableColumn( field *Field, ) *PrinterColumn
AddStatusPrintableColumn adds an entry to the list of additional printer columns using the path of the given status field.
func (*CRD) AddTypeImport ¶
AddTypeImport adds an entry in the CRD's TypeImports map for an import line and optional alias
func (*CRD) CompareIgnoredFields ¶
CompareIgnoredFields returns the list of fields compare logic should ignore
func (*CRD) Config ¶
func (r *CRD) Config() *ackgenconfig.Config
Config returns a pointer to the generator config
func (*CRD) CustomUpdateMethodName ¶
CustomUpdateMethodName returns the name of the custom resourceManager method for updating the resource state, if any has been specified in the generator config
func (*CRD) ExceptionCode ¶
ExceptionCode returns the name of the resource's Exception code for the Exception having the exception code. If the generator config has instructions for overriding the name of an exception code for a resource for a particular HTTP status code, we return that, otherwise we look through the API model definitions looking for a match
func (*CRD) GetCustomImplementation ¶
func (r *CRD) GetCustomImplementation( op *awssdkmodel.Operation, ) string
GetCustomImplementation returns custom implementation method name for the supplied operation as specified in generator config
func (*CRD) HasShapeAsMember ¶
HasShapeAsMember returns true if the supplied Shape name appears in *any* payload shape of *any* Operation for the resource. It recurses down through the resource's Operation Input and Output shapes and their member shapes looking for a shape with the supplied name
func (*CRD) InputFieldRename ¶
InputFieldRename returns the renamed field for a supplied Operation ID and original field name and whether or not a renamed override field name was found
func (*CRD) IsPrimaryARNField ¶
IsPrimaryARNField returns true if the supplied field name is likely the resource's ARN identifier field.
func (*CRD) ListOpMatchFieldNames ¶
ListOpMatchFieldNames returns a slice of strings representing the field names in the List operation's Output shape's element Shape that we should check a corresponding value in the target Spec exists.
func (*CRD) NameField ¶
NameField returns the name of the "Name" or string identifier field in the Spec
func (*CRD) SDKAPIPackageName ¶
SDKAPIPackageName returns the aws-sdk-go package name used for this resource's API
func (*CRD) SetAttributesSingleAttribute ¶
SetAttributesSingleAttribute returns true if the supplied resource name has a SetAttributes operation that only actually changes a single attribute at a time. See: SNS SetTopicAttributes API call, which is entirely different from the SNS SetPlatformApplicationAttributes API call, which sets multiple attributes at once. :shrug:
func (*CRD) SetOutputCustomMethodName ¶
func (r *CRD) SetOutputCustomMethodName( op *awssdkmodel.Operation, ) *string
SetOutputCustomMethodName returns custom set output operation as *string for given operation on custom resource, if specified in generator config
func (*CRD) SpecFieldNames ¶
SpecFieldNames returns a sorted slice of field names for the Spec fields
func (*CRD) TerminalExceptionCodes ¶
TerminalExceptionCodes returns terminal exception codes as []string for custom resource, if specified in generator config
func (*CRD) TypeRenames ¶
TypeRenames returns a map of original type name to renamed name (some type definition names conflict with generated names)
func (*CRD) UnpackAttributes ¶
func (r *CRD) UnpackAttributes()
UnpackAttributes grabs instructions about fields that are represented in the AWS API as a `map[string]*string` but are actually real, schema'd fields and adds Field definitions for those fields.
func (*CRD) UnpacksAttributesMap ¶
UnpacksAttributesMap returns true if the underlying API has Get{Resource}Attributes/Set{Resource}Attributes API calls that map real, schema'd fields to a raw `map[string]*string` for this resource (see SNS and SQS APIs)
func (*CRD) UpdateConditionsCustomMethodName ¶
UpdateConditionsCustomMethodName returns custom update conditions operation as *string for custom resource, if specified in generator config
type EnumDef ¶
EnumDef is the definition of an enumeration type for a field present in either a CRD or a TypeDef
type Field ¶
type Field struct { CRD *CRD Names names.Names GoType string GoTypeElem string GoTypeWithPkgName string ShapeRef *awssdkmodel.ShapeRef FieldConfig *ackgenconfig.FieldConfig }
Field represents a single field in the CRD's Spec or Status objects
func (*Field) IsRequired ¶
IsRequired checks the FieldConfig for Field and returns if the field is marked as required or not.A
If there is no required override present for this field in FieldConfig, IsRequired will return if the shape is marked as required in AWS SDK Private model We use this to append kubebuilder:validation:Required markers to validate using the CRD validation schema
type OpType ¶
type OpType int
func GetOpTypeAndResourceNameFromOpID ¶
GetOpTypeAndResourceNameFromOpID guesses the resource name and type of operation from the OperationID
func OpTypeFromString ¶
type OperationMap ¶
type OperationMap map[OpType]map[string]*awssdkmodel.Operation
type Ops ¶
type Ops struct { Create *awssdkmodel.Operation ReadOne *awssdkmodel.Operation ReadMany *awssdkmodel.Operation Update *awssdkmodel.Operation Delete *awssdkmodel.Operation GetAttributes *awssdkmodel.Operation SetAttributes *awssdkmodel.Operation }
Ops are the CRUD operations controlling a particular resource
func (Ops) IterOps ¶
func (ops Ops) IterOps() []*awssdkmodel.Operation
IterOps returns a slice of Operations for a resource
type PrinterColumn ¶
PrinterColumn represents a single field in the CRD's Spec or Status objects
type SDKAPI ¶
type SDKAPI struct { API *awssdkmodel.API // contains filtered or unexported fields }
SDKAPI contains an API model for a single AWS service API
func (*SDKAPI) APIGroup ¶
APIGroup returns the normalized Kubernetes APIGroup for the AWS service API, e.g. "sns.services.k8s.aws"
func (*SDKAPI) CRDNames ¶
func (a *SDKAPI) CRDNames(cfg *ackgenconfig.Config) []names.Names
CRDNames returns a slice of names structs for all top-level resources in the API
func (*SDKAPI) GetInputShapeRef ¶
GetInputShapeRef finds a ShapeRef for a supplied member path (dot-notation) for given API operation
func (*SDKAPI) GetOperationMap ¶
func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap
GetOperationMap returns a map, keyed by the operation type and operation ID/name, of aws-sdk-go private/model/api.Operation struct pointers
func (*SDKAPI) GetOutputShapeRef ¶
GetOutputShapeRef finds a ShapeRef for a supplied member path (dot-notation) for given API operation
func (*SDKAPI) GetPayloads ¶
GetPayloads returns a slice of strings of Shape names representing input and output request/response payloads
func (*SDKAPI) GetServiceFullName ¶
func (*SDKAPI) GetTypeRenames ¶
func (a *SDKAPI) GetTypeRenames(cfg *ackgenconfig.Config) map[string]string
GetTypeRenames returns a map of original type name to renamed name (some type definition names conflict with generated names)
func (*SDKAPI) HasConflictingTypeName ¶
func (a *SDKAPI) HasConflictingTypeName(typeName string, cfg *ackgenconfig.Config) bool
HasConflictingTypeName returns true if the supplied type name will conflict with any generated type in the service's API package
func (*SDKAPI) SDKAPIInterfaceTypeName ¶
SDKAPIInterfaceTypeName returns the name of the aws-sdk-go primary API interface type name.
func (*SDKAPI) ServiceID ¶
ServiceID returns the exact `metadata.serviceId` attribute for the AWS service APi's api-2.json file
func (*SDKAPI) ServiceIDClean ¶
ServiceIDClean returns a lowercased, whitespace-stripped ServiceID
type SDKHelper ¶
type SDKHelper struct { // Default is "services.k8s.aws" APIGroupSuffix string // contains filtered or unexported fields }
SDKHelper is a helper struct that helps work with the aws-sdk-go models and API model loader
func NewSDKHelper ¶
NewSDKHelper returns a new SDKHelper object
func (*SDKHelper) APIVersion ¶
APIVersion returns the API version (e.h. "2012-10-03") for a service API