Documentation ¶
Index ¶
- Constants
- func GetAttributeName(oas *openapi3.Schema) string
- func GetDataSourceAttributes(name string) (map[string]datasource.Attribute, error)
- func GetResourceAttributes(name string) (map[string]resource.Attribute, error)
- func GetSchema(name string) (*openapi3.Schema, error)
- func GetStringValidators(oas *openapi3.Schema) []validator.String
- func GetTerraformType(schemaRef *openapi3.SchemaRef) attr.Type
- func IsExtensionSet(oas *openapi3.Schema, key string) bool
- func IsIdentifierAttribute(oas *openapi3.Schema) bool
- func IsImmutableAttribute(oas *openapi3.Schema) bool
- func IsSensitiveAttribute(oas *openapi3.Schema) bool
- func ParseTimeouts(timeouts map[string]OperationTimeouts, resourceTypes map[string]struct{}) (map[string]map[string]time.Duration, error)
- func ReadResource(ctx context.Context, diags *diag.Diagnostics, ...) bool
- func ToDataSourceAttribute(oas *openapi3.Schema) (string, datasource.Attribute)
- func ToDataSourceSchema(oas *openapi3.Schema) map[string]datasource.Attribute
- func ToResourceAttribute(oas *openapi3.Schema, required, readOnly bool) (string, resource.Attribute)
- func ToResourceSchema(oas *openapi3.Schema, readOnly bool) map[string]resource.Attribute
- type AttributeBuilder
- func (ab *AttributeBuilder) WithComputedStringAttribute(name, description string) *AttributeBuilder
- func (ab *AttributeBuilder) WithNameAttribute(typeName string) *AttributeBuilder
- func (ab *AttributeBuilder) WithNewListNestedAttribute(name, description string) *AttributeBuilder
- func (ab *AttributeBuilder) WithNewNestedAttribute(name, description string) *AttributeBuilder
- func (ab *AttributeBuilder) WithOptionalStringAttribute(name, description string) *AttributeBuilder
- func (ab *AttributeBuilder) WithStringAttribute(name, description string, optional bool) *AttributeBuilder
- func (ab *AttributeBuilder) WithStringListAttribute(name, description string) *AttributeBuilder
- type ClientWithOptions
- type DataSourceState
- type GenericDataSource
- func (d *GenericDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, ...)
- func (d *GenericDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, ...)
- func (d *GenericDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse)
- func (d *GenericDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, ...)
- type GenericPlanModifier
- func (m GenericPlanModifier) Description(_ context.Context) string
- func (m GenericPlanModifier) MarkdownDescription(_ context.Context) string
- func (m GenericPlanModifier) PlanModifyBool(_ context.Context, req planmodifier.BoolRequest, ...)
- func (m GenericPlanModifier) PlanModifyFloat64(_ context.Context, req planmodifier.Float64Request, ...)
- func (m GenericPlanModifier) PlanModifyInt64(_ context.Context, req planmodifier.Int64Request, ...)
- func (m GenericPlanModifier) PlanModifyList(_ context.Context, req planmodifier.ListRequest, ...)
- func (m GenericPlanModifier) PlanModifyMap(_ context.Context, req planmodifier.MapRequest, resp *planmodifier.MapResponse)
- func (m GenericPlanModifier) PlanModifyNumber(_ context.Context, req planmodifier.NumberRequest, ...)
- func (m GenericPlanModifier) PlanModifyObject(_ context.Context, req planmodifier.ObjectRequest, ...)
- func (m GenericPlanModifier) PlanModifyString(_ context.Context, req planmodifier.StringRequest, ...)
- type GenericRequest
- type GenericResource
- func (r *GenericResource) AwaitDeleted(ctx context.Context, state ResourceState) error
- func (r *GenericResource) AwaitReady(ctx context.Context, state ResourceState, operation string) error
- func (r *GenericResource) Configure(ctx context.Context, req resource.ConfigureRequest, ...)
- func (r *GenericResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *GenericResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *GenericResource) GetTimeout(operation string, defaultTimeout time.Duration) time.Duration
- func (r *GenericResource) ImportState(ctx context.Context, req resource.ImportStateRequest, ...)
- func (r *GenericResource) Metadata(ctx context.Context, req resource.MetadataRequest, ...)
- func (r *GenericResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *GenericResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *GenericResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type GenericResponse
- type OperationTimeouts
- type ResourceState
- type SchemaBuilder
- func (sb *SchemaBuilder) Build() *schema.Schema
- func (sb *SchemaBuilder) WithDescription(description string) *SchemaBuilder
- func (sb *SchemaBuilder) WithOrganizationScopeFilters(typeNamePlural string) *AttributeBuilder
- func (sb *SchemaBuilder) WithOrganizationScopeList(typeName, typeNamePlural string) *AttributeBuilder
- func (sb *SchemaBuilder) WithProjectScopeFilters(typeNamePlural string) *AttributeBuilder
- func (sb *SchemaBuilder) WithProjectScopeList(typeName, typeNamePlural string) *AttributeBuilder
- type State
Constants ¶
const ( READINESS_TIMEOUT = 5 * time.Minute DELETION_TIMEOUT = 1 * time.Minute POLLING_INTERVAL = 1 * time.Second DEFAULT_RESOURCE = "default" CREATE_OPERATION = "create" UPDATE_OPERATION = "update" DELETE_OPERATION = "delete" )
const ( ALLOW_DESTRUCTIVE_REPLACE_VAR = "NUODB_CP_ALLOW_DESTRUCTIVE_REPLACE" IMMUTABLE_ATTRIBUTE_CHANGE_ERR_FMT = "A change has been made to the immutable attribute `%s`, which may be rejected by the server or ignored. " + "In order for an immutable attribute change to take effect, it is necessary to delete and re-create the resource, which may result in data loss.\n\n" + "If it is acceptable to destroy all data associated with the resource, then deletion and re-creation can be enabled by setting the environment variable `" + ALLOW_DESTRUCTIVE_REPLACE_VAR + "=true` when running `terraform apply`:\n\n" + " " + ALLOW_DESTRUCTIVE_REPLACE_VAR + "=true terraform apply\n\n" + "If the resource has dependent resources, it may be necessary to explicitly delete and re-create the resource and its dependent resources by running the following:\n\n" + " terraform destroy -target=<resource>\n terraform apply\n\n" + "If it is not acceptable to destroy all data associated with the resource, the configured value of the attribute can be reverted to the value in the Terraform state (`%s`)." )
const (
LABEL_FILTER_DESCRIPTION = "List of filters to apply based on labels, which are composed using `AND`. Acceptable filter expressions are:\n" +
" * `key` - Only return items that have label with specified key\n" +
" * `key=value` - Only return items that have label with specified key set to value\n" +
" * `!key` - Only return items that do _not_ have label with specified key\n" +
" * `key!=value` - Only return items that do _not_ have label with specified key set to value"
)
Variables ¶
This section is empty.
Functions ¶
func GetAttributeName ¶
func GetDataSourceAttributes ¶ added in v1.1.0
func GetDataSourceAttributes(name string) (map[string]datasource.Attribute, error)
func GetResourceAttributes ¶ added in v1.1.0
func GetStringValidators ¶ added in v1.1.0
func IsIdentifierAttribute ¶
func IsImmutableAttribute ¶
func IsSensitiveAttribute ¶
func ParseTimeouts ¶ added in v1.0.0
func ReadResource ¶
func ReadResource(ctx context.Context, diags *diag.Diagnostics, fn func(context.Context, any) diag.Diagnostics, dest any) bool
ReadResource decodes Terraform configuration, state, or plan to a model struct containing ordinary Golang field types (e.g. bool, *int, []string) that have the `tfsdk:"..."` tag.
func ToDataSourceAttribute ¶
func ToDataSourceAttribute(oas *openapi3.Schema) (string, datasource.Attribute)
func ToDataSourceSchema ¶
func ToDataSourceSchema(oas *openapi3.Schema) map[string]datasource.Attribute
func ToResourceAttribute ¶
Types ¶
type AttributeBuilder ¶
type AttributeBuilder struct {
// contains filtered or unexported fields
}
func (*AttributeBuilder) WithComputedStringAttribute ¶
func (ab *AttributeBuilder) WithComputedStringAttribute(name, description string) *AttributeBuilder
func (*AttributeBuilder) WithNameAttribute ¶
func (ab *AttributeBuilder) WithNameAttribute(typeName string) *AttributeBuilder
func (*AttributeBuilder) WithNewListNestedAttribute ¶
func (ab *AttributeBuilder) WithNewListNestedAttribute(name, description string) *AttributeBuilder
func (*AttributeBuilder) WithNewNestedAttribute ¶
func (ab *AttributeBuilder) WithNewNestedAttribute(name, description string) *AttributeBuilder
func (*AttributeBuilder) WithOptionalStringAttribute ¶
func (ab *AttributeBuilder) WithOptionalStringAttribute(name, description string) *AttributeBuilder
func (*AttributeBuilder) WithStringAttribute ¶
func (ab *AttributeBuilder) WithStringAttribute(name, description string, optional bool) *AttributeBuilder
func (*AttributeBuilder) WithStringListAttribute ¶
func (ab *AttributeBuilder) WithStringListAttribute(name, description string) *AttributeBuilder
type ClientWithOptions ¶ added in v1.0.0
type ClientWithOptions struct { Client openapi.ClientInterface // contains filtered or unexported fields }
func NewClientWithOptions ¶ added in v1.0.0
func NewClientWithOptions(client openapi.ClientInterface, timeouts map[string]map[string]time.Duration) *ClientWithOptions
type DataSourceState ¶
type DataSourceState interface { State // Read retrieves the state of the resource from the backend. Read(ctx context.Context, client openapi.ClientInterface) error }
DataSourceState handles interactions with the provider API.
type GenericDataSource ¶
type GenericDataSource struct { TypeName string Description string GetDataSourceAttributes func() (map[string]schema.Attribute, error) SchemaOverride *schema.Schema Build func() DataSourceState // contains filtered or unexported fields }
GenericDataSource is a DataSource implementation that handles all interactions with the Terraform API and delegates interaction with the provider API to DataSourceState.
func (*GenericDataSource) Configure ¶
func (d *GenericDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse)
func (*GenericDataSource) Metadata ¶
func (d *GenericDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse)
func (*GenericDataSource) Read ¶
func (d *GenericDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse)
func (*GenericDataSource) Schema ¶
func (d *GenericDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse)
type GenericPlanModifier ¶
type GenericPlanModifier struct {
// contains filtered or unexported fields
}
GenericPlanModifier is a plan modifier implementation that can be applied to any type.
func RequiresReplace ¶
func RequiresReplace() *GenericPlanModifier
func UseStateForUnknown ¶
func UseStateForUnknown() *GenericPlanModifier
func (GenericPlanModifier) Description ¶
func (m GenericPlanModifier) Description(_ context.Context) string
Description returns a human-readable description of the plan modifier.
func (GenericPlanModifier) MarkdownDescription ¶
func (m GenericPlanModifier) MarkdownDescription(_ context.Context) string
MarkdownDescription returns a markdown description of the plan modifier.
func (GenericPlanModifier) PlanModifyBool ¶
func (m GenericPlanModifier) PlanModifyBool(_ context.Context, req planmodifier.BoolRequest, resp *planmodifier.BoolResponse)
PlanModifyBool implements the plan modification logic.
func (GenericPlanModifier) PlanModifyFloat64 ¶
func (m GenericPlanModifier) PlanModifyFloat64(_ context.Context, req planmodifier.Float64Request, resp *planmodifier.Float64Response)
PlanModifyFloat64 implements the plan modification logic.
func (GenericPlanModifier) PlanModifyInt64 ¶
func (m GenericPlanModifier) PlanModifyInt64(_ context.Context, req planmodifier.Int64Request, resp *planmodifier.Int64Response)
PlanModifyInt64 implements the plan modification logic.
func (GenericPlanModifier) PlanModifyList ¶
func (m GenericPlanModifier) PlanModifyList(_ context.Context, req planmodifier.ListRequest, resp *planmodifier.ListResponse)
PlanModifyList implements the plan modification logic.
func (GenericPlanModifier) PlanModifyMap ¶
func (m GenericPlanModifier) PlanModifyMap(_ context.Context, req planmodifier.MapRequest, resp *planmodifier.MapResponse)
PlanModifyMap implements the plan modification logic.
func (GenericPlanModifier) PlanModifyNumber ¶
func (m GenericPlanModifier) PlanModifyNumber(_ context.Context, req planmodifier.NumberRequest, resp *planmodifier.NumberResponse)
PlanModifyNumber implements the plan modification logic.
func (GenericPlanModifier) PlanModifyObject ¶
func (m GenericPlanModifier) PlanModifyObject(_ context.Context, req planmodifier.ObjectRequest, resp *planmodifier.ObjectResponse)
PlanModifyObject implements the plan modification logic.
func (GenericPlanModifier) PlanModifyString ¶
func (m GenericPlanModifier) PlanModifyString(_ context.Context, req planmodifier.StringRequest, resp *planmodifier.StringResponse)
PlanModifyString implements the plan modification logic.
type GenericRequest ¶
type GenericRequest struct { // Path contains the path of the attribute for modification. Use this path // for any response diagnostics. Path path.Path // Config contains the entire configuration of the resource. Config tfsdk.Config // ConfigValue contains the value of the attribute for modification from the configuration. ConfigValue attr.Value // Plan contains the entire proposed new state of the resource. Plan tfsdk.Plan // PlanValue contains the value of the attribute for modification from the proposed new state. PlanValue attr.Value // State contains the entire prior state of the resource. State tfsdk.State // StateValue contains the value of the attribute for modification from the prior state. StateValue attr.Value }
GenericRequest is a request for plan modification that uses attr.Value instead of specific type of the attribute to enable code reuse across types.
type GenericResource ¶
type GenericResource struct { TypeName string Description string GetResourceAttributes func() (map[string]schema.Attribute, error) Build func() ResourceState // contains filtered or unexported fields }
GenericResource is a Resource implementation that handles all interactions with the Terraform API and delegates interaction with the provider API to ResourceState.
func (*GenericResource) AwaitDeleted ¶
func (r *GenericResource) AwaitDeleted(ctx context.Context, state ResourceState) error
func (*GenericResource) AwaitReady ¶
func (r *GenericResource) AwaitReady(ctx context.Context, state ResourceState, operation string) error
func (*GenericResource) Configure ¶
func (r *GenericResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
func (*GenericResource) Create ¶
func (r *GenericResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
func (*GenericResource) Delete ¶
func (r *GenericResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
func (*GenericResource) GetTimeout ¶ added in v1.0.0
func (*GenericResource) ImportState ¶
func (r *GenericResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse)
func (*GenericResource) Metadata ¶
func (r *GenericResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
func (*GenericResource) Read ¶
func (r *GenericResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
func (*GenericResource) Schema ¶
func (r *GenericResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
func (*GenericResource) Update ¶
func (r *GenericResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
type GenericResponse ¶
type GenericResponse struct { // PlanValue is the planned new state for the attribute. PlanValue attr.Value // RequiresReplace indicates whether a change in the attribute // requires replacement of the whole resource. RequiresReplace bool // Diagnostics report errors or warnings related to validating the data // source configuration. An empty slice indicates success, with no warnings // or errors generated. Diagnostics *diag.Diagnostics }
GenericResponse is a response to a GenericRequest.
type OperationTimeouts ¶ added in v1.0.0
type ResourceState ¶
type ResourceState interface { State // Reset resets the local state of the resource to the zero value. Reset() // CheckReady returns an error if the resource is not in the desired // state according to its spec, based on the local state. The supplied // client can be used to request additional readiness information from // the server. CheckReady(ctx context.Context, client openapi.ClientInterface) error // Create creates the resource in the backend based on the local state // and waits for it to satisfy IsReady(). Create(ctx context.Context, client openapi.ClientInterface) error // Read retrieves the state of the resource from the backend. Read(ctx context.Context, client openapi.ClientInterface) error // Update updates the resource in the backend to match the local state // and waits for it to satisfy IsReady(). Update(ctx context.Context, client openapi.ClientInterface, currentState ResourceState) error // Delete deletes the resource from the backend and waits for it to be // cleaned up. Delete(ctx context.Context, client openapi.ClientInterface) error // Deserialize the resource ID SetId(id string) error }
ResourceState handles interactions with the provider API.
type SchemaBuilder ¶
type SchemaBuilder struct { AttributeBuilder // contains filtered or unexported fields }
func NewSchemaBuilder ¶
func NewSchemaBuilder() *SchemaBuilder
func (*SchemaBuilder) Build ¶
func (sb *SchemaBuilder) Build() *schema.Schema
func (*SchemaBuilder) WithDescription ¶
func (sb *SchemaBuilder) WithDescription(description string) *SchemaBuilder
func (*SchemaBuilder) WithOrganizationScopeFilters ¶
func (sb *SchemaBuilder) WithOrganizationScopeFilters(typeNamePlural string) *AttributeBuilder
WithOrganizationScopeFilters attaches common attributes for the filter nested attribute of an organization-scoped resource in DBaaS.
func (*SchemaBuilder) WithOrganizationScopeList ¶
func (sb *SchemaBuilder) WithOrganizationScopeList(typeName, typeNamePlural string) *AttributeBuilder
WithOrganizationScopeList attaches schema information for the list attribute of the supplied type, which is organization-scoped (e.g. projects).
func (*SchemaBuilder) WithProjectScopeFilters ¶
func (sb *SchemaBuilder) WithProjectScopeFilters(typeNamePlural string) *AttributeBuilder
WithProjectScopeFilters attaches schema information for the filter nested attribute of a project-scoped resource in DBaaS.
func (*SchemaBuilder) WithProjectScopeList ¶
func (sb *SchemaBuilder) WithProjectScopeList(typeName, typeNamePlural string) *AttributeBuilder
WithProjectScopeList attaches schema information for the list attribute of the supplied type, which is project-scoped (e.g. databases).