model

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var (
	// ErrNilShapePointer indicates an unexpected nil Shape pointer
	ErrNilShapePointer = errors.New("found nil Shape pointer")
)
View Source
var (
	// GoTypeToSDKShapeType is a map of Go types to aws-sdk-go
	// private/model/api.Shape types
	GoTypeToSDKShapeType = map[string]string{
		"int":       "integer",
		"int64":     "integer",
		"float64":   "float",
		"string":    "string",
		"bool":      "boolean",
		"time.Time": "timestamp",
		"bytes":     "blob",
	}
)

Functions

func CleanGoType added in v0.15.2

func CleanGoType(
	api *SDKAPI,
	cfg *ackgenconfig.Config,
	shape *awssdkmodel.Shape,
	fieldCfg *ackgenconfig.FieldConfig,
) (string, string, string)

CleanGoType returns a tuple of three strings representing the normalized Go types in "element", "normal" and "with package name" format for a particular Shape.

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.".

[0] https://github.com/aws-controllers-k8s/code-generator/blob/e2970c8ec5a68a831081d22d82509a428aa5fe00/templates/pkg/resource/sdk.go.tpl#L20

func ResourceManagerMethodFromOpType added in v0.16.0

func ResourceManagerMethodFromOpType(opType OpType) string

ResourceManagerMethodFromOpType returns the string representing the AWSResourceManager method ("Create", "Update", "Delete" or "ReadOne") corresponding to the supplied OpType.

Types

type Attr

type Attr struct {
	Names  names.Names
	GoType string
	Shape  *awssdkmodel.Shape
	GoTag  string
}

func NewAttr

func NewAttr(
	names names.Names,
	goType string,
	shape *awssdkmodel.Shape,
) *Attr

func (*Attr) GetGoTag added in v0.29.0

func (a *Attr) GetGoTag() string

GetGoTag returns the Go Tag to inject for this attribute. If the GoTag field is not empty, it will be used. Otherwise, one will be generated from the attribute's name.

type By added in v0.0.6

type By func(a, b *PrinterColumn) bool

By can sort two PrinterColumns

func (By) Sort added in v0.0.6

func (by By) Sort(subject []*PrinterColumn)

Sort does an in-place sort of the supplied printer columns

type CRD

type CRD struct {
	Names  names.Names
	Kind   string
	Plural string
	// Ops are the CRUD operations controlling this resource
	Ops Ops

	// 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
	// Fields is a map, keyed by the **renamed/normalized field path**, of
	// Field objects representing a field in the CRD's Spec or Status objects.
	Fields 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

func NewCRD(
	sdkAPI *SDKAPI,
	cfg *ackgenconfig.Config,
	docCfg *ackgenconfig.DocumentationConfig,
	crdNames names.Names,
	ops Ops,
) *CRD

NewCRD returns a pointer to a new `ackmodel.CRD` struct that describes a single top-level resource in an AWS service API

func (*CRD) AddSpecField

func (r *CRD) AddSpecField(
	memberNames names.Names,
	shapeRef *awssdkmodel.ShapeRef,
)

AddSpecField adds a new Field of a given name and shape into the Spec field of a CRD

func (*CRD) AddStatusField

func (r *CRD) AddStatusField(
	memberNames names.Names,
	shapeRef *awssdkmodel.ShapeRef,
)

AddStatusField adds a new Field of a given name and shape into the Status field of a CRD

func (*CRD) AddTypeImport

func (r *CRD) AddTypeImport(
	packagePath string,
	alias string,
)

AddTypeImport adds an entry in the CRD's TypeImports map for an import line and optional alias

func (*CRD) AdditionalPrinterColumns

func (r *CRD) AdditionalPrinterColumns() []*PrinterColumn

AdditionalPrinterColumns returns a sorted list of PrinterColumn structs for the resource

func (*CRD) CompareIgnoredFields

func (r *CRD) CompareIgnoredFields() []string

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) CustomDeleteMethodName added in v0.29.0

