Documentation ¶
Index ¶
- Constants
- Variables
- func GetExternalNameFromTemplated(tmpl, val string) (string, error)
- func GetSchema(sch *schema.Resource, fieldpath string) *schema.Schema
- func ManipulateEveryField(r *schema.Resource, op func(sch *schema.Schema))
- func MarkAsRequired(sch *schema.Resource, fieldpaths ...string)
- func MoveToStatus(sch *schema.Resource, fieldpaths ...string)
- type AdditionalConnectionDetailsFn
- type BasePackages
- type ConfigurationInjector
- type CustomDiff
- type ExternalName
- type ExternalNameFrom
- type ExternalNameFromOption
- func WithGetExternalNameFn(fn func(fn GetExternalNameFn, tfstate map[string]any) (string, error)) ExternalNameFromOption
- func WithGetIDFn(...) ExternalNameFromOption
- func WithSetIdentifierArgumentsFn(fn func(fn SetIdentifierArgumentsFn, base map[string]any, externalName string)) ExternalNameFromOption
- type GetExternalNameFn
- type GetIDFn
- type InjectedKey
- type LateInitializer
- type ListMapKeys
- type ListMergeStrategy
- type ListType
- type MapType
- type MergeStrategy
- type Mode
- type NewInitializerFn
- type OperationTimeouts
- type Provider
- type ProviderOption
- func WithBasePackages(b BasePackages) ProviderOption
- func WithDefaultResourceOptions(opts ...ResourceOption) ProviderOption
- func WithFeaturesPackage(s string) ProviderOption
- func WithIncludeList(l []string) ProviderOption
- func WithMainTemplate(template string) ProviderOption
- func WithReferenceInjectors(refInjectors []ReferenceInjector) ProviderOption
- func WithRootGroup(s string) ProviderOption
- func WithSchemaTraversers(traversers ...traverser.SchemaTraverser) ProviderOption
- func WithShortName(s string) ProviderOption
- func WithSkipList(l []string) ProviderOption
- func WithTerraformPluginFrameworkIncludeList(l []string) ProviderOption
- func WithTerraformPluginFrameworkProvider(tp fwprovider.Provider) ProviderOption
- func WithTerraformPluginSDKIncludeList(l []string) ProviderOption
- func WithTerraformProvider(tp *schema.Provider) ProviderOption
- type Reference
- type ReferenceInjector
- type References
- type Resource
- func (r *Resource) AddSingletonListConversion(tfPath, crdPath string)
- func (r *Resource) ApplyTFConversions(params map[string]any, mode Mode) (map[string]any, error)
- func (r *Resource) CRDHubVersion() string
- func (r *Resource) CRDListConversionPaths() []string
- func (r *Resource) CRDStorageVersion() string
- func (r *Resource) MarkAsRequired(fieldpaths ...string)
- func (r *Resource) RequiredFields() []string
- func (r *Resource) SetCRDHubVersion(v string)
- func (r *Resource) SetCRDStorageVersion(v string)
- func (r *Resource) ShouldUseTerraformPluginFrameworkClient() bool
- func (r *Resource) ShouldUseTerraformPluginSDKClient() bool
- func (r *Resource) TFListConversionPaths() []string
- type ResourceConfigurator
- type ResourceConfiguratorChain
- type ResourceConfiguratorFn
- type ResourceOption
- type ResourceSetter
- type SchemaElementOption
- type SchemaElementOptions
- type Sensitive
- type ServerSideApplyMergeStrategies
- type SetIdentifierArgumentsFn
- type SingletonListEmbedder
- type StructType
- type Tagger
- type TerraformConversion
Constants ¶
const ( // PackageNameConfig is the name of the provider subpackage that contains // the base resources (e.g., ProviderConfig, ProviderConfigUsage, // StoreConfig. etc.). // TODO: we should be careful that there may also exist short groups with // these names. We can consider making these configurable by the provider // maintainer. PackageNameConfig = "config" // PackageNameMonolith is the name of the backwards-compatible // provider subpackage that contains the all the resources. PackageNameMonolith = "monolith" )
Variables ¶
var ( DefaultBasePackages = BasePackages{ APIVersion: []string{ "apis/v1alpha1", "apis/v1beta1", }, Controller: []string{ "internal/controller/providerconfig", }, ControllerMap: map[string]string{ "internal/controller/providerconfig": PackageNameConfig, }, } // NopSensitive does nothing. NopSensitive = Sensitive{ AdditionalConnectionDetailsFn: NopAdditionalConnectionDetails, } )
Commonly used resource configurations.
var ( // NameAsIdentifier uses "name" field in the arguments as the identifier of // the resource. NameAsIdentifier = ExternalName{ SetIdentifierArgumentFn: func(base map[string]any, 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, } )
Functions ¶
func GetExternalNameFromTemplated ¶
GetExternalNameFromTemplated takes a Terraform ID and the template it's produced from and reverse it to get the external name. For example, you can supply "/subscription/{{ .paramters.some }}/{{ .external_name }}" with "/subscription/someval/myname" and get "myname" returned.
func GetSchema ¶
GetSchema returns the schema of the field whose fieldpath is given. Returns nil if Schema is not found at the specified path.
func ManipulateEveryField ¶
ManipulateEveryField manipulates all fields in the schema by input function.
func MarkAsRequired ¶
MarkAsRequired marks the schema of the given fieldpath as required. It's most useful in cases where external name contains an optional parameter that is defaulted by the provider but we need it to exist or to fix plain buggy schemas. Deprecated: Use Resource.MarkAsRequired instead. This function will be removed in future versions.
func MoveToStatus ¶
MoveToStatus moves given fields and their leaf fields to the status as a whole. It's used mostly in cases where there is a field that is represented as a separate CRD, hence you'd like to remove that field from spec.
Types ¶
type AdditionalConnectionDetailsFn ¶
AdditionalConnectionDetailsFn functions adds custom keys to connection details secret using input terraform attributes
type BasePackages ¶
type BasePackages struct { APIVersion []string // Deprecated: Use ControllerMap instead. Controller []string ControllerMap map[string]string }
BasePackages keeps lists of packages that needs to be registered as API and controllers. Typically, we expect to see ProviderConfig packages here. These APIs and controllers belong to non-generated (manually maintained) resources.
type ConfigurationInjector ¶
ConfigurationInjector is a function that injects Terraform configuration values from the specified managed resource into the specified configuration map. jsonMap is the map obtained by converting the `spec.forProvider` using the JSON tags and tfMap is obtained by using the TF tags.
func CanonicalizeJSONParameters ¶ added in v1.1.1
func CanonicalizeJSONParameters(tfPath ...string) ConfigurationInjector
CanonicalizeJSONParameters returns a ConfigurationInjector that computes and stores the canonical forms of the JSON documents for the specified list of top-level Terraform configuration arguments. Please note that currently only top-level configuration arguments are supported by this function.
type CustomDiff ¶
type CustomDiff func(diff *terraform.InstanceDiff, state *terraform.InstanceState, config *terraform.ResourceConfig) (*terraform.InstanceDiff, error)
CustomDiff customizes the computed Terraform InstanceDiff. This can be used in cases where, for example, changes in a certain argument should just be dismissed. The new InstanceDiff is returned along with any errors.
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 terraformProviderConfig, 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 // IdentifierFields are the fields that are used to construct external // resource identifier. We need to know these fields no matter what the // management policy is including the Observe Only, different from other // (required) fields. IdentifierFields []string }
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.
func NewExternalNameFrom ¶ added in v1.1.1
func NewExternalNameFrom(parent ExternalName, opts ...ExternalNameFromOption) ExternalName
NewExternalNameFrom initializes a new ExternalNameFrom with the given parent and with the given options. An example configuration that uses a TemplatedStringAsIdentifier as its parent (base) and sets a default value for the external-name if the external-name is yet not populated is as follows:
config.NewExternalNameFrom(config.TemplatedStringAsIdentifier("", "{{ .parameters.type }}/{{ .setup.client_metadata.account_id }}/{{ .external_name }}"),
config.WithGetIDFn(func(fn config.GetIDFn, ctx context.Context, externalName string, parameters map[string]any, terraformProviderConfig map[string]any) (string, error) { if externalName == "" { externalName = "some random string" } return fn(ctx, externalName, parameters, terraformProviderConfig) }))
func ParameterAsIdentifier ¶
func ParameterAsIdentifier(param string) ExternalName
ParameterAsIdentifier uses the given field name in the arguments as the identifier of the resource.
func TemplatedStringAsIdentifier ¶
func TemplatedStringAsIdentifier(nameFieldPath, tmpl string) ExternalName
TemplatedStringAsIdentifier accepts a template as the shape of the Terraform ID and lets you provide a field path for the argument you're using as external name. The available variables you can use in the template are as follows:
parameters: A tree of parameters that you'd normally see in a Terraform HCL file. You can use TF registry documentation of given resource to see what's available.
setup.configuration: The Terraform configuration object of the provider. You can take a look at the TF registry provider configuration object to see what's available. Not to be confused with ProviderConfig custom resource of the Crossplane provider.
setup.client_metadata: The Terraform client metadata available for the provider, such as the AWS account ID for the AWS provider.
external_name: The value of external name annotation of the custom resource. It is required to use this as part of the template.
The following template functions are available:
ToLower: Converts the contents of the pipeline to lower-case
ToUpper: Converts the contents of the pipeline to upper-case
Please note that it's currently *not* possible to use the template functions on the .external_name template variable. Example usages:
TemplatedStringAsIdentifier("index_name", "/subscriptions/{{ .setup.configuration.subscription }}/{{ .external_name }}")
TemplatedStringAsIdentifier("index_name", "/resource/{{ .external_name }}/static")
TemplatedStringAsIdentifier("index_name", "{{ .parameters.cluster_id }}:{{ .parameters.node_id }}:{{ .external_name }}")
TemplatedStringAsIdentifier("", "arn:aws:network-firewall:{{ .setup.configuration.region }}:{{ .setup.client_metadata.account_id }}:{{ .parameters.type | ToLower }}-rulegroup/{{ .external_name }}")
type ExternalNameFrom ¶ added in v1.1.1
type ExternalNameFrom struct { ExternalName // contains filtered or unexported fields }
ExternalNameFrom is an ExternalName configuration which uses a parent configuration as its base and modifies any of the GetIDFn, GetExternalNameFn or SetIdentifierArgumentsFn. This enables us to reuse the existing ExternalName configurations with modifications in their behaviors via compositions.
type ExternalNameFromOption ¶ added in v1.1.1
type ExternalNameFromOption func(from *ExternalNameFrom)
ExternalNameFromOption is an option that modifies the behavior of an ExternalNameFrom external-name configuration.
func WithGetExternalNameFn ¶ added in v1.1.1
func WithGetExternalNameFn(fn func(fn GetExternalNameFn, tfstate map[string]any) (string, error)) ExternalNameFromOption
WithGetExternalNameFn sets the GetExternalNameFn for the ExternalNameFrom configuration. The function parameter fn receives the parent ExternalName's GetExternalNameFn, and implementations may invoke the parent's GetExternalNameFn via this parameter. For the description of the rest of the parameters and return values, please see the documentation of GetExternalNameFn.
func WithGetIDFn ¶ added in v1.1.1
func WithGetIDFn(fn func(fn GetIDFn, ctx context.Context, externalName string, parameters map[string]any, terraformProviderConfig map[string]any) (string, error)) ExternalNameFromOption
WithGetIDFn sets the GetIDFn for the ExternalNameFrom configuration. The function parameter fn receives the parent ExternalName's GetIDFn, and implementations may invoke the parent's GetIDFn via this parameter. For the description of the rest of the parameters and return values, please see the documentation of GetIDFn.
func WithSetIdentifierArgumentsFn ¶ added in v1.1.1
func WithSetIdentifierArgumentsFn(fn func(fn SetIdentifierArgumentsFn, base map[string]any, externalName string)) ExternalNameFromOption
WithSetIdentifierArgumentsFn sets the SetIdentifierArgumentsFn for the ExternalNameFrom configuration. The function parameter fn receives the parent ExternalName's SetIdentifierArgumentsFn, and implementations may invoke the parent's SetIdentifierArgumentsFn via this parameter. For the description of the rest of the parameters and return values, please see the documentation of SetIdentifierArgumentsFn.
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]any, terraformProviderConfig map[string]any) (string, error)
GetIDFn returns the ID to be used in TF State file, i.e. "id" field in terraform.tfstate.
type InjectedKey ¶ added in v1.1.0
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 // ConditionalIgnoredFields are the field paths to be skipped during // late-initialization if they are filled in spec.initProvider. ConditionalIgnoredFields []string // contains filtered or unexported fields }
LateInitializer represents configurations that control late-initialization behaviour
func (*LateInitializer) AddConditionalIgnoredCanonicalFields ¶ added in v1.4.0
func (l *LateInitializer) AddConditionalIgnoredCanonicalFields(cf string)
AddConditionalIgnoredCanonicalFields sets conditional ignored canonical fields
func (*LateInitializer) AddIgnoredCanonicalFields ¶
func (l *LateInitializer) AddIgnoredCanonicalFields(cf string)
AddIgnoredCanonicalFields sets ignored canonical fields
func (*LateInitializer) GetConditionalIgnoredCanonicalFields ¶ added in v1.4.0
func (l *LateInitializer) GetConditionalIgnoredCanonicalFields() []string
GetConditionalIgnoredCanonicalFields returns the conditionalIgnoredCanonicalFieldPaths
func (*LateInitializer) GetIgnoredCanonicalFields ¶
func (l *LateInitializer) GetIgnoredCanonicalFields() []string
GetIgnoredCanonicalFields returns the ignoredCanonicalFields
type ListMapKeys ¶ added in v1.1.0
type ListMapKeys struct { // InjectedKey can be used to inject the specified index key // into the generated CRD schema for the list object when // the SSA merge strategy for the parent list is `map`. // If a non-zero `InjectedKey` is specified, then a field of type string with // the specified name is injected into the Terraform schema and used as // a list map key together with any other existing keys specified in `Keys`. InjectedKey InjectedKey // Keys is the set of list map keys to be used while SSA merges list items. // If InjectedKey is non-zero, then it's automatically put into Keys and // you must not specify the InjectedKey in Keys explicitly. Keys []string }
ListMapKeys is the list map keys when the server-side apply merge strategy islistType=map.
type ListMergeStrategy ¶ added in v1.1.0
type ListMergeStrategy struct { // ListMapKeys is the list map keys when the SSA merge strategy is // `listType=map`. The keys specified here must be a set of scalar Terraform // argument names to be used as the list map keys for the object list. ListMapKeys ListMapKeys // MergeStrategy is the SSA merge strategy for an object list. Valid values // are: `atomic`, `set` and `map` MergeStrategy ListType }
ListMergeStrategy configures the corresponding field as list and configures its server-side apply merge strategy.
type ListType ¶ added in v1.1.0
type ListType string
A ListType is a type of list.
const ( // ListTypeAtomic means the entire list is replaced during merge. At any // point in time, a single manager owns the list. ListTypeAtomic ListType = "atomic" // ListTypeSet can be granularly merged, and different managers can own // different elements in the list. The list can include only scalar // elements. ListTypeSet ListType = "set" // ListTypeMap can be granularly merged, and different managers can own // different elements in the list. The list can include only nested types // (i.e. objects). ListTypeMap ListType = "map" )
Types of lists.
type MergeStrategy ¶ added in v1.1.0
type MergeStrategy struct { ListMergeStrategy ListMergeStrategy MapMergeStrategy MapType StructMergeStrategy StructType }
MergeStrategy configures the server-side apply merge strategy for the corresponding field. One and only one of the pointer members can be set and the specified merge strategy configuration must match the field's type, e.g., you cannot set MapMergeStrategy for a field of type list.
type Mode ¶ added in v1.4.0
type Mode int
Mode denotes the mode of the runtime Terraform conversion, e.g., conversion from Crossplane parameters to Terraform arguments, or conversion from Terraform state to Crossplane state.
type NewInitializerFn ¶
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.upbound.io". // Defaults to "<TerraformResourcePrefix>.upbound.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/upbound/provider-aws" ModulePath string // FeaturesPackage is the relative package patch for the features package to // configure the features behind the feature gates. FeaturesPackage 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 // DefaultResourceOptions is a list of config.ResourceOption that will be // applied to all resources before any user-provided options are applied. DefaultResourceOptions []ResourceOption // 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 // MainTemplate is the template string to be used to render the // provider subpackage main program. If this is set, the generated provider // is broken up into subpackage families partitioned across the API groups. // A monolithic provider is also generated to // ensure backwards-compatibility. MainTemplate string // IncludeList is a list of regex for the Terraform resources to be // included and reconciled via the Terraform CLI. // 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 // TerraformPluginSDKIncludeList is a list of regex for the Terraform resources // implemented with Terraform Plugin SDKv2 to be included and reconciled // in the no-fork architecture (without the Terraform CLI). // 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. TerraformPluginSDKIncludeList []string // TerraformPluginFrameworkIncludeList is a list of regex for the Terraform // resources implemented with Terraform Plugin Framework to be included and // reconciled in the no-fork architecture (without the Terraform CLI). // 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. TerraformPluginFrameworkIncludeList []string // Resources is a map holding resource configurations where key is Terraform // resource name. Resources map[string]*Resource // TerraformProvider is the Terraform provider in Terraform Plugin SDKv2 // compatible format TerraformProvider *schema.Provider // TerraformPluginFrameworkProvider is the Terraform provider reference // in Terraform Plugin Framework compatible format TerraformPluginFrameworkProvider fwprovider.Provider // contains filtered or unexported fields }
Provider holds configuration for a provider to be generated with Upjet.
func NewProvider ¶
func NewProvider(schema []byte, prefix string, modulePath string, metadata []byte, opts ...ProviderOption) *Provider
NewProvider 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) GetSkippedResourceNames ¶
GetSkippedResourceNames returns a list of Terraform resource names available in the Terraform provider schema, but not in the include list or in the skip list, meaning that the corresponding managed resources are not generated.
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 WithDefaultResourceOptions ¶
func WithDefaultResourceOptions(opts ...ResourceOption) ProviderOption
WithDefaultResourceOptions configures DefaultResourceOptions for this Provider.
func WithFeaturesPackage ¶
func WithFeaturesPackage(s string) ProviderOption
WithFeaturesPackage configures FeaturesPackage for this Provider.
func WithIncludeList ¶
func WithIncludeList(l []string) ProviderOption
WithIncludeList configures IncludeList for this Provider.
func WithMainTemplate ¶
func WithMainTemplate(template string) ProviderOption
WithMainTemplate configures the provider family main module file's path. This template file will be used to generate the main modules of the family's members.
func WithReferenceInjectors ¶
func WithReferenceInjectors(refInjectors []ReferenceInjector) ProviderOption
WithReferenceInjectors configures an ordered list of `ReferenceInjector`s for this Provider. The configured reference resolvers are executed in order to inject cross-resource references across this Provider's resources.
func WithRootGroup ¶
func WithRootGroup(s string) ProviderOption
WithRootGroup configures RootGroup for resources of this Provider.
func WithSchemaTraversers ¶ added in v1.4.0
func WithSchemaTraversers(traversers ...traverser.SchemaTraverser) ProviderOption
WithSchemaTraversers configures a chain of schema traversers to be used with this Provider configuration. Schema traversers can be used to inspect or modify the Provider configuration based on the underlying Terraform resource schemas.
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.
func WithTerraformPluginFrameworkIncludeList ¶ added in v1.1.0
func WithTerraformPluginFrameworkIncludeList(l []string) ProviderOption
WithTerraformPluginFrameworkIncludeList configures the TerraformPluginFrameworkIncludeList for this Provider, with the given Terraform Plugin Framework-based resource name list
func WithTerraformPluginFrameworkProvider ¶ added in v1.1.0
func WithTerraformPluginFrameworkProvider(tp fwprovider.Provider) ProviderOption
WithTerraformPluginFrameworkProvider configures the TerraformPluginFrameworkProvider for this Provider.
func WithTerraformPluginSDKIncludeList ¶ added in v1.1.0
func WithTerraformPluginSDKIncludeList(l []string) ProviderOption
WithTerraformPluginSDKIncludeList configures the TerraformPluginSDKIncludeList for this Provider, with the given Terraform Plugin SDKv2-based resource name list
func WithTerraformProvider ¶
func WithTerraformProvider(tp *schema.Provider) ProviderOption
WithTerraformProvider configures the TerraformProvider for this Provider.
type Reference ¶
type Reference struct { // Type is the Go type name of the CRD if it is in the same package or // <package-path>.<type-name> if it is in a different package. // Deprecated: Type is deprecated in favor of TerraformName, which provides // a more stable and less error-prone API compared to Type. TerraformName // will automatically handle name & version configurations that will affect // the generated cross-resource reference. This is crucial especially if the // provider generates multiple versions for its MR APIs. Type string // TerraformName is the name of the Terraform resource // which will be referenced. The supplied resource name is // converted to a type name of the corresponding CRD using // the configured TerraformTypeMapper. TerraformName 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 Go 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 ReferenceInjector ¶
ReferenceInjector injects cross-resource references across the resources of this Provider.
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 // Terraform Plugin SDKv2 based resource. TerraformResource *schema.Resource // TerraformPluginFrameworkResource is the Terraform representation // of the TF Plugin Framework based resource TerraformPluginFrameworkResource fwresource.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 API version being generated for the corresponding CRD. Version string // PreviousVersions is the list of API versions previously generated for this // resource for multi-versioned managed resources. upjet will attempt to load // the type definitions from these previous versions if configured. PreviousVersions []string // ControllerReconcileVersion is the CRD API version the associated // controller will watch & reconcile. If left unspecified, // defaults to the value of Version. This configuration parameter // can be used to have a controller use an older // API version of the generated CRD instead of the API version being // generated. Because this configuration parameter's value defaults to // the value of Version, by default the controllers will reconcile the // currently generated API versions of their associated CRs. ControllerReconcileVersion 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 specifies the initializer functions to be used // for this Resource. 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 // MetaResource is the metadata associated with the resource scraped from // the Terraform registry. MetaResource *registry.Resource // Path is the resource path for the API server endpoint. It defaults to // the plural name of the generated CRD. Overriding this sets both the // path and the plural name for the generated CRD. Path string // SchemaElementOptions is a map from the schema element paths to // SchemaElementOption for configuring options for schema elements. SchemaElementOptions SchemaElementOptions // TerraformConfigurationInjector allows a managed resource to inject // configuration values in the Terraform configuration map obtained by // deserializing its `spec.forProvider` value. Managed resources can // use this resource configuration option to inject Terraform // configuration parameters into their deserialized configuration maps, // if the deserialization skips certain fields. TerraformConfigurationInjector ConfigurationInjector // TerraformCustomDiff allows a resource.Terraformed to customize how its // Terraform InstanceDiff is computed during reconciliation. TerraformCustomDiff CustomDiff // ServerSideApplyMergeStrategies configures the server-side apply merge // strategy for the fields at the given map keys. The map key is // a Terraform configuration argument path such as a.b.c, without any // index notation (i.e., array/map components do not need indices). ServerSideApplyMergeStrategies ServerSideApplyMergeStrategies // Conversions is the list of CRD API conversion functions to be invoked // in-chain by the installed conversion Webhook for the generated CRD. // This list of conversion.Conversion registered here are responsible for // doing the conversions between the hub & spoke CRD API versions. Conversions []conversion.Conversion // TerraformConversions is the list of conversions to be invoked when passing // data from the Crossplane layer to the Terraform layer and when reading // data (state) from the Terraform layer to be used in the Crossplane layer. TerraformConversions []TerraformConversion // OverrideFieldNames allows to manually override the relevant field name to // avoid possible Go struct name conflicts that may occur after Multiversion // CRDs support. During field generation, there may be fields with the same // struct name calculated in the same group. For example, let X and Y // resources in the same API group have a field named Tag. This field is an // object type and the name calculated for the struct to be generated is // TagParameters (for spec) for both resources. To avoid this conflict, upjet // looks at all previously created structs in the package during generation // and if there is a conflict, it puts the Kind name of the related resource // in front of the next one: YTagParameters. // With Multiversion CRDs support, the above conflict scenario cannot be // solved in the generator when the old API group is preserved and not // regenerated, because the generator does not know the object names in the // old version. For example, a new API version is generated for resource X. In // this case, no generation is done for the old version of X and when Y is // generated, the generator is not aware of the TagParameters in X and // generates TagParameters instead of YTagParameters. Thus, two object types // with the same name are generated in the same package. This can be overcome // by using this configuration API. // The key of the map indicates the name of the field that is generated and // causes the conflict, while the value indicates the name used to avoid the // conflict. By convention, also used in upjet, the field name is preceded by // the value of the generated Kind, for example: // "TagParameters": "ClusterTagParameters" // Deprecated: OverrideFieldNames has been deprecated in favor of loading // the already existing type names from the older versions of the MR APIS // via the PreviousVersions API. OverrideFieldNames map[string]string // contains filtered or unexported fields }
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, terraformPluginFrameworkResource fwresource.Resource, terraformRegistry *registry.Resource, opts ...ResourceOption) *Resource
DefaultResource keeps an initial default configuration for all resources of a provider.
func (*Resource) AddSingletonListConversion ¶ added in v1.4.0
AddSingletonListConversion configures the list at the specified Terraform field path and the specified CRD field path as an embedded object. crdPath is the field path expression for the CRD schema and tfPath is the field path expression for the Terraform schema corresponding to the singleton list to be converted to an embedded object. At runtime, upjet will convert such objects back and forth from/to singleton lists while communicating with the Terraform stack. The specified fieldpath expression must be a wildcard expression such as `conditions[*]` or a 0-indexed expression such as `conditions[0]`. Other index values are not allowed as this function deals with singleton lists.
func (*Resource) ApplyTFConversions ¶ added in v1.4.0
ApplyTFConversions applies the configured Terraform conversions on the specified params map in the given mode, i.e., from Crossplane layer to the Terraform layer or vice versa.
func (*Resource) CRDHubVersion ¶ added in v1.4.0
CRDHubVersion returns the CRD hub version if configured. If not, returns the Version being generated as the default value.
func (*Resource) CRDListConversionPaths ¶ added in v1.4.0
CRDListConversionPaths returns the Resource's runtime CRD list conversion paths in fieldpath syntax.
func (*Resource) CRDStorageVersion ¶ added in v1.4.0
CRDStorageVersion returns the CRD storage version if configured. If not, returns the Version being generated as the default value.
func (*Resource) MarkAsRequired ¶ added in v1.1.6
MarkAsRequired marks the given fieldpaths as required without manipulating the native field schema.
func (*Resource) RequiredFields ¶ added in v1.1.6
RequiredFields returns slice of the marked as required fieldpaths.
func (*Resource) SetCRDHubVersion ¶ added in v1.4.0
SetCRDHubVersion configures the CRD API conversion hub version for a Resource. If unset, the default hub version is the current Version being generated.
func (*Resource) SetCRDStorageVersion ¶ added in v1.4.0
SetCRDStorageVersion configures the CRD storage version for a Resource. If unset, the default storage version is the current Version being generated.
func (*Resource) ShouldUseTerraformPluginFrameworkClient ¶ added in v1.1.0
ShouldUseTerraformPluginFrameworkClient returns whether to generate a Terraform Plugin Framework-based external client for this Resource.
func (*Resource) ShouldUseTerraformPluginSDKClient ¶ added in v1.1.0
ShouldUseTerraformPluginSDKClient returns whether to generate an SDKv2-based external client for this Resource.
func (*Resource) TFListConversionPaths ¶ added in v1.4.0
TFListConversionPaths returns the Resource's runtime Terraform list conversion paths in fieldpath syntax.
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 ResourceSetter ¶ added in v1.4.0
type ResourceSetter interface {
SetResource(r *Resource)
}
ResourceSetter allows the context Resource to be set for a traverser.
type SchemaElementOption ¶
type SchemaElementOption struct { // AddToObservation is set to true if the field represented by // a schema element is to be added to the generated CRD type's // Observation type. AddToObservation bool // EmbeddedObject is set to true if the field represented by // a schema element is to be embedded into its parent instead of being // generated as a single element list. EmbeddedObject bool }
SchemaElementOption represents configuration options on a schema element.
type SchemaElementOptions ¶
type SchemaElementOptions map[string]*SchemaElementOption
SchemaElementOptions represents schema element options for the schema elements of a Resource.
func (SchemaElementOptions) AddToObservation ¶
func (m SchemaElementOptions) AddToObservation(el string) bool
AddToObservation returns true if the schema element at the specified path should be added to the CRD type's Observation type.
func (SchemaElementOptions) EmbeddedObject ¶ added in v1.1.1
func (m SchemaElementOptions) EmbeddedObject(el string) bool
EmbeddedObject returns true if the schema element at the specified path should be generated as an embedded object.
func (SchemaElementOptions) SetAddToObservation ¶
func (m SchemaElementOptions) SetAddToObservation(el string)
SetAddToObservation sets the AddToObservation for the specified key.
func (SchemaElementOptions) SetEmbeddedObject ¶ added in v1.1.1
func (m SchemaElementOptions) SetEmbeddedObject(el string)
SetEmbeddedObject sets the EmbeddedObject for the specified key. The key is a Terraform field path without the wildcard segments.
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 ServerSideApplyMergeStrategies ¶ added in v1.1.0
type ServerSideApplyMergeStrategies map[string]MergeStrategy
ServerSideApplyMergeStrategies configures the server-side apply merge strategy for the field at the specified path as the map key. The key is a Terraform configuration argument path such as a.b.c, without any index notation (i.e., array/map components do not need indices). It's an error to set a configuration option which does not match the object type at the specified path or to leave the corresponding configuration entry empty. For example, if the field at path a.b.c is a list, then ListMergeStrategy must be set and it should be the only configuration entry set.
type SetIdentifierArgumentsFn ¶
SetIdentifierArgumentsFn sets the name of the resource in Terraform attributes map, i.e. Main HCL file.
var NopSetIdentifierArgument SetIdentifierArgumentsFn = func(_ map[string]any, _ 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 SingletonListEmbedder ¶ added in v1.4.0
type SingletonListEmbedder struct { traverser.NoopTraverser // contains filtered or unexported fields }
SingletonListEmbedder is a schema traverser for embedding singleton lists in the Terraform schema as objects.
func (*SingletonListEmbedder) SetResource ¶ added in v1.4.0
func (rc *SingletonListEmbedder) SetResource(r *Resource)
func (*SingletonListEmbedder) VisitResource ¶ added in v1.4.0
func (l *SingletonListEmbedder) VisitResource(r *traverser.ResourceNode) error
type StructType ¶ added in v1.1.0
type StructType string
A StructType is a type of struct.
const ( // StructTypeAtomic means that the struct can only be entirely replaced by a // single manager. StructTypeAtomic StructType = "atomic" // StructTypeGranular means that the struct supports separate managers // updating individual fields. StructTypeGranular StructType = "granular" )
Struct types.
type Tagger ¶
type Tagger struct {
// contains filtered or unexported fields
}
Tagger implements the Initialize function to set external tags
func (*Tagger) Initialize ¶
Initialize is a custom initializer for setting external tags
type TerraformConversion ¶ added in v1.4.0
type TerraformConversion interface {
Convert(params map[string]any, r *Resource, mode Mode) (map[string]any, error)
}
func NewTFSingletonConversion ¶ added in v1.4.0
func NewTFSingletonConversion() TerraformConversion
NewTFSingletonConversion initializes a new TerraformConversion to convert between singleton lists and embedded objects in the exchanged data at runtime between the Crossplane & Terraform layers.