Documentation ¶
Index ¶
- Variables
- type AdditionalConnectionDetailsFn
- type BasePackages
- type DefaultResourceFn
- type ExternalName
- type GetExternalNameFn
- type GetIDFn
- type LateInitializer
- type NewInitializerFn
- type OperationTimeouts
- type Provider
- type ProviderOption
- type Reference
- type References
- type Resource
- type ResourceConfigurator
- type ResourceConfiguratorChain
- type ResourceConfiguratorFn
- type ResourceOption
- type Sensitive
- type SetIdentifierArgumentsFn
- type Tagger
Constants ¶
This section is empty.
Variables ¶
var ( // NameAsIdentifier uses "name" field in the arguments as the identifier of // the resource. NameAsIdentifier = ExternalName{ SetIdentifierArgumentFn: func(base map[string]interface{}, name string) { base["name"] = name }, GetExternalNameFn: IDAsExternalName, GetIDFn: ExternalNameAsID, OmittedFields: []string{ "name", "name_prefix", }, } // IdentifierFromProvider is used in resources whose identifier is assigned by // the remote client, such as AWS VPC where it gets an identifier like // vpc-2213das instead of letting user choose a name. IdentifierFromProvider = ExternalName{ SetIdentifierArgumentFn: NopSetIdentifierArgument, GetExternalNameFn: IDAsExternalName, GetIDFn: ExternalNameAsID, DisableNameInitializer: true, } DefaultBasePackages = BasePackages{ APIVersion: []string{ "apis/v1alpha1", }, Controller: []string{ "internal/controller/providerconfig", }, } // NopSensitive does nothing. NopSensitive = Sensitive{ AdditionalConnectionDetailsFn: NopAdditionalConnectionDetails, } )
Commonly used resource configurations.
Functions ¶
This section is empty.
Types ¶
type AdditionalConnectionDetailsFn ¶
AdditionalConnectionDetailsFn functions adds custom keys to connection details secret using input terraform attributes
type BasePackages ¶
BasePackages keeps lists of base packages that needs to be registered as API and controllers. Typically, we expect to see ProviderConfig packages here.
type DefaultResourceFn ¶
type DefaultResourceFn func(name string, terraformResource *schema.Resource, opts ...ResourceOption) *Resource
DefaultResourceFn returns a default resource configuration to be used while building resource configurations.
type ExternalName ¶
type ExternalName struct { // SetIdentifierArgumentFn sets the name of the resource in Terraform argument // map. In many cases, there is a field called "name" in the HCL schema, however, // there are cases like RDS DB Cluster where the name field in HCL is called // "cluster_identifier". This function is the place that you can take external // name and assign it to that specific key for that resource type. SetIdentifierArgumentFn SetIdentifierArgumentsFn // GetExternalNameFn returns the external name extracted from TF State. In most cases, // "id" field contains all the information you need. You'll need to extract // the format that is decided for external name annotation to use. // For example the following is an Azure resource ID: // /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1 // The function should return "mygroup1" so that it can be used to set external // name if it was not set already. GetExternalNameFn GetExternalNameFn // GetIDFn returns the string that will be used as "id" key in TF state. In // many cases, external name format is the same as "id" but when it is not // we may need information from other places to construct it. For example, // the following is an Azure resource ID: // /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1 // The function here should use information from supplied arguments to // construct this ID, i.e. "mygroup1" from external name, subscription ID // from providerConfig, and others from parameters map if needed. GetIDFn GetIDFn // OmittedFields are the ones you'd like to be removed from the schema since // they are specified via external name. For example, if you set // "cluster_identifier" in SetIdentifierArgumentFn, then you need to omit // that field. // You can omit only the top level fields. // No field is omitted by default. OmittedFields []string // DisableNameInitializer allows you to specify whether the name initializer // that sets external name to metadata.name if none specified should be disabled. // It needs to be disabled for resources whose external identifier is randomly // assigned by the provider, like AWS VPC where it gets vpc-21kn123 identifier // and not let you name it. DisableNameInitializer bool }
ExternalName contains all information that is necessary for naming operations, such as removal of those fields from spec schema and calling Configure function to fill attributes with information given in external name.
type GetExternalNameFn ¶
GetExternalNameFn returns the external name extracted from the TF State.
type GetIDFn ¶
type GetIDFn func(ctx context.Context, externalName string, parameters map[string]interface{}, providerConfig map[string]interface{}) (string, error)
GetIDFn returns the ID to be used in TF State file, i.e. "id" field in terraform.tfstate.
type LateInitializer ¶
type LateInitializer struct { // IgnoredFields are the field paths to be skipped during // late-initialization. Similar to other configurations, these paths are // Terraform field paths concatenated with dots. For example, if we want to // ignore "ebs" block in "aws_launch_template", we should add // "block_device_mappings.ebs". IgnoredFields []string // contains filtered or unexported fields }
LateInitializer represents configurations that control late-initialization behaviour
func (*LateInitializer) AddIgnoredCanonicalFields ¶
func (l *LateInitializer) AddIgnoredCanonicalFields(cf string)
AddIgnoredCanonicalFields sets ignored canonical fields
func (*LateInitializer) GetIgnoredCanonicalFields ¶
func (l *LateInitializer) GetIgnoredCanonicalFields() []string
GetIgnoredCanonicalFields returns the ignoredCanonicalFields
type NewInitializerFn ¶ added in v0.4.0
type NewInitializerFn func(client client.Client) managed.Initializer
NewInitializerFn returns the Initializer with a client.
var TagInitializer NewInitializerFn = func(client client.Client) managed.Initializer { return NewTagger(client, "tags") }
TagInitializer returns a tagger to use default tag initializer.
type OperationTimeouts ¶
type OperationTimeouts struct { Read time.Duration Create time.Duration Update time.Duration Delete time.Duration }
OperationTimeouts allows configuring resource operation timeouts: https://www.terraform.io/language/resources/syntax#operation-timeouts Please note that, not all resources support configuring timeouts.
type Provider ¶
type Provider struct { // TerraformResourcePrefix is the prefix used in all resources of this // Terraform provider, e.g. "aws_". Defaults to "<prefix>_". This is being // used while setting some defaults like Kind of the resource. For example, // for "aws_rds_cluster", we drop "aws_" prefix and its group ("rds") to set // Kind of the resource as "Cluster". TerraformResourcePrefix string // RootGroup is the root group that all CRDs groups in the provider are based // on, e.g. "aws.jet.crossplane.io". // Defaults to "<TerraformResourcePrefix>.jet.crossplane.io". RootGroup string // ShortName is the short name of the provider. Typically, added as a CRD // category, e.g. "awsjet". Default to "<prefix>jet". For more details on CRD // categories, see: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#categories ShortName string // ModulePath is the go module path for the Crossplane provider repo, e.g. // "github.com/crossplane-contrib/provider-jet-aws" ModulePath string // BasePackages keeps lists of base packages that needs to be registered as // API and controllers. Typically, we expect to see ProviderConfig packages // here. BasePackages BasePackages // DefaultResourceFn is a function that returns resource configuration to be // used as default while building the resources. DefaultResourceFn DefaultResourceFn // SkipList is a list of regex for the Terraform resources to be skipped. // For example, to skip generation of "aws_shield_protection_group", one // can add "aws_shield_protection_group$". To skip whole aws waf group, one // can add "aws_waf.*" to the list. SkipList []string // IncludeList is a list of regex for the Terraform resources to be // included. For example, to include "aws_shield_protection_group" into // the generated resources, one can add "aws_shield_protection_group$". // To include whole aws waf group, one can add "aws_waf.*" to the list. // Defaults to []string{".+"} which would include all resources. IncludeList []string // Resources is a map holding resource configurations where key is Terraform // resource name. Resources map[string]*Resource // contains filtered or unexported fields }
Provider holds configuration for a provider to be generated with Terrajet.
func NewProvider ¶
func NewProvider(resourceMap map[string]*schema.Resource, prefix string, modulePath string, opts ...ProviderOption) *Provider
NewProvider builds and returns a new Provider. Deprecated: This function will be removed soon, please use NewProviderWithSchema instead.
func NewProviderWithSchema ¶ added in v0.4.0
func NewProviderWithSchema(schema []byte, prefix string, modulePath string, opts ...ProviderOption) *Provider
NewProviderWithSchema builds and returns a new Provider from provider tfjson schema, that is generated using Terraform CLI with: `terraform providers schema --json`
func (*Provider) AddResourceConfigurator ¶
func (p *Provider) AddResourceConfigurator(resource string, c ResourceConfiguratorFn)
AddResourceConfigurator adds resource specific configurators.
func (*Provider) ConfigureResources ¶
func (p *Provider) ConfigureResources()
ConfigureResources configures resources with provided ResourceConfigurator's
func (*Provider) SetResourceConfigurator ¶
func (p *Provider) SetResourceConfigurator(resource string, c ResourceConfigurator)
SetResourceConfigurator sets ResourceConfigurator for a resource. This will override all previously added ResourceConfigurators for this resource.
type ProviderOption ¶
type ProviderOption func(*Provider)
A ProviderOption configures a Provider.
func WithBasePackages ¶
func WithBasePackages(b BasePackages) ProviderOption
WithBasePackages configures BasePackages for this Provider.
func WithDefaultResourceFn ¶
func WithDefaultResourceFn(f DefaultResourceFn) ProviderOption
WithDefaultResourceFn configures DefaultResourceFn for this Provider
func WithIncludeList ¶
func WithIncludeList(l []string) ProviderOption
WithIncludeList configures IncludeList for this Provider.
func WithRootGroup ¶
func WithRootGroup(s string) ProviderOption
WithRootGroup configures RootGroup for resources of this Provider.
func WithShortName ¶
func WithShortName(s string) ProviderOption
WithShortName configures ShortName for resources of this Provider.
func WithSkipList ¶
func WithSkipList(l []string) ProviderOption
WithSkipList configures SkipList for this Provider.
type Reference ¶
type Reference struct { // Type is the type name of the CRD if it is in the same package or // <package-path>.<type-name> if it is in a different package. Type string // Extractor is the function to be used to extract value from the // referenced type. Defaults to getting external name. // Optional Extractor string // RefFieldName is the field name for the Reference field. Defaults to // <field-name>Ref or <field-name>Refs. // Optional RefFieldName string // SelectorFieldName is the field name for the Selector field. Defaults to // <field-name>Selector. // Optional SelectorFieldName string }
Reference represents the Crossplane options used to generate reference resolvers for fields
type References ¶
References represents reference resolver configurations for the fields of a given resource. Key should be the field path of the field to be referenced.
type Resource ¶
type Resource struct { // Name is the name of the resource type in Terraform, // e.g. aws_rds_cluster. Name string // TerraformResource is the Terraform representation of the resource. TerraformResource *schema.Resource // ShortGroup is the short name of the API group of this CRD. The full // CRD API group is calculated by adding the group suffix of the provider. // For example, ShortGroup could be `ec2` where group suffix of the // provider is `aws.crossplane.io` and in that case, the full group would // be `ec2.aws.crossplane.io` ShortGroup string // Version is the version CRD will have. Version string // Kind is the kind of the CRD. Kind string // UseAsync should be enabled for resource whose creation and/or deletion // takes more than 1 minute to complete such as Kubernetes clusters or // databases. UseAsync bool InitializerFns []NewInitializerFn // OperationTimeouts allows configuring resource operation timeouts. OperationTimeouts OperationTimeouts // ExternalName allows you to specify a custom ExternalName. ExternalName ExternalName // References keeps the configuration to build cross resource references References References // Sensitive keeps the configuration to handle sensitive information Sensitive Sensitive // LateInitializer configuration to control late-initialization behaviour LateInitializer LateInitializer }
Resource is the set of information that you can override at different steps of the code generation pipeline.
func DefaultResource ¶
func DefaultResource(name string, terraformSchema *schema.Resource, opts ...ResourceOption) *Resource
DefaultResource keeps an initial default configuration for all resources of a provider.
type ResourceConfigurator ¶
type ResourceConfigurator interface {
Configure(r *Resource)
}
ResourceConfigurator configures a Resource
type ResourceConfiguratorChain ¶
type ResourceConfiguratorChain []ResourceConfigurator
A ResourceConfiguratorChain chains multiple ResourceConfigurators.
func (ResourceConfiguratorChain) Configure ¶
func (cc ResourceConfiguratorChain) Configure(r *Resource)
Configure configures a resource by calling each ResourceConfigurator in the chain serially.
type ResourceConfiguratorFn ¶
type ResourceConfiguratorFn func(r *Resource)
ResourceConfiguratorFn is a function that implements the ResourceConfigurator interface
func (ResourceConfiguratorFn) Configure ¶
func (c ResourceConfiguratorFn) Configure(r *Resource)
Configure configures a resource by calling ResourceConfiguratorFn
type ResourceOption ¶
type ResourceOption func(*Resource)
ResourceOption allows setting optional fields of a Resource object.
type Sensitive ¶
type Sensitive struct { // AdditionalConnectionDetailsFn is the path for function adding additional // connection details keys AdditionalConnectionDetailsFn AdditionalConnectionDetailsFn // contains filtered or unexported fields }
Sensitive represents configurations to handle sensitive information
func (*Sensitive) AddFieldPath ¶
AddFieldPath adds the given tf path and xp path to the fieldPaths map.
func (*Sensitive) GetFieldPaths ¶
GetFieldPaths returns the fieldPaths map for Sensitive
type SetIdentifierArgumentsFn ¶
SetIdentifierArgumentsFn sets the name of the resource in Terraform attributes map, i.e. Main HCL file.
var NopSetIdentifierArgument SetIdentifierArgumentsFn = func(_ map[string]interface{}, _ string) {}
NopSetIdentifierArgument does nothing. It's useful for cases where the external name is calculated by provider and doesn't have any effect on spec fields.
type Tagger ¶ added in v0.4.0
type Tagger struct {
// contains filtered or unexported fields
}
Tagger implements the Initialize function to set external tags
func (*Tagger) Initialize ¶ added in v0.4.0
Initialize is a custom initializer for setting external tags