func (r *CRD) CustomDeleteMethodName() string

func (*CRD) CustomFindMethodName added in v0.29.0

func (r *CRD) CustomFindMethodName() string

func (*CRD) CustomUpdateMethodName

func (r *CRD) CustomUpdateMethodName() string

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) Documentation added in v0.2.3

func (r *CRD) Documentation() string

Documentation returns the base documentation string for the API formatted as a Go code comment block

func (*CRD) ExceptionCode

func (r *CRD) ExceptionCode(httpStatusCode int) string

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) GetAllRenames added in v0.6.0

func (r *CRD) GetAllRenames(op OpType) map[string]string

GetAllRenames returns all the field renames observed in the generator config for a given OpType.

func (*CRD) GetCustomCheckRequiredFieldsMissingMethod added in v0.5.0

func (r *CRD) GetCustomCheckRequiredFieldsMissingMethod(

	op *awssdkmodel.Operation,
) string

GetCustomCheckRequiredFieldsMissingMethod returns custom check required fields missing method as string for custom resource

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) GetIdentifiers added in v0.13.1

func (r *CRD) GetIdentifiers() []string

GetIdentifiers returns the identifier fields of a given CRD which can be singular or plural. Note, these fields will be the *original* field names from the API model shape, not renamed field names.

func (*CRD) GetImmutableFieldPaths added in v0.2.2

func (r *CRD) GetImmutableFieldPaths() []string

GetImmutableFieldPaths returns list of immutable field paths present in CRD

func (*CRD) GetMatchingInputShapeFieldName added in v0.26.1

func (r *CRD) GetMatchingInputShapeFieldName(opType OpType, sdkField string) string

GetMatchingInputShapeFieldName returns the name of the field in the Input shape. For simplicity, we assume that there will be only one setConfig for the any unique sdkField, per operation. Which means that we will never set two different sdk field from the same

func (*CRD) GetOutputShape added in v0.3.0

func (r *CRD) GetOutputShape(
	op *awssdkmodel.Operation,
) (*awssdkmodel.Shape, error)

GetOutputShape returns the Output shape for a given operation and applies wrapper field path overrides.

func (*CRD) GetOutputShapeGoType added in v0.3.0

func (r *CRD) GetOutputShapeGoType(
	op *awssdkmodel.Operation,
) string

GetOutputShapeGoType returns the Go type of the supplied operation's Output shape, renamed to use the standardized svcsdk alias.

func (*CRD) GetOutputWrapperFieldPath added in v0.2.3

func (r *CRD) GetOutputWrapperFieldPath(
	op *awssdkmodel.Operation,
) *string

GetOutputWrapperFieldPath returns the JSON-Path of the output wrapper field as *string for a given operation.

func (*CRD) GetPrimaryKeyField added in v0.14.0

func (r *CRD) GetPrimaryKeyField() (*Field, error)

GetPrimaryKeyField returns the field designated as the primary key, nil if none are specified or an error if multiple are designated.

func (*CRD) GetResourcePrintOrderByName added in v0.2.3

func (r *CRD) GetResourcePrintOrderByName() string

GetResourcePrintOrderByName returns the Printer Column order-by field name

func (*CRD) GetSanitizedMemberPath added in v0.13.1

func (r *CRD) GetSanitizedMemberPath(
	memberName string,
	op *awssdkmodel.Operation,
	koVarName string) (string, error)

GetSanitizedMemberPath takes a shape member field, checks for renames, checks for existence in Spec and Status, then constructs and returns the var path. Returns error if memberName is not present in either Spec or Status.

func (*CRD) GetStorageVersion added in v0.16.4

func (r *CRD) GetStorageVersion(defaultVersion string) (string, error)

GetStorageVersion returns the configured storage API version for the CRD, or the specified default version.

func (*CRD) GetTagField added in v0.19.0

