Documentation ¶
Index ¶
- type APIVersion
- type AdditionalColumnConfig
- type CompareConfig
- type CompareFieldConfig
- type Config
- func (c *Config) GetAPIVersions(crdName string) []APIVersion
- func (c *Config) GetAdditionalColumns(resourceName string) []*AdditionalColumnConfig
- func (c *Config) GetAllRenames(resourceName string, operations map[string]*awssdkmodel.Operation) map[string]string
- func (c *Config) GetCompareIgnoredFieldPaths(resourceName string) []string
- func (c *Config) GetCustomCheckRequiredFieldsMissingMethod(op *awssdkmodel.Operation) string
- func (c *Config) GetCustomDeleteMethodName(resourceName string) string
- func (c *Config) GetCustomFindMethodName(resourceName string) string
- func (c *Config) GetCustomImplementation(op *awssdkmodel.Operation) string
- func (c *Config) GetCustomListFieldMembers() []string
- func (c *Config) GetCustomMapFieldMembers() []string
- func (c *Config) GetCustomUpdateMethodName(resourceName string) string
- func (c *Config) GetFieldConfigByPath(resourceName string, fieldPath string) *FieldConfig
- func (c *Config) GetFieldConfigs(resourceName string) map[string]*FieldConfig
- func (c *Config) GetLateInitConfigByPath(resourceName string, fieldPath string) *LateInitializeConfig
- func (c *Config) GetLateInitConfigs(resourceName string) map[string]*LateInitializeConfig
- func (c *Config) GetListOpMatchFieldNames(resName string) []string
- func (c *Config) GetOperationConfig(opID string) (*OperationConfig, bool)
- func (c *Config) GetOriginalMemberName(resourceName string, opID string, fieldName string) string
- func (c *Config) GetOutputWrapperFieldPath(op *awssdkmodel.Operation) *string
- func (c *Config) GetOverrideValues(operationName string) (map[string]string, bool)
- func (c *Config) GetReconcileRequeueOnSuccessSeconds(resourceName string) int
- func (c *Config) GetResourceConfig(resourceName string) *ResourceConfig
- func (c *Config) GetResourceFieldName(resourceName string, opID string, origFieldName string) string
- func (c *Config) GetResourcePrintOrderByName(resourceName string) string
- func (c *Config) GetResourceShortNames(resourceName string) []string
- func (c *Config) GetSetOutputCustomMethodName(op *awssdkmodel.Operation) *string
- func (c *Config) GetTerminalExceptionCodes(resourceName string) []string
- func (c *Config) GetUpdateConditionsCustomMethodName(resourceName string) string
- func (c *Config) OperationIsIgnored(operation *awssdkmodel.Operation) bool
- func (c *Config) ResourceContainsAttributesMap(resourceName string) bool
- func (c *Config) ResourceDisplaysAgeColumn(resourceName string) bool
- func (c *Config) ResourceDisplaysSyncedColumn(resourceName string) bool
- func (c *Config) ResourceIsAdoptable(resourceName string) bool
- func (c *Config) ResourceIsIgnored(resourceName string) bool
- func (c *Config) ResourceSetsSingleAttribute(resourceName string) bool
- func (c *Config) TagsAreIgnored(resName string) bool
- type CustomFieldConfig
- type DeleteOperationsConfig
- type DocumentationConfig
- type ErrorConfig
- type ExceptionsConfig
- type FieldConfig
- type FieldDocsConfig
- type GetAttributesInputConfig
- type HooksConfig
- type IgnoreSpec
- type LateInitializeConfig
- type ListOperationConfig
- type MemberConstructorConfig
- type OperationConfig
- type OperationRenamesConfig
- type PrefixConfig
- type PrintConfig
- type PrintFieldConfig
- type ReadOperationsConfig
- type ReconcileConfig
- type ReferencesConfig
- type RenamesConfig
- type ResourceConfig
- type ResourceDocsConfig
- type SDKNames
- type SetFieldConfig
- type SourceFieldConfig
- type StringArray
- type SyncedCondition
- type SyncedConfig
- type TagConfig
- type UnpackAttributesMapConfig
- type UpdateOperationConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIVersion ¶
type APIVersion struct { // Name of the API version, e.g. v1beta1 Name string `json:"name"` // Served whether this version is enabled or not Served *bool `json:"served,omitempty"` // Storage whether this version is the storage version. // One and only one version can be set as the storage version. Storage *bool `json:"storage,omitempty"` }
APIVersion represents an API version of the generated CRD.
type AdditionalColumnConfig ¶ added in v0.21.0
type AdditionalColumnConfig struct { // Name is the thing to display in the column's output. Name string `json:"name"` // JSONPath defines the source of the output. JSONPath string `json:"json_path"` // Type is the OpenAPI type of the output. // c.f., https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types Type string `json:"type"` // Priority of the column in the resource's output. Priority int `json:"priority,omitempty"` // Index is the zero-based index of the position at which to display the column in output. Index int `json:"index,omitempty"` }
AdditionalColumnConfig can be used to specify additional printer columns to be included in a Resource's output from kubectl.
type CompareConfig ¶
type CompareConfig struct { // Ignore is a list of field paths to ignore when comparing two objects Ignore []string `json:"ignore"` }
CompareConfig informs instruct the code generator on how to compare two different two objects of the same type
type CompareFieldConfig ¶
type CompareFieldConfig struct { // IsIgnored indicates the field should be ignored when comparing a // resource IsIgnored bool `json:"is_ignored"` // NilEqualsZeroValue indicates a nil pointer and zero-value pointed-to // value should be considered equal for the purposes of comparison NilEqualsZeroValue bool `json:"nil_equals_zero_value"` }
CompareFieldConfig informs the code generator how to compare two values of a field
type Config ¶
type Config struct { // Resources contains generator instructions for individual CRDs within an // API Resources map[string]ResourceConfig `json:"resources"` // CRDs to ignore. ACK generator would skip these resources. Ignore IgnoreSpec `json:"ignore"` // Contains generator instructions for individual API operations. Operations map[string]OperationConfig `json:"operations"` // PrefixConfig contains the prefixes to access certain fields in the generated // Go code. PrefixConfig PrefixConfig `json:"prefix_config,omitempty"` // IncludeACKMetadata lets you specify whether ACK Metadata should be included // in the status. Default is true. IncludeACKMetadata bool `json:"include_ack_metadata,omitempty"` // SetManyOutputNotFoundErrReturn is the return statement when generated // SetManyOutput function fails with NotFound error. // Default is "return nil, ackerr.NotFound" SetManyOutputNotFoundErrReturn string `json:"set_many_output_notfound_err_return,omitempty"` // SDKNames lets you specify SDK object names. This configuration field was // introduces when we learned that the EventBridgePipes service renamed, not // only the service model name, but also the iface name to `PipesAPI`. See // https://github.com/aws/aws-sdk-go/blob/main/service/pipes/pipesiface/interface.go#L62 SDKNames SDKNames `json:"sdk_names"` }
Config represents instructions to the ACK code generator for a particular AWS service API
func (*Config) GetAPIVersions ¶ added in v0.19.0
func (c *Config) GetAPIVersions(crdName string) []APIVersion
GetAPIVersions returns the API version(s) for a CRD
func (*Config) GetAdditionalColumns ¶ added in v0.21.0
func (c *Config) GetAdditionalColumns(resourceName string) []*AdditionalColumnConfig
GetAdditionalColumns extracts AdditionalColumns defined for a given Resource
func (*Config) GetAllRenames ¶ added in v0.19.0
func (c *Config) GetAllRenames( resourceName string, operations map[string]*awssdkmodel.Operation, ) map[string]string
GetAllRenames returns all of the CRD's field renames observed in the generator config for a given map of operations.
func (*Config) GetCompareIgnoredFieldPaths ¶ added in v0.19.0
GetCompareIgnoredFieldPaths returns the list of field paths to ignore when comparing two different objects
func (*Config) GetCustomCheckRequiredFieldsMissingMethod ¶ added in v0.19.0
func (c *Config) GetCustomCheckRequiredFieldsMissingMethod( op *awssdkmodel.Operation, ) string
GetCustomCheckRequiredFieldsMissingMethod returns custom check required fields missing method as string for custom resource, if specified in generator config
func (*Config) GetCustomDeleteMethodName ¶ added in v0.29.0
func (*Config) GetCustomFindMethodName ¶ added in v0.29.0
func (*Config) GetCustomImplementation ¶ added in v0.19.0
func (c *Config) GetCustomImplementation( op *awssdkmodel.Operation, ) string
GetCustomImplementation returns custom implementation method name for the supplied operation as specified in generator config
func (*Config) GetCustomListFieldMembers ¶
GetCustomListFieldMembers finds all of the custom list fields that need to be generated as defined in the generator config.
func (*Config) GetCustomMapFieldMembers ¶
GetCustomMapFieldMembers finds all of the custom map fields that need to be generated as defined in the generator config.
func (*Config) GetCustomUpdateMethodName ¶ added in v0.19.0
GetCustomUpdateMethodName returns the name of the custom resourceManager method for updating the resource state, if any has been specified in the generator config
func (*Config) GetFieldConfigByPath ¶ added in v0.19.0
func (c *Config) GetFieldConfigByPath(resourceName string, fieldPath string) *FieldConfig
GetFieldConfigByPath returns the FieldConfig provided a resource and path to associated field.
func (*Config) GetFieldConfigs ¶ added in v0.19.0
func (c *Config) GetFieldConfigs(resourceName string) map[string]*FieldConfig
GetFieldConfigs returns all FieldConfigs for a given resource as a map. The map is keyed by the resource's field paths
func (*Config) GetLateInitConfigByPath ¶ added in v0.19.0
func (c *Config) GetLateInitConfigByPath(resourceName string, fieldPath string) *LateInitializeConfig
GetLateInitConfigByPath returns the LateInitializeConfig provided a resource and path to associated field.
func (*Config) GetLateInitConfigs ¶ added in v0.19.0
func (c *Config) GetLateInitConfigs(resourceName string) map[string]*LateInitializeConfig
GetLateInitConfigs returns all LateInitializeConfigs for a given resource as a map. The map is keyed by the resource's field names after applying renames, if applicable.
func (*Config) GetListOpMatchFieldNames ¶ added in v0.19.0
GetListOpMatchFieldNames 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 (*Config) GetOperationConfig ¶ added in v0.19.0
func (c *Config) GetOperationConfig(opID string) (*OperationConfig, bool)
OperationConfig returns the OperationConfig for a given operation
func (*Config) GetOriginalMemberName ¶ added in v0.23.0
func (c *Config) GetOriginalMemberName( resourceName string, opID string, fieldName string, ) string
GetOriginalMemberName returns the original struct member name within an Input or Output shape given a resource and field name. This accounts for any renames that may have occurred. It is the reverse of the Config.GetResourceFieldName method.
func (*Config) GetOutputWrapperFieldPath ¶ added in v0.19.0
func (c *Config) GetOutputWrapperFieldPath( op *awssdkmodel.Operation, ) *string
GetOutputWrapperFieldPath returns the JSON-Path of the output wrapper field as *string for a given operation, if specified in generator config.
func (*Config) GetOverrideValues ¶ added in v0.19.0
OverrideValues returns a list of member values to override for a given operation
func (*Config) GetReconcileRequeueOnSuccessSeconds ¶ added in v0.19.0
GetReconcileRequeueOnSuccessSeconds returns the duration after which to requeue the custom resource as int, if specified in generator config.
func (*Config) GetResourceConfig ¶ added in v0.19.0
func (c *Config) GetResourceConfig(resourceName string) *ResourceConfig
GetResourceConfig returns the ResourceConfig for a given resource name, searching case-insensitively.
func (*Config) GetResourceFieldName ¶ added in v0.19.0
func (c *Config) GetResourceFieldName( resourceName string, opID string, origFieldName string, ) string
GetResourceFieldName returns a resource field name after applying rename overrides, if configured
func (*Config) GetResourcePrintOrderByName ¶
GetResourcePrintOrderByName returns the Printer Column order-by field name
func (*Config) GetResourceShortNames ¶ added in v0.19.0
GetResourceShortNames returns the CRD list of aliases
func (*Config) GetSetOutputCustomMethodName ¶ added in v0.19.0
func (c *Config) GetSetOutputCustomMethodName( op *awssdkmodel.Operation, ) *string
GetSetOutputCustomMethodName returns custom set output operation as *string for given operation on custom resource, if specified in generator config
func (*Config) GetTerminalExceptionCodes ¶ added in v0.19.0
GetTerminalExceptionCodes returns terminal exception codes as []string for custom resource, if specified in generator config
func (*Config) GetUpdateConditionsCustomMethodName ¶ added in v0.19.0
GetUpdateConditionsCustomMethodName returns custom update conditions operation as *string for custom resource, if specified in generator config
func (*Config) OperationIsIgnored ¶ added in v0.19.0
func (c *Config) OperationIsIgnored(operation *awssdkmodel.Operation) bool
OperationIsIgnored returns true if Operation Name is configured to be ignored in generator config for the AWS service
func (*Config) ResourceContainsAttributesMap ¶ added in v0.19.0
ResourceContainsAttributesMap 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 a given resource name (see SNS and SQS APIs)
func (*Config) ResourceDisplaysAgeColumn ¶ added in v0.19.0
ResourceDisplaysAgeColumn returns true if the resource is configured to display resource age (created since date)
func (*Config) ResourceDisplaysSyncedColumn ¶ added in v0.19.0
ResourceDisplaysSyncedColumn returns true if the resource is configured to display the synced status.
func (*Config) ResourceIsAdoptable ¶
ResourceIsAdoptable returns true if resource name is configured to be adoptable. Default behavior is every resource can be adopted using AdoptionReconciler
func (*Config) ResourceIsIgnored ¶ added in v0.19.0
ResourceIsIgnored returns true if resource name is configured to be ignored in generator config for the AWS service
func (*Config) ResourceSetsSingleAttribute ¶ added in v0.19.0
ResourceSetsSingleAttribute 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 (*Config) TagsAreIgnored ¶ added in v0.19.0
TagsAreIgnored returns whether ensuring controller tags should be ignored for a resource or not.
type CustomFieldConfig ¶
type CustomFieldConfig struct { // ListOf provides the name of the SDK shape which will become the // member of a custom slice field. ListOf string `json:"list_of,omitempty"` // MapOf provides the name of the SDK shape which will become the value // shape for a custom map field. All maps will have `string` as their key // type. MapOf string `json:"map_of,omitempty"` }
CustomField instructs the code generator to create a new list or map field type using a shape that exists in the SDK.
type DeleteOperationsConfig ¶ added in v0.29.0
type DeleteOperationsConfig struct { // CustomMethodName is a string for the method name to replace the // sdkDelete() method implementation for this resource CustomMethodName string `json:"custom_method_name"` }
DeleteOperationsConfig contains instructions for the code generator to handle custom delete operations for service APIs that have resources that have difficult-to-standardize delete operations.
type DocumentationConfig ¶ added in v0.27.0
type DocumentationConfig struct {
Resources map[string]*ResourceDocsConfig `json:"resources,omitempty"`
}
DocumentationConfig represents the configuration of the documentation file, used to override or append documentation to any of the resource fields
func NewDocumentationConfig ¶ added in v0.27.0
func NewDocumentationConfig( configPath string, ) (DocumentationConfig, error)
NewDocumentationConfig returns a new DocumentationConfig object given a supplied path to a config file
type ErrorConfig ¶
type ErrorConfig struct { // Code corresponds to name of Exception returned by AWS API. // In AWS Go SDK terms - awsErr.Code() Code string `json:"code"` // MessagePrefix is an optional string field to be checked as prefix of the // exception message in addition to exception name. This is needed for HTTP codes // where the exception name alone is not sufficient to determine the type of error. // Example: SageMaker service throws ValidationException if job does not exist // as well as if IAM role does not have sufficient permission to fetch the dataset // For the former controller should proceed with creation of job whereas the // later is a terminal state. // In Go SDK terms - awsErr.Message() MessagePrefix *string `json:"message_prefix,omitempty"` // MessageSuffix is an optional string field to be checked as suffix of the // exception message in addition to exception name. This is needed for HTTP codes // where the exception name alone is not sufficient to determine the type of error. // Example: SageMaker service throws ValidationException if job does not exist // as well as if IAM role does not have sufficient permission to fetch the dataset // For the former controller should proceed with creation of job whereas the // later is a terminal state. // In Go SDK terms - awsErr.Message() MessageSuffix *string `json:"message_suffix,omitempty"` }
ErrorConfig contains instructions to the code generator about the exception corresponding to a HTTP status code
type ExceptionsConfig ¶
type ExceptionsConfig struct { // Errors is a map of HTTP status code to information about the Exception // that corresponds to that HTTP status code for this resource Errors map[int]ErrorConfig `json:"errors"` // Set of aws exception codes that are terminal exceptions for this resource TerminalCodes []string `json:"terminal_codes"` }
ExceptionsConfig contains instructions to the code generator about how to handle the exceptions for the operations on a resource. These instructions are necessary for those APIs where the API models do not contain any information about the HTTP status codes a particular exception has (or, like the EC2 API, where the API model has no information at all about error responses for any operation)
type FieldConfig ¶
type FieldConfig struct { // IsAttribute informs the code generator that this field is part of an // "Attributes Map". // // Some resources for some service APIs follow a pattern or using an // "Attributes" `map[string]*string` that contains real, schema'd fields of // the primary resource, and that those fields should be "unpacked" from // the raw map and into CRD's Spec and Status struct fields. IsAttribute bool `json:"is_attribute"` // IsReadOnly indicates the field's value can not be set by a Kubernetes // user; in other words, the field should go in the CR's Status struct IsReadOnly bool `json:"is_read_only"` // Required indicates whether this field is a required member or not. // This field is used to configure '+kubebuilder:validation:Required' on API object's members. IsRequired *bool `json:"is_required,omitempty"` // IsPrimaryKey indicates the field represents the primary name/string // identifier field for the resource. This allows the generator config to // override the default behaviour of considering a field called "Name" or // "{Resource}Name" or "{Resource}Id" as the "name field" for the resource. IsPrimaryKey bool `json:"is_primary_key"` // IsOwnerAccountID indicates the field contains the AWS Account ID // that owns the resource. This is a special field that we direct to // storage in the common `Status.ACKResourceMetadata.OwnerAccountID` field. IsOwnerAccountID bool `json:"is_owner_account_id"` // IsARN indicates the field represents the ARN for the resource. // This allows the generator config to override the // default behaviour of considering a field called "Arn" or // "{Resource}Arn" (case in-sensitive) as the "ARN field" for the resource. IsARN bool `json:"is_arn"` // IsSecret instructs the code generator that this field should be a // SecretKeyReference. IsSecret bool `json:"is_secret"` // IsImmutable instructs the code generator to add advisory conditions // if user modifies the spec field after resource was created. IsImmutable bool `json:"is_immutable"` // From instructs the code generator that the value of the field should // be retrieved from the specified operation and member path From *SourceFieldConfig `json:"from,omitempty"` // CustomField instructs the code generator to create a new field that does // not exist in the SDK. CustomField *CustomFieldConfig `json:"custom_field,omitempty"` // Compare instructs the code generator how to produce code that compares // the value of the field in two resources Compare *CompareFieldConfig `json:"compare,omitempty"` // Set contains instructions for the code generator how to deal with // fields where the Go type of the same-named fields in an Output shape is // different from the Go type of the Input shape. Set []*SetFieldConfig `json:"set"` // Print instructs the code generator how to generate comment markers that // influence hows field are printed in `kubectl get` response. If this field // is not nil, it will be added to the columns of `kubectl get`. Print *PrintFieldConfig `json:"print,omitempty"` // Late Initialize instructs the code generator how to handle the late initialization // of the field. LateInitialize *LateInitializeConfig `json:"late_initialize,omitempty"` // References instructs the code generator how to refer this field from // other custom resource References *ReferencesConfig `json:"references,omitempty"` // Type *overrides* the inferred Go type of the field. This is required for // custom fields that are not inferred either as a Create Input/Output // shape or via the SourceFieldConfig attribute. // // As an example, assume you have a Role resource where you want to add a // custom spec field called Policies that is a slice of string pointers. // The generator.yaml file might look like this: // // resources: // Role: // fields: // Policies: // type: []*string // // TODO(jaypipes,crtbry): Figure out if we can roll the CustomShape stuff // into this type override... Type *string `json:"type,omitempty"` // GoTag is used to override the default Go tag injected into the fields of // a generated go structure. This is useful if we want to override the json // tag name or add an omitempty directive to the tag. If not specified, // the default json tag is used, i.e. json:"<fieldName>,omitempty" // // The main reason behind introducing this feature is that, our naming utility // package appends an underscore suffix to the field name if it is colliding with // a Golang keyword (switch, if, else etc...). This is needed to avoid violating // the Go language spec, when defining package names, variable names, etc. // This functionality resulted in injecting the underscore suffix to the json tag // as well, e.g. json:"type_,omitempty". Which is not ideal because it weirdens // the experience for the users of the generated CRDs. // // One could argue that we should just modify the `names“ package to return an // extra field indicating whether the field name is a Go keyword or not, or even // better, return the correct go tag dirrctly. The reason why we should avoid // such a change is that it would modify the already existing/generated code, which // would break the compatibility for the existing CRDs. Without introducing some // sort of mutating webhook to handle field name change, this is not a viable. // We decided to introduce this feature to, at least, allow us to override the // go tag for any new resource or fields that we generate in the future. // // (See https://github.com/aws-controllers-k8s/pkg/blob/main/names/names.go) GoTag *string `json:"go_tag,omitempty"` }
FieldConfig contains instructions to the code generator about how to interpret the value of an Attribute and how to map it to a CRD's Spec or Status field
type FieldDocsConfig ¶ added in v0.27.0
type FieldDocsConfig struct { // Append specifies a string that will be added to the end of the existing // GoDoc comment for the field Append *string `json:"append,omitempty"` // Prepend specifies a string that will be added before the existing // GoDoc comment for the field Prepend *string `json:"prepend,omitempty"` // Override will entirely replace the GoDoc comment for the field Override *string `json:"override,omitempty"` }
FieldDocsConfig represents the configuration for the documentation overrides of a single field
type GetAttributesInputConfig ¶
type GetAttributesInputConfig struct { // Overrides is a map of structures instructing the code generator how to // handle the override of a particular field in the Input shape for the // GetAttributes operation. The map keys are the names of the field in the // Input shape to override. Overrides map[string]*MemberConstructorConfig `json:"overrides"` }
GetAttributesInputConfig is used to instruct the code generator how to handle the GetAttributes API operation's Input shape.
type HooksConfig ¶
type HooksConfig struct { // Code is the Go code to be injected at the hook point Code *string `json:"code,omitempty"` // TemplatePath is a path to the template containing the hook code TemplatePath *string `json:"template_path,omitempty"` }
HooksConfig instructs the code generator how to inject custom callback hooks at various places in the resource manager and SDK linkage code.
Example usage from the AmazonMQ generator config:
resources:
Broker: hooks: sdk_update_pre_build_request: code: if err := rm.requeueIfNotRunning(latest); err != nil { return nil, err }
Note that the implementor of the AmazonMQ service controller for ACK should ensure that there is a `requeueIfNotRunning()` method implementation in `pkg/resource/broker`
Instead of placing Go code directly into the generator.yaml file using the `code` field, you can reference a template file containing Go code with the `template_path` field:
resources:
Broker: hooks: sdk_update_pre_build_update_request: template_path: templates/sdk_update_pre_build_request.go.tpl
type IgnoreSpec ¶
type IgnoreSpec struct { // Set of operation IDs/names that should be ignored by the // generator when constructing SDK linkage Operations []string `json:"operations"` // Set of resource names that should be ignored by the // generator ResourceNames []string `json:"resource_names"` // Set of shapes to ignore when constructing API type definitions and // associated SDK code for structs that have these shapes as members ShapeNames []string `json:"shape_names"` // Set of field paths to ignore. The name here should be the original name of // the field as it appears in AWS SDK objects. You can refer to a field by // giving its "<shape_name>.<field_name>". For example, "CreateApiInput.Name". FieldPaths []string `json:"field_paths"` }
IgnoreSpec represents instructions to the ACK code generator to ignore operations, resources on an AWS service API
type LateInitializeConfig ¶
type LateInitializeConfig struct { // MinBackoffSeconds provides the minimum backoff to attempt late initialization again after an unsuccessful // attempt to late initialized fields from ReadOne output // For every attempt, the reconciler will calculate the delay between MinBackoffSeconds and MaxBackoffSeconds // using exponential backoff and retry strategy MinBackoffSeconds int `json:"min_backoff_seconds,omitempty"` // MaxBackoffSeconds provide the maximum allowed backoff when retrying late initialization after an // unsuccessful attempt. MaxBackoffSeconds int `json:"max_backoff_seconds"` }
LateInitializeConfig contains instructions for how to handle the retrieval and setting of server-side defaulted fields. NOTE: Currently the members of this have no effect on late initialization of fields. Currently the late initialization is requeued with static delay of 5 second. TODO: (vijat@) Add support of retry/backoff for late initialization.
type ListOperationConfig ¶
type ListOperationConfig struct { // MatchFields lists the names of fields in the Shape of the // list element in the List Operation's Output shape. MatchFields []string `json:"match_fields"` }
ListOperationConfig contains instructions for the code generator to handle List operations for service APIs that have no built-in filtering ability and whose List Operation always returns all objects.
type MemberConstructorConfig ¶
type MemberConstructorConfig struct { // Values contains the value or values of the member to always set the // member to. If the member's type is a []string, the member is set to the // Values list. If the type is a string, the member's value is set to the // first list element in the Values list. Values []string `json:"values"` }
MemberConstructorConfig contains override instructions for how to handle the construction of a particular member for a Shape in the API.
type OperationConfig ¶
type OperationConfig struct { CustomImplementation string `json:"custom_implementation,omitempty"` CustomCheckRequiredFieldsMissingMethod string `json:"custom_check_required_fields_missing_method,omitempty"` OverrideValues map[string]string `json:"override_values"` // SetOutputCustomMethodName provides the name of the custom method on the // `resourceManager` struct that will set fields on a `resource` struct // depending on the output of the operation. SetOutputCustomMethodName string `json:"set_output_custom_method_name,omitempty"` // OutputWrapperFieldPath provides the JSON-Path like to the struct field containing // information that will be merged into a `resource` object. OutputWrapperFieldPath string `json:"output_wrapper_field_path,omitempty"` // Override for resource name in case of heuristic failure // An example of this is correcting stutter when the resource logic doesn't properly determine the resource name ResourceName StringArray `json:"resource_name"` // Override for operation type in case of heuristic failure // An example of this is `Put...` or `Register...` API operations not being correctly classified as `Create` op type // OperationType []string `json:"operation_type"` OperationType StringArray `json:"operation_type"` }
OperationConfig represents instructions to the ACK code generator to specify the overriding values for API operation parameters and its custom implementation.
type OperationRenamesConfig ¶
type OperationRenamesConfig struct { // InputFields is a map of Input shape fields to renamed field name. InputFields map[string]string `json:"input_fields"` // OutputFields is a map of Output shape fields to renamed field name. OutputFields map[string]string `json:"output_fields"` }
OperationRenamesConfig contains instructions to the code generator on how to rename fields in an Operation's input and output payload shapes
type PrefixConfig ¶
type PrefixConfig struct { // SpecField stores the string prefix to use for information that will be // sent to AWS. Defaults to `.Spec` SpecField string `json:"spec_field,omitempty"` // StatusField stores the string prefix to use for information fetched from // AWS. Defaults to `.Status` StatusField string `json:"status_field,omitempty"` }
type PrintConfig ¶
type PrintConfig struct { // AddAgeColumn a boolean informing the code generator whether to append a kubebuilder // marker comment to show a resource Age (created since date) in `kubectl get` response. // The Age value is parsed from '.metadata.creationTimestamp'. // // NOTE: this is the Kubernetes resource Age (creation time at the api-server/etcd) // and not the AWS resource Age. AddAgeColumn bool `json:"add_age_column"` // AddSyncedColumn is used to append a kubebuilder marker comment to show the status of a // resource in `kubectl get` response. // // Default value is true. AddSyncedColumn *bool `json:"add_synced_column"` // OrderBy is the field used to sort the list of PrinterColumn options. OrderBy string `json:"order_by"` // AdditionalColumns can be used to add arbitrary extra columns to a Resource's output // if present, should be a list of objects, each containing: name, json_path, and type AdditionalColumns []*AdditionalColumnConfig `json:"additional_columns,omitempty"` }
PrintConfig informs instruct the code generator on how to sort kubebuilder printcolumn marker comments.
type PrintFieldConfig ¶
type PrintFieldConfig struct { // Name instructs the code generator to override the column name used to // include the field in `kubectl get` response. This field is generally used // to override very long and redundant columns names. Name string `json:"name"` // Priority differentiates between fields/columns shown in standard view or wide // view (using the -o wide flag). Fields with priority 0 are shown in standard view. // Fields with priority greater than 0 are only shown in wide view. Default is 0 Priority int `json:"priority"` // Index informs the code generator about the position/order of a specific field/column in // `kubectl get` response. To enable ordering by index, `$resource.print.orderBy` must be set // to `index` // The field with the smallest index will be right next to the first column (NAME). // The field with the biggest index will be positioned right before the last column (AGE). Index int `json:"index"` }
PrintFieldConfig instructs the code generator how to handle kubebuilder:printcolumn comment marker generation. If this struct is not nil, the field will be added to the columns of `kubectl get` response.
type ReadOperationsConfig ¶ added in v0.29.0
type ReadOperationsConfig struct { // CustomMethodName is a string for the method name to replace the // sdkFind() method implementation for this resource CustomMethodName string `json:"custom_method_name"` }
ReadOperationsConfig contains instructions for the code generator to handle custom read operations for service APIs that have resources that have difficult-to-standardize read operations.
type ReconcileConfig ¶
type ReconcileConfig struct { // RequeueOnSuccessSeconds indicates the number of seconds after which to requeue a // resource that has been successfully reconciled (i.e. ConditionTypeResourceSynced=true) // This is useful for resources that are long-lived and may have observable status fields // change over time that would be useful to refresh those field values for users. // This field is optional and the default behaviour of the ACK runtime is to not requeue // resources that have been successfully reconciled. Note that all ACK controllers will // *flush and resync their watch caches* every 10 hours by default, which will end up // causing ACK controllers to refresh the status views of all watched resources, but this // behaviour is expensive and may be turned off in future ACK runtime options. RequeueOnSuccessSeconds int `json:"requeue_on_success_seconds,omitempty"` }
ReconcileConfig describes options for controlling the reconciliation logic for a particular resource.
type ReferencesConfig ¶
type ReferencesConfig struct { // ServiceName mentions the AWS service name where "Resource" exists. // This field is used to generate the API Group for the "Resource". // // ServiceName is the go package name for AWS service in // aws-sdk-go/service/<package_name>/api.go // Ex: Use "opensearchservice" to refer "Domain" resource from // opensearchservice-controller because it is the go package name for // "aws-sdk-go/service/opensearchservice/api.go" // // When not specified, 'ServiceName' defaults to service name of controller // which contains generator.yaml ServiceName string `json:"service_name,omitempty"` // Resource mentions the K8s resource which is read to resolve the // reference Resource string `json:"resource"` // Path refers to the the path of field which should be copied // to resolve the reference Path string `json:"path"` }
ReferencesConfig contains the instructions for how to add the referenced resource configuration for a field. Example: ``` Integration:
fields: ApiId: references: resource: API path: Status.APIID
``` The above configuration will result in generation of a new field 'APIRef' of type 'AWSResourceReference' for ApiGatewayv2-Integration crd. When 'APIRef' field is present in custom resource manifest, reconciler will read the referred 'API' resource and copy the value from 'Status.APIID' in 'Integration' resource's 'APIID' field
type RenamesConfig ¶
type RenamesConfig struct { // Operations is a map, keyed by Operation ID, of instructions on how to // handle renamed fields in Input and Output shapes. Operations map[string]*OperationRenamesConfig `json:"operations"` }
RenamesConfig contains instructions to the code generator how to rename fields in various Operation payloads
type ResourceConfig ¶
type ResourceConfig struct { // UnpackAttributeMapConfig contains instructions for converting a raw // `map[string]*string` into real fields on a CRD's Spec or Status object UnpackAttributesMapConfig *UnpackAttributesMapConfig `json:"unpack_attributes_map,omitempty"` // Exceptions identifies the exception codes for the resource. Some API // model files don't contain the ErrorInfo struct that contains the // HTTPStatusCode attribute that we usually look for to identify 404 Not // Found and other common error types for primary resources, and thus we // need these instructions. Exceptions *ExceptionsConfig `json:"exceptions,omitempty"` // Hooks is a map, keyed by the hook identifier, of instructions for the // the code generator about a custom callback hooks that should be injected // into the resource's manager or SDK binding code. Hooks map[string]*HooksConfig `json:"hooks"` // Synced contains instructions for the code generator to generate Go code // that verifies whether a resource is synced or not. Synced *SyncedConfig `json:"synced"` // Renames identifies fields in Operations that should be renamed. Renames *RenamesConfig `json:"renames,omitempty"` // ListOperation contains instructions for the code generator to generate // Go code that filters the results of a List operation looking for a // singular object. Certain AWS services (e.g. S3's ListBuckets API) have // absolutely no way to pass a filter to the operation. Instead, the List // operation always returns ALL objects of that type. // // The ListOperationConfig object enables us to inject some custom code to // filter the results of these List operations from within the generated // code in sdk.go's sdkFind(). ListOperation *ListOperationConfig `json:"list_operation,omitempty"` // UpdateOperation contains instructions for the code generator to generate // Go code for the update operation for the resource. For some APIs, the // way that a resource's attributes are updated after creation is, well, // very odd. Some APIs have separate API calls for each attribute or set of // related attributes of the resource. For example, the ECR API has // separate API calls for PutImageScanningConfiguration, // PutImageTagMutability, PutLifecyclePolicy and SetRepositoryPolicy. FOr // these APIs, we basically need to revert to custom code because there's // very little consistency to the APIs that we can use to instruct the code // generator :( UpdateOperation *UpdateOperationConfig `json:"update_operation,omitempty"` // ReadOperation contains instructions for the code generator to generate // Go code for the read operation for the resource. For some resources, // there is no describe/find/list apis. However, it is possible to write // `read` function for such resources using another resource's (say, // resource B) `read` function. Then, one could write custom code to find // the relevant resource from the response of resource B's read function. // // Additionally, if the `read` function for a resource is not available // then reconciler's progression is stalled with the error `read` // operation `notImplemented`. Custom read function allows the // reconciler's progression. ReadOperation *ReadOperationsConfig `json:"find_operation,omitempty"` //DeleteOperation contains instructions for the code generator to generate // Go code for the delete operation for the resource. DeleteOperation *DeleteOperationsConfig `json:"delete_operation,omitempty"` // Reconcile describes options for controlling the reconciliation // logic for a particular resource. Reconcile *ReconcileConfig `json:"reconcile,omitempty"` // UpdateConditionsCustomMethodName provides the name of the custom method on the // `resourceManager` struct that will set Conditions on a `resource` struct // depending on the status of the resource. UpdateConditionsCustomMethodName string `json:"update_conditions_custom_method_name,omitempty"` // Fields is a map, keyed by the field name, of instructions for how the // code generator should interpret and handle a particular field in the // resource. Fields map[string]*FieldConfig `json:"fields"` // Compare contains instructions for the code generation to generate custom // comparison logic. Compare *CompareConfig `json:"compare,omitempty"` // ShortNames represent the CRD list of aliases. Short names allow shorter strings to // match a CR on the CLI. // All ShortNames must be distinct from any other ShortNames installed into the cluster, // otherwise the CRD will fail to install. ShortNames []string `json:"shortNames,omitempty"` // APIVersions represents the API versions defined for the generated CRD. // Default version to be used is the one specified via the "--version" // command-line argument, if none is specified here. // For the Crossplane pipeline, the generation target is the version // marked as the storage version. APIVersions []APIVersion `json:"api_versions,omitempty"` // IsAdoptable determines whether the CRD should be accepted by the adoption reconciler. // If set to false, the user will be given an error if they attempt to adopt a resource // with this type. IsAdoptable *bool `json:"is_adoptable,omitempty"` // Print contains instructions for the code generator to generate kubebuilder printcolumns // marker comments. Print *PrintConfig `json:"print,omitempty"` // IsARNPrimaryKey determines whether the CRD uses the ARN as the primary // identifier in the ReadOne operations. IsARNPrimaryKey bool `json:"is_arn_primary_key"` // TagConfig contains instructions for the code generator to generate // custom code for ensuring tags TagConfig *TagConfig `json:"tags,omitempty"` }
ResourceConfig represents instructions to the ACK code generator for a particular CRD/resource on an AWS service API
func (*ResourceConfig) GetFieldConfig ¶ added in v0.21.0
func (rc *ResourceConfig) GetFieldConfig(subject string) *FieldConfig
GetFieldConfig accepts a string name of a field and returns the FieldConfig object inside the ResourceConfig matching (case-insensitively) the supplied field name, or nil if that field has no FieldConfig.
type ResourceDocsConfig ¶ added in v0.27.0
type ResourceDocsConfig struct {
Fields map[string]*FieldDocsConfig `json:"fields,omitempty"`
}
ResourceDocsConfig represents the configuration for the documentation overrides of a single resource
type SDKNames ¶ added in v0.25.0
type SDKNames struct { // ModelName lets you specify the path used to identify the AWS service API // in the aws-sdk-go's models/apis/ directory. This field is optional and // only needed for services such as the opensearchservice service where the // model name is `opensearch` and the service package is called // `opensearchservice`. Model string `json:"model_name,omitempty"` // ClientInterface is the name of the interface that defines the "shape" of // the a sdk service client. e.g PipesAPI, LambdaAPI, etc... ClientInterface string `json:"client_interface,omitempty"` // ClientStruct is the name of the service client struct. e.g Lambda, Pipes, etc... ClientStruct string `json:"client_struct,omitempty"` }
SDKNames contains information on the SDK Client package. More precisely it holds information on how to correctly import the {service}/iface main interface and client structs.
type SetFieldConfig ¶
type SetFieldConfig struct { // Method is the resource manager method name whose Output shape will be // transformed by this config. If empty, this set field config applies to // all resource manager methods. // // Options: Create, Update, Delete or ReadOne Method *string `json:"method,omitempty"` // From tells the code generator to output Go code that sets the value of a // variable containing the target resource field with the contents of a // member field in the source struct. // // Consider the `DBInstance.Spec.DBSecurityGroups` field discussed above. // // If we have the following generator.yaml config: // // “`yaml // resources: // DBInstance: // fields: // DBSecurityGroups: // set: // - method: Create // from: DBSecurityGroupName // - method: ReadOne // from: DBSecurityGroupName // “` // // That will instruct the code generator to output this Go code when // processing the `*DBSecurityGroupMembership` struct elements of the // Output shape's DBSecurityGroups field: // // “`go // f17elem = *f17iter.DBSecurityGroupName // “` From *string `json:"from,omitempty"` // To instructs the code generator to output Go code that sets the value of // an Input sdkField with the content of a CR field. // // “`yaml // resources: // User: // fields: // URL: // set: // - method: Update // to: NewURL // “` To *string `json:"to,omitempty"` // Ignore instructs the code generator to ignore this field in the Output // shape when setting the value of the resource's field in the Spec. This // is useful when we know that, for example, the returned value of field in // an Output shape contains stale data, such as when the ElastiCache // ModifyReplicationGroup API's Output response shape contains the // originally-set value for the LogDeliveryConfiguration field that was // updated in the Input shape. // // See: https://github.com/aws-controllers-k8s/elasticache-controller/pull/59/ // // In the case of ElastiCache, we might have the following generator.yaml // config: // // “`yaml // resources: // ReplicationGroup: // fields: // LogDeliveryConfiguration: // set: // - method: Update // ignore: true // “` Ignore bool `json:"ignore,omitempty"` }
SetFieldConfig instructs the code generator how to handle setting the value of the field from an Output shape in the API response.
These instructions are necessary when the Go type for Input and Output fields is different.
For example, consider the `DBSecurityGroups` field for an RDS `DBInstance` resource.
The Create operation's Input shape's `DBSecurityGroups` field has a Go type of `[]*string` [0] because the user is expected to provide a list of DBSecurityGroup identifiers when creating the DBInstance.
However, the Output shape for both the Create and ReadOne operation uses a different Go type for the `DBSecurityGroups` field. For these Output shapes, the Go type is `[]*DBSecurityGroupMembership` [1]. The `DBSecurityGroupMembership` struct contains the DBSecurityGroup's name and "status".
The challenge that the ACK code generator has is to figure out how to take the Go type of the Output shape and process it into the Go type of the Input shape.
In other words, for the `DBInstance.Spec.DBSecurityGroups` field discussed above, we need to have the code generator produce the following Go code in the SetResource generator:
```go
if resp.DBInstance.DBSecurityGroups != nil { f17 := []*string{} for _, f17iter := range resp.DBInstance.DBSecurityGroups { var f17elem string f17elem = *f17iter.DBSecurityGroupName f17 = append(f17, &f17elem) } ko.Spec.DBSecurityGroupNames = f17 } else { ko.Spec.DBSecurityGroupNames = nil }
```
[0] https://github.com/aws/aws-sdk-go/blob/0a01aef9caf16d869c7340e729080205760dc2a2/models/apis/rds/2014-10-31/api-2.json#L2985 [1] https://github.com/aws/aws-sdk-go/blob/0a01aef9caf16d869c7340e729080205760dc2a2/models/apis/rds/2014-10-31/api-2.json#L3815
type SourceFieldConfig ¶
type SourceFieldConfig struct { // Operation refers to the ID of the API Operation where we will // determine the field's Go type. Operation string `json:"operation"` // Path refers to the field path of the member of the Input or Output // shape in the Operation identified by OperationID that we will take as // our additional spec/status field's value. Path string `json:"path"` }
SourceFieldConfig instructs the code generator how to handle a field in the Resource's SpecFields/StatusFields collection that takes its value from an abnormal source -- in other words, not the Create operation's Input or Output shape.
This additional field can source its value from a shape in a different API Operation entirely.
The data type (Go type) that a field is assigned during code generation depends on whether the field is part of the Create Operation's Input shape which go into the Resource's Spec fields collection, or the Create Operation's Output shape which, if not present in the Input shape, means the field goes into the Resource's Status fields collection).
Each Resource typically also has a ReadOne Operation. The ACK service controller will call this ReadOne Operation to get the latest observed state of a particular resource in the backend AWS API service. The service controller sets the observed Resource's Spec and Status fields from the Output shape of the ReadOne Operation. The code generator is responsible for producing the Go code that performs these "setter" methods on the Resource. The way the code generator determines how to set the Spec or Status fields from the Output shape's member fields is by looking at the data type of the Spec or Status field with the same name as the Output shape's member field.
Importantly, in producing this "setter" Go code the code generator **assumes that the data types (Go types) in the source (the Output shape's member field) and target (the Spec or Status field) are the same**.
There are some APIs, however, where the Go type of the field in the Create Operation's Input shape is actually different from the same-named field in the ReadOne Operation's Output shape. A good example of this is the Lambda CreateFunction API call, which has a `Code` member of its Input shape that looks like this:
"Code": { "ImageUri": "string", "S3Bucket": "string", "S3Key": "string", "S3ObjectVersion": "string", "ZipFile": blob },
The GetFunction API call's Output shape has a same-named field called `Code` in it, but this field looks like this:
"Code": { "ImageUri": "string", "Location": "string", "RepositoryType": "string", "ResolvedImageUri": "string" },
This presents a conundrum to the ACK code generator, which, as noted above, assumes the data types of same-named fields in the Create Operation's Input shape and ReadOne Operation's Output shape are the same.
The SourceFieldConfig struct allows us to explain to the code generator how to handle situations like this.
For the Lambda Function Resource's `Code` field, we can inform the code generator to create three new Status fields (readonly) from the `Location`, `RepositoryType` and `ResolvedImageUri` fields in the `Code` member of the ReadOne Operation's Output shape:
resources:
Function: fields: CodeLocation: is_read_only: true from: operation: GetFunction path: Code.Location CodeRepositoryType: is_read_only: true from: operation: GetFunction path: Code.RepositoryType CodeRegisteredImageURI: is_read_only: true from: operation: GetFunction path: Code.RegisteredImageUri
type StringArray ¶
type StringArray []string
StringArray is a type that can be represented in JSON as *either* a string *or* an array of strings
func (*StringArray) UnmarshalJSON ¶
func (a *StringArray) UnmarshalJSON(b []byte) error
UnmarshalJSON parses input for either a string or a list and returns a StringArray.
type SyncedCondition ¶
type SyncedCondition struct { // Path of the field. e.g Status.Processing Path *string `json:"path"` // In contains a list of possible values `Path` should be equal to. In []string `json:"in"` }
SyncedCondition represent one of the unique condition that should be fulfilled in order to assert whether a resource is synced.
type SyncedConfig ¶
type SyncedConfig struct { // When is a list of conditions that should be satisfied in order to tell whether a // a resource was synced or not. When []SyncedCondition `json:"when"` }
SyncedConfig instructs the code generator on how to generate functions that checks whether a resource was synced or not.
type TagConfig ¶ added in v0.19.0
type TagConfig struct { // Ignore is a boolean that indicates whether ensuring controller tags // should be ignored for a resource. For AWS resources which do not // support tagging, this should be set to True Ignore bool `json:"ignore,omitempty"` // Path represents the field path for the member which contains the tags Path *string `json:"path,omitempty"` // KeyMemberName is the name of field which represents AWS tag key inside tag // struct. This is only used for tag fields with shape as list of struct, // where the struct represents a single tag. KeyMemberName *string `json:"key_name,omitempty"` // ValueMemberName is the name of field which represents AWS tag value inside // tag struct. This is only used for tag fields with shape as list of struct, // where the struct represents a single tag. ValueMemberName *string `json:"value_name,omitempty"` }
TagConfig instructs the code generator on how to generate functions that ensure that controller tags are added to the AWS Resource
type UnpackAttributesMapConfig ¶
type UnpackAttributesMapConfig struct { // SetAttributesSingleAttribute indicates that the SetAttributes API call // doesn't actually set multiple attributes but rather must be called // multiple times, once for each attribute that needs to change. See SNS // SetTopicAttributes API call, which can be compared to the "normal" SNS // SetPlatformApplicationAttributes API call which accepts multiple // attributes and replaces the supplied attributes map key/values... SetAttributesSingleAttribute bool `json:"set_attributes_single_attribute"` // GetAttributesInput instructs the code generator how to handle the // GetAttributes input shape GetAttributesInput *GetAttributesInputConfig `json:"get_attributes_input,omitempty"` }
UnpackAttributesMapConfig informs the code generator that the API follows a pattern or using an "Attributes" `map[string]*string` that contains real, schema'd fields of the primary resource, and that those fields should be "unpacked" from the raw map and into CRD's Spec and Status struct fields.
AWS Simple Notification Service (SNS) and AWS Simple Queue Service (SQS) are examples of APIs that use this pattern. For instance, the SNS CreateTopic API accepts a parameter called "Attributes" that can contain one of four keys:
- DeliveryPolicy – The policy that defines how Amazon SNS retries failed deliveries to HTTP/S endpoints.
- DisplayName – The display name to use for a topic with SMS subscriptions
- Policy – The policy that defines who can access your topic.
- KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) for Amazon SNS or a custom CMK.
The `CreateTopic` API call **returns** only a single field: the TopicARN. But there is a separate `GetTopicAttributes` call that needs to be made that returns the above attributes (that are ReadWrite) along with a set of key/values that are ReadOnly:
- Owner – The AWS account ID of the topic's owner.
- SubscriptionsConfirmed – The number of confirmed subscriptions for the topic.
- SubscriptionsDeleted – The number of deleted subscriptions for the topic.
- SubscriptionsPending – The number of subscriptions pending confirmation for the topic.
- TopicArn – The topic's ARN.
- EffectiveDeliveryPolicy – The JSON serialization of the effective delivery policy, taking system defaults into account.
This structure instructs the code generator about the above real, schema'd fields that are masquerading as raw key/value pairs.
type UpdateOperationConfig ¶
type UpdateOperationConfig struct { // CustomMethodName is a string for the method name to replace the // sdkUpdate() method implementation for this resource CustomMethodName string `json:"custom_method_name"` // OmitUnchangedFields instructs the code generator on how to generate // `newUpdateRequestPayload` function. If the boolean is true, the code generator // will leverage `delta.DifferentAt` to check whether a field have changed or not // before including it in the update request. OmitUnchangedFields bool `json:"omit_unchanged_fields"` }
UpdateOperationConfig contains instructions for the code generator to handle Update operations for service APIs that have resources that have difficult-to-standardize update operations.