defaults

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MPL-2.0 Imports: 4 Imported by: 4

Documentation

Overview

Package defaults contains schema default value interfaces and request/response implementations. These default value interfaces are used by resource/schema and internally in the framework. Refer to the typed default packages, such as stringdefault, for framework-defined default values that can be used in provider-defined schemas.

Each attr.Type has a corresponding {TYPE} interface which implements concretely typed Default{TYPE} methods, such as StringDefault and DefaultString.

The framework has to choose between default value developers handling a concrete framework value type, such as types.Bool, or the framework interface for custom value basetypes, such as basetypes.BoolValuable.

In the framework type model, the developer can immediately use the value. If the value was associated with a custom type and using the custom value type is desired, the developer must use the type's ValueFrom{TYPE} method.

In the custom type model, the developer must always convert to a concrete type before using the value unless checking for null or unknown. Since any custom type may be passed due to the schema, it is possible, if not likely, that unknown concrete types will be passed to the default.

The framework chooses to pass the framework value type. This prevents the potential for unexpected runtime panics and simplifies development for easier use cases where the framework type is sufficient. More advanced developers can choose to call the type's ValueFrom{TYPE} method to get the desired custom type in a plan modifier.

Defaults that are not type dependent need to implement all interfaces, but can use shared logic to reduce implementation code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool interface {
	Describer

	// DefaultBool should set the default value.
	DefaultBool(context.Context, BoolRequest, *BoolResponse)
}

Bool is a schema default value for types.Bool attributes.

type BoolRequest

type BoolRequest struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type BoolResponse

type BoolResponse struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Bool
}

type Describer

type Describer interface {
	// Description should describe the default in plain text formatting.
	// This information is used by provider logging and provider tooling such
	// as documentation generation.
	//
	// The description should:
	//  - Begin with a lowercase or other character suitable for the middle of
	//    a sentence.
	//  - End without punctuation.
	Description(ctx context.Context) string

	// MarkdownDescription should describe the default in Markdown
	// formatting. This information is used by provider logging and provider
	// tooling such as documentation generation.
	//
	// The description should:
	//  - Begin with a lowercase or other character suitable for the middle of
	//    a sentence.
	//  - End without punctuation.
	MarkdownDescription(ctx context.Context) string
}

Describer is the common documentation interface for extensible schema default value functionality.

type Dynamic added in v1.7.0

type Dynamic interface {
	Describer

	// DefaultDynamic should set the default value.
	DefaultDynamic(context.Context, DynamicRequest, *DynamicResponse)
}

Dynamic is a schema default value for types.Dynamic attributes.

type DynamicRequest added in v1.7.0

type DynamicRequest struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type DynamicResponse added in v1.7.0

type DynamicResponse struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Dynamic
}

type Float32 added in v1.10.0

type Float32 interface {
	Describer

	// DefaultFloat32 should set the default value.
	DefaultFloat32(context.Context, Float32Request, *Float32Response)
}

Float32 is a schema default value for types.Float32 attributes.

type Float32Request added in v1.10.0

type Float32Request struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type Float32Response added in v1.10.0

type Float32Response struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Float32
}

type Float64

type Float64 interface {
	Describer

	// DefaultFloat64 should set the default value.
	DefaultFloat64(context.Context, Float64Request, *Float64Response)
}

Float64 is a schema default value for types.Float64 attributes.

type Float64Request

type Float64Request struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type Float64Response

type Float64Response struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Float64
}

type Int32 added in v1.10.0

type Int32 interface {
	Describer

	// DefaultInt32 should set the default value.
	DefaultInt32(context.Context, Int32Request, *Int32Response)
}

Int32 is a schema default value for types.Int32 attributes.

type Int32Request added in v1.10.0

type Int32Request struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type Int32Response added in v1.10.0

type Int32Response struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Int32
}

type Int64

type Int64 interface {
	Describer

	// DefaultInt64 should set the default value.
	DefaultInt64(context.Context, Int64Request, *Int64Response)
}

Int64 is a schema default value for types.Int64 attributes.

type Int64Request

type Int64Request struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type Int64Response

type Int64Response struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Int64
}

type List

type List interface {
	Describer

	// DefaultList should set the default value.
	DefaultList(context.Context, ListRequest, *ListResponse)
}

List is a schema default value for types.List attributes.

type ListRequest

type ListRequest struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type ListResponse

type ListResponse struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.List
}

type Map

type Map interface {
	Describer

	// DefaultMap should set the default value.
	DefaultMap(context.Context, MapRequest, *MapResponse)
}

Map is a schema default value for types.Map attributes.

type MapRequest

type MapRequest struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type MapResponse

type MapResponse struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Map
}

type Number

type Number interface {
	Describer

	// DefaultNumber should set the default value.
	DefaultNumber(context.Context, NumberRequest, *NumberResponse)
}

Number is a schema default value for types.Number attributes.

type NumberRequest

type NumberRequest struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type NumberResponse

type NumberResponse struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Number
}

type Object

type Object interface {
	Describer

	// DefaultObject should set the default value.
	DefaultObject(context.Context, ObjectRequest, *ObjectResponse)
}

Object is a schema default value for types.Object attributes.

type ObjectRequest

type ObjectRequest struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type ObjectResponse

type ObjectResponse struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Object
}

type Set

type Set interface {
	Describer

	// DefaultSet should set the default value.
	DefaultSet(context.Context, SetRequest, *SetResponse)
}

Set is a schema default value for types.Set attributes.

type SetRequest

type SetRequest struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type SetResponse

type SetResponse struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.Set
}

type String

type String interface {
	Describer

	// DefaultString should set the default value.
	DefaultString(context.Context, StringRequest, *StringResponse)
}

String is a schema default value for types.String attributes.

type StringRequest

type StringRequest struct {
	// Path contains the path of the attribute for setting the
	// default value. Use this path for any response diagnostics.
	Path path.Path
}

type StringResponse

type StringResponse struct {
	// Diagnostics report errors or warnings related to setting the
	// default value resource configuration. An empty slice
	// indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics

	// PlanValue is the planned new state for the attribute.
	PlanValue types.String
}

Jump to

Keyboard shortcuts

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