func (r *CRD) GetTagField() (*Field, error)

GetTagField return the model.Field representing the Tag field for CRD. If no such field is found an error is returned.

func (*CRD) GetTagFieldName added in v0.19.0

func (r *CRD) GetTagFieldName() (string, error)

GetTagFieldName returns the name of field containing AWS tags. The default name is "Tags". If no tag field is found inside the CRD, an error is returned

func (*CRD) GetTagKeyMemberName added in v0.19.0

func (r *CRD) GetTagKeyMemberName() (keyMemberName string)

GetTagKeyMemberName returns the member name which represents tag key. The default value is "Key". This is only applicable for tag fields with shape list of struct.If the tag field shape is not list of struct, an empty string is returned.

func (*CRD) GetTagValueMemberName added in v0.19.0

func (r *CRD) GetTagValueMemberName() (valueMemberName string)

GetTagValueMemberName returns the member name which represents tag value. The default value is "Value". This is only applicable for tag fields with shape list of struct.If the tag field shape is not list of struct, an empty string is returned.

func (*CRD) HasImmutableFieldChanges added in v0.2.2

func (r *CRD) HasImmutableFieldChanges() bool

HasImmutableFieldChanges helper function that return true if there are any immutable field changes

func (*CRD) HasMember added in v0.16.0

func (r *CRD) HasMember(
	memberName string,
	operationName string,
) (inSpec bool, inStatus bool)

HasMember returns true in the respective field if Spec xor Status field contains memberName or rename

func (*CRD) HasReferenceFields added in v0.16.0

func (r *CRD) HasReferenceFields() bool

HasReferenceFields returns true if any of the fields in CRD is a reference field. Otherwise returns false

func (*CRD) HasShapeAsMember

func (r *CRD) HasShapeAsMember(toFind string) bool

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) IsARNPrimaryKey added in v0.14.0

func (r *CRD) IsARNPrimaryKey() bool

IsARNPrimaryKey returns true if the CRD uses its ARN as its primary key in ReadOne calls.

func (*CRD) IsAdoptable added in v0.1.0

func (r *CRD) IsAdoptable() bool

IsAdoptable returns true if the resource can be adopted

func (*CRD) IsPrimaryARNField

func (r *CRD) IsPrimaryARNField(fieldName string) bool

IsPrimaryARNField returns true if the supplied field name is likely the resource's ARN identifier field.

func (*CRD) IsSecretField added in v0.2.0

func (r *CRD) IsSecretField(path string) bool

IsSecretField returns true if the supplied field *path* refers to a Field that is a SecretKeyReference

func (*CRD) ListOpMatchFieldNames

func (r *CRD) ListOpMatchFieldNames() []string

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) OmitUnchangedFieldsOnUpdate added in v0.24.3

func (r *CRD) OmitUnchangedFieldsOnUpdate() bool

OmitUnchangedFieldsOnUpdate returns whether the controller needs to omit unchanged fields from an update request or not.

func (*CRD) PrintAgeColumn added in v0.2.3

func (r *CRD) PrintAgeColumn() bool

PrintAgeColumn returns whether the code generator should append 'Age' kubebuilder:printcolumn comment marker

func (*CRD) PrintSyncedColumn added in v0.19.0

func (r *CRD) PrintSyncedColumn() bool

PrintSyncedColumn returns whether the code generator should append 'Sync' kubebuilder:printcolumn comment marker

func (*CRD) ReconcileRequeuOnSuccessSeconds added in v0.3.1

func (r *CRD) ReconcileRequeuOnSuccessSeconds() int

ReconcileRequeuOnSuccessSeconds returns the duration after which to requeue the custom resource as int

func (*CRD) ReferencedServiceNames added in v0.18.0

func (r *CRD) ReferencedServiceNames() (serviceNames []string)

ReferencedServiceNames returns the set of service names for ACK controllers whose resources are referenced inside the CRD. The service name is the go package name for the AWS service inside aws-sdk-go.

If a CRD has no reference fields, nil is returned(zero vale of slice)

func (*CRD) SDKAPIPackageName

func (r *CRD) SDKAPIPackageName() string

SDKAPIPackageName returns the aws-sdk-go package name used for this resource's API

func (*CRD) SetAttributesSingleAttribute

func (r *CRD) SetAttributesSingleAttribute() bool

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

func (*CRD) SortedFieldNames added in v0.18.0

func (r *CRD) SortedFieldNames() []string

SortedFieldNames returns the fieldNames of the CRD in a sorted order.

func (*CRD) SpecFieldNames

func (r *CRD) SpecFieldNames() []string

SpecFieldNames returns a sorted slice of field names for the Spec fields

func (*CRD) SpecIdentifierField added in v0.1.0

func (r *CRD) SpecIdentifierField() *string

SpecIdentifierField returns the name of the "Name" or string identifier field in the Spec.

func (*CRD) TerminalExceptionCodes

func (r *CRD) TerminalExceptionCodes() []string

TerminalExceptionCodes returns terminal exception codes as []string for custom resource

func (*CRD) TypeRenames

func (r *CRD) TypeRenames() map[string]string

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

func (r *CRD) UnpacksAttributesMap() bool

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

func (r *CRD) UpdateConditionsCustomMethodName() string

UpdateConditionsCustomMethodName returns custom update conditions operation as *string for custom resource

type CustomShape added in v0.15.2

type CustomShape struct {
	Shape           *awssdkmodel.Shape
	ShapeRef        *awssdkmodel.ShapeRef
	MemberShapeName *string
	ValueShapeName  *string
}

CustomShape represents a shape created by the generator that does not exist in the standard AWS SDK models.

func NewCustomListShape added in v0.15.2

func NewCustomListShape(shape *awssdkmodel.Shape, ref *awssdkmodel.ShapeRef, memberShapeName string) *CustomShape

NewCustomListShape creates a custom shape object for a new list.

func NewCustomMapShape added in v0.15.2

func NewCustomMapShape(shape *awssdkmodel.Shape, ref *awssdkmodel.ShapeRef, valueShapeName string) *CustomShape

NewCustomMapShape creates a custom shape object for a new map.

type EnumDef

type EnumDef struct {
	Names  names.Names
	Values []EnumValue
}

EnumDef is the definition of an enumeration type for a field present in either a CRD or a TypeDef

func NewEnumDef

func NewEnumDef(names names.Names, values []string) (*EnumDef, error)

NewEnumDef returns a pointer to an `ackmodel.EnumDef` struct representing a constrained string value field

type EnumValue

type EnumValue struct {
	Original string
	Clean    string
}

type Field

type Field struct {
	// CRD is the a pointer to the top-level custom resource definition
	// descriptor for the field or field's parent (if a nested field)
	CRD *CRD
	// Names is a set of normalized names for the field
	Names names.Names
	// Path is a "field path" that indicates where the field is within the CRD.
	// For example "Spec.Name" or "Status.BrokerInstances..Endpoint". Note for
	// the latter example, the field path indicates that the field `Endpoint`
	// is an attribute of the `Status.BrokerInstances` top-level field and the
	// double dot (`..` indicates that BrokerInstances is a list type).
	Path string
	// GoType is a string containing the Go data type for the field
	GoType string
	// GoTypeElem indicates the Go data type for the type of list element if
	// the field is a list type
	GoTypeElem        string
	GoTypeWithPkgName string
	ShapeRef          *awssdkmodel.ShapeRef
	FieldConfig       *ackgenconfig.FieldConfig

	// MemberFields is a map, keyed by the *renamed, cleaned, camel-cased name* of
	// member fields when this Field is a struct type.
	MemberFields map[string]*Field
}

Field represents a single field in the CRD's Spec or Status objects. The field may be a direct field of the Spec or Status object or may be a field of a list or struct-type field of the Spec or Status object. We call these latter fields "nested fields" and they are identified by the Field.Path attribute.

func NewField added in v0.2.0

func NewField(
	crd *CRD,
	path string,
	fieldNames names.Names,
	shapeRef *awssdkmodel.ShapeRef,
	cfg *ackgenconfig.FieldConfig,
) *Field

NewField returns a pointer to a new Field object

func NewReferenceField added in v0.16.0

func NewReferenceField(
	crd *CRD,
	fieldNames names.Names,
	shapeRef *awssdkmodel.ShapeRef,
) *Field

NewReferenceField returns a pointer to a new Field object. The go-type of field is either slice of '*AWSResourceReferenceWrapper' or '*AWSResourceReferenceWrapper' depending on whether 'shapeRef' parameter has 'list' type or not, respectively

func (*Field) FieldPathWithUnderscore added in v0.18.2

func (f *Field) FieldPathWithUnderscore() string

FieldPathWithUnderscore replaces the period in fieldPath with underscore. This method is useful for generating go method name from the fieldPath.

func (*Field) GetDocumentation added in v0.25.0

func (f *Field) GetDocumentation() string

GetDocumentation returns a string containing the field's description/docstring. The ShapeRef from the AWS SDK is used as the default value for the documentation of the field. If a documentation override has been provided (in the `documentation.yaml`) file, then it will either be prependend or appended, or entirely overridden.

For example, if there is a field with a ShapeRef that has a Documentation string containing:

"// This field contains the identifier for the cluster

running the cache services"

and the field has a documentation config specifies the following should be appended:

"please note that this field is updated on the service

side"

then the string returned from this method will be:

"// This field contains the identifier for the cluster

// running the cache services
// please note that this field is updated on the service
// side"

func (*Field) GetFieldDocsConfig added in v0.27.0

func (f *Field) GetFieldDocsConfig() *ackgenconfig.FieldDocsConfig

GetFieldDocsConfig returns the field documentation configuration for the current field if it exists, otherwise it returns nil.

func (*Field) GetGoTag added in v0.29.0

func (f *Field) GetGoTag() string

GetGoTag returns the json tag for the field. If the field has a FieldConfig with a GoTag attribute, the value of GoTag is returned. Otherwise, we evaluate the field type and return the appropriate json tag.

func (*Field) GetReferenceFieldName added in v0.16.4

func (f *Field) GetReferenceFieldName() names.Names

GetReferenceFieldName returns the corresponding Reference field name Reference field name is generated by removing the identifier suffix like 'Id', 'Arn', 'Name' etc and adding 'Ref(s)' as suffix.

func (*Field) GetSetterConfig added in v0.16.0

func (f *Field) GetSetterConfig(opType OpType) *ackgenconfig.SetFieldConfig

GetSetterConfig returns the SetFieldConfig object associated with this field and a supplied operation type, or nil if none exists.

func (*Field) HasReference added in v0.16.0

func (f *Field) HasReference() bool

HasReference returns true if the supplied field *path* refers to a Field that contains 'ReferencesConfig' i.e. has a corresponding reference field. Ex: ``` Integration:

fields:
  ApiId:
    references:
      resource: API
      path: Status.APIID

``` For the above configuration, 'HasReference' for 'ApiId'(Original name) field will return true because a corresponding 'APIRef' field will be generated by ACK code-generator

func (*Field) IsReference added in v0.16.0

func (f *Field) IsReference() bool

IsReference returns true if the Field has type '*ackv1alpha1.AWSResourceReferenceWrapper' or '[]*ackv1alpha1.AWSResourceReferenceWrapper'. These fields are not part of aws-sdk-go model and they are generated by ACK code-generator to accept references of other resource(s).

func (*Field) IsRequired

func (f *Field) IsRequired() bool

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

func (*Field) ReferenceFieldPath added in v0.18.2

func (f *Field) ReferenceFieldPath() string

ReferenceFieldPath returns the fieldPath for the corresponding Reference field. It replaces the fieldName with ReferenceFieldName at the end of fieldPath

func (*Field) ReferencedResourceNamePlural added in v0.17.1

func (f *Field) ReferencedResourceNamePlural() string

ReferencedResourceNamePlural returns the plural of referenced resource when the field has a 'ReferencesConfig' If the field does not have 'ReferencesConfig', empty string is returned

func (*Field) ReferencedServiceName added in v0.17.1

func (f *Field) ReferencedServiceName() (referencedServiceName string)

ReferencedServiceName returns the serviceName for the referenced resource when the field has 'ReferencesConfig' If the field does not have 'ReferencesConfig', empty string is returned

type Model added in v0.5.0

type Model struct {
	SDKAPI *SDKAPI
	// contains filtered or unexported fields
}

Model contains the ACK model for the generator to process and apply templates against.

func New added in v0.5.0

func New(
	SDKAPI *SDKAPI,
	servicePackageName string,
	apiVersion string,
	cfg ackgenconfig.Config,
	docCfg ackgenconfig.DocumentationConfig,
) (*Model, error)

New returns a new Model struct for a supplied API model. Optionally, pass a file path to a generator config file that can be used to instruct the code generator how to handle the API properly

func (*Model) APIGroup added in v0.15.0

func (m *Model) APIGroup() string

APIGroup returns the normalized Kubernetes APIGroup for the AWS service API, e.g. "sns.services.k8s.aws"

func (*Model) ApplyShapeIgnoreRules added in v0.5.0

func (m *Model) ApplyShapeIgnoreRules()

ApplyShapeIgnoreRules removes the ignored shapes and fields from the API object so that they are not considered in any of the calculations of code generator.

func (*Model) ClientInterfaceTypeName added in v0.25.0

func (m *Model) ClientInterfaceTypeName() string

ClientInterfaceTypeName returns the name of the aws-sdk-go primary API interface type name.

func (*Model) ClientStructTypeName added in v0.25.0

func (m *Model) ClientStructTypeName() string

ClientStructTypeName returns the name of the aws-sdk-go primary client struct type name.

func (*Model) GetCRDs added in v0.5.0

func (m *Model) GetCRDs() ([]*CRD, error)

GetCRDs returns a slice of `CRD` structs that describe the top-level resources discovered by the code generator for an AWS service API

func (*Model) GetConfig added in v0.5.0

func (m *Model) GetConfig() *ackgenconfig.Config

GetConfig returns the configuration option used to define the current generator.

func (*Model) GetEnumDefs added in v0.5.0

func (m *Model) GetEnumDefs() ([]*EnumDef, error)

GetEnumDefs returns a slice of pointers to `EnumDef` structs which represent string fields whose value is constrained to one or more specific string values.

func (*Model) GetTypeDefs added in v0.5.0

func (m *Model) GetTypeDefs() ([]*TypeDef, error)

GetTypeDefs returns a slice of `TypeDef` pointers

func (*Model) IsShapeUsedInCRDs added in v0.5.0

func (m *Model) IsShapeUsedInCRDs(shapeName string) bool

IsShapeUsedInCRDs returns true if the supplied shape name is a member of amy CRD's payloads or those payloads sub-member shapes

func (*Model) MetaVars added in v0.5.0

func (m *Model) MetaVars() templateset.MetaVars

MetaVars returns a MetaVars struct populated with metadata about the AWS service API

func (*Model) RemoveIgnoredOperations added in v0.5.0

func (m *Model) RemoveIgnoredOperations(ops *Ops)

RemoveIgnoredOperations updates Ops argument by setting those operations to nil that are configured to be ignored in generator config for the AWS service

type OpType

type OpType int
const (
	OpTypeUnknown OpType = iota
	OpTypeCreate
	OpTypeCreateBatch
	OpTypeDelete
	OpTypeReplace
	OpTypeUpdate
	OpTypeAddChild
	OpTypeAddChildren
	OpTypeRemoveChild
	OpTypeRemoveChildren
	OpTypeGet
	OpTypeList
	OpTypeGetAttributes
	OpTypeSetAttributes
)

func GetOpTypeAndResourceNameFromOpID

func GetOpTypeAndResourceNameFromOpID(
	opID string,
	cfg *ackgenconfig.Config,
) (OpType, string)

GetOpTypeAndResourceNameFromOpID guesses the resource name and type of operation from the OperationID

func OpTypeFromString

func OpTypeFromString(s string) OpType

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

type PrinterColumn struct {
	CRD      *CRD
	Name     string
	Type     string
	Priority int
	JSONPath string
	Index    int
}

PrinterColumn represents a single field in the CRD's Spec or Status objects

type SDKAPI

type SDKAPI struct {
	API            *awssdkmodel.API
	APIGroupSuffix string
	CustomShapes   []*CustomShape
	// contains filtered or unexported fields
}

SDKAPI contains an API model for a single AWS service API

func NewSDKAPI added in v0.15.2

func NewSDKAPI(api *awssdkmodel.API, apiGroupSuffix string) *SDKAPI

NewSDKAPI returns a pointer to a new `ackmodel.SDKAPI` struct that describes the AWS SDK API and its respective groupings, mappings and renamings.

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) ClientInterfaceTypeName added in v0.25.0

func (a *SDKAPI) ClientInterfaceTypeName() string

ClientInterfaceTypeName returns the name of the aws-sdk-go primary API interface type name.

func (*SDKAPI) ClientStructTypeName added in v0.25.0

func (a *SDKAPI) ClientStructTypeName() string

ClientStructTypeName returns the name of the aws-sdk-go primary API struct type name.

func (*SDKAPI) GetCustomShapeRef added in v0.15.2

func (a *SDKAPI) GetCustomShapeRef(shapeName string) *awssdkmodel.ShapeRef

GetCustomShapeRef finds a ShapeRef for a custom shape using either its member or its value shape name.

func (*SDKAPI) GetInputShapeRef

func (a *SDKAPI) GetInputShapeRef(
	opID string,
	path string,
) (*awssdkmodel.ShapeRef, bool)

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

func (a *SDKAPI) GetOutputShapeRef(
	opID string,
	path string,
) (*awssdkmodel.ShapeRef, bool)

GetOutputShapeRef finds a ShapeRef for a supplied member path (dot-notation) for given API operation

func (*SDKAPI) GetPayloads

func (a *SDKAPI) GetPayloads() []string

GetPayloads returns a slice of strings of Shape names representing input and output request/response payloads

func (*SDKAPI) GetServiceFullName

func (a *SDKAPI) GetServiceFullName() string

func (*SDKAPI) GetShapeRefFromType added in v0.16.2

func (a *SDKAPI) GetShapeRefFromType(
	typeOverride string,
) *awssdkmodel.ShapeRef

GetShapeRefFromType returns a ShapeRef given a string representing the Go type. If no shape can be determined, returns nil.

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) ServiceID

func (a *SDKAPI) ServiceID() string

ServiceID returns the exact `metadata.serviceId` attribute for the AWS service APi's api-2.json file. This MAY NOT MATCH the AWS SDK Go package used by the service. For example: AWS SDK Go uses `opensearchservice` whereas the service ID is `opensearch`

type TypeDef

type TypeDef struct {
	Names names.Names
	Attrs map[string]*Attr
	Shape *awssdkmodel.Shape
}

TypeDef is a Go type definition for structs that are member fields of the Spec or Status structs in Custom Resource Definitions (CRDs).

func (*TypeDef) GetAttribute added in v0.18.2

func (td *TypeDef) GetAttribute(attrName string) *Attr

GetAttribute returns the Attribute with name "attrName". This method performs case-insensitive matching to find the Attribute.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL