Documentation ¶
Overview ¶
Package tfsdk contains core framework functionality for schema data.
Index ¶
- func ConvertValue(ctx context.Context, val attr.Value, typ attr.Type) (attr.Value, diag.Diagnostics)
- func ValueAs(ctx context.Context, val attr.Value, target interface{}) diag.Diagnostics
- func ValueFrom(ctx context.Context, val interface{}, targetType attr.Type, target interface{}) diag.Diagnostics
- type Config
- type EphemeralResultData
- func (s EphemeralResultData) Get(ctx context.Context, target interface{}) diag.Diagnostics
- func (s EphemeralResultData) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
- func (s EphemeralResultData) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
- func (s *EphemeralResultData) Set(ctx context.Context, val interface{}) diag.Diagnostics
- func (s *EphemeralResultData) SetAttribute(ctx context.Context, path path.Path, val interface{}) diag.Diagnostics
- type Plan
- func (p Plan) Get(ctx context.Context, target interface{}) diag.Diagnostics
- func (p Plan) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
- func (p Plan) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
- func (p *Plan) Set(ctx context.Context, val interface{}) diag.Diagnostics
- func (p *Plan) SetAttribute(ctx context.Context, path path.Path, val interface{}) diag.Diagnostics
- type State
- func (s State) Get(ctx context.Context, target interface{}) diag.Diagnostics
- func (s State) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
- func (s State) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
- func (s *State) RemoveResource(ctx context.Context)
- func (s *State) Set(ctx context.Context, val interface{}) diag.Diagnostics
- func (s *State) SetAttribute(ctx context.Context, path path.Path, val interface{}) diag.Diagnostics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertValue ¶ added in v0.4.0
func ConvertValue(ctx context.Context, val attr.Value, typ attr.Type) (attr.Value, diag.Diagnostics)
ConvertValue creates a new attr.Value of the attr.Type `typ`, using the data in `val`, which can be of any attr.Type so long as its TerraformType method returns a tftypes.Type that `typ`'s ValueFromTerraform method can accept.
func ValueAs ¶ added in v0.3.0
ValueAs takes the attr.Value `val` and populates the Go value `target` with its content.
This is achieved using reflection rules provided by the internal/reflect package.
func ValueFrom ¶ added in v0.9.0
func ValueFrom(ctx context.Context, val interface{}, targetType attr.Type, target interface{}) diag.Diagnostics
ValueFrom takes the Go value `val` and populates `target` with an attr.Value, based on the type definition provided in `targetType`.
This is achieved using reflection rules provided by the internal/reflect package.
Types ¶
type Config ¶
Config represents a Terraform config.
func (Config) Get ¶
func (c Config) Get(ctx context.Context, target interface{}) diag.Diagnostics
Get populates the struct passed as `target` with the entire config.
func (Config) GetAttribute ¶
func (c Config) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
GetAttribute retrieves the attribute or block found at `path` and populates the `target` with the value. This method is intended for top level schema attributes or blocks. Use `types` package methods or custom types to step into collections.
Attributes or elements under null or unknown collections return null values, however this behavior is not protected by compatibility promises.
func (Config) PathMatches ¶ added in v0.10.0
func (c Config) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
PathMatches returns all matching path.Paths from the given path.Expression.
If a parent path is null or unknown, which would prevent a full expression from matching, the parent path is returned rather than no match to prevent false positives.
type EphemeralResultData ¶ added in v1.13.0
EphemeralResultData represents the data returned after opening a Terraform ephemeral resource.
func (EphemeralResultData) Get ¶ added in v1.13.0
func (s EphemeralResultData) Get(ctx context.Context, target interface{}) diag.Diagnostics
Get populates the struct passed as `target` with the entire ephemeral result data object.
func (EphemeralResultData) GetAttribute ¶ added in v1.13.0
func (s EphemeralResultData) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
GetAttribute retrieves the attribute or block found at `path` and populates the `target` with the value. This method is intended for top level schema attributes or blocks. Use `types` package methods or custom types to step into collections.
Attributes or elements under null or unknown collections return null values, however this behavior is not protected by compatibility promises.
func (EphemeralResultData) PathMatches ¶ added in v1.13.0
func (s EphemeralResultData) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
PathMatches returns all matching path.Paths from the given path.Expression.
If a parent path is null or unknown, which would prevent a full expression from matching, the parent path is returned rather than no match to prevent false positives.
func (*EphemeralResultData) Set ¶ added in v1.13.0
func (s *EphemeralResultData) Set(ctx context.Context, val interface{}) diag.Diagnostics
Set populates the entire ephemeral result data object using the supplied Go value. The value `val` should be a struct whose values have one of the attr.Value types. Each field must be tagged with the corresponding schema field.
func (*EphemeralResultData) SetAttribute ¶ added in v1.13.0
func (s *EphemeralResultData) SetAttribute(ctx context.Context, path path.Path, val interface{}) diag.Diagnostics
SetAttribute sets the attribute at `path` using the supplied Go value.
The attribute path and value must be valid with the current schema. If the attribute path already has a value, it will be overwritten. If the attribute path does not have a value, it will be added, including any parent attribute paths as necessary.
The value must not be an untyped nil. Use a typed nil or types package null value function instead. For example with a types.StringType attribute, use (*string)(nil) or types.StringNull().
Lists can only have the next element added according to the current length.
type Plan ¶
Plan represents a Terraform plan.
func (Plan) Get ¶
func (p Plan) Get(ctx context.Context, target interface{}) diag.Diagnostics
Get populates the struct passed as `target` with the entire plan.
func (Plan) GetAttribute ¶
func (p Plan) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
GetAttribute retrieves the attribute or block found at `path` and populates the `target` with the value. This method is intended for top level schema attributes or blocks. Use `types` package methods or custom types to step into collections.
Attributes or elements under null or unknown collections return null values, however this behavior is not protected by compatibility promises.
func (Plan) PathMatches ¶ added in v0.10.0
func (p Plan) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
PathMatches returns all matching path.Paths from the given path.Expression.
If a parent path is null or unknown, which would prevent a full expression from matching, the parent path is returned rather than no match to prevent false positives.
func (*Plan) Set ¶
func (p *Plan) Set(ctx context.Context, val interface{}) diag.Diagnostics
Set populates the entire plan using the supplied Go value. The value `val` should be a struct whose values have one of the attr.Value types. Each field must be tagged with the corresponding schema field.
func (*Plan) SetAttribute ¶
SetAttribute sets the attribute at `path` using the supplied Go value.
The attribute path and value must be valid with the current schema. If the attribute path already has a value, it will be overwritten. If the attribute path does not have a value, it will be added, including any parent attribute paths as necessary.
The value must not be an untyped nil. Use a typed nil or types package null value function instead. For example with a types.StringType attribute, use (*string)(nil) or types.StringNull().
Lists can only have the next element added according to the current length.
type State ¶
State represents a Terraform state.
func (State) Get ¶
func (s State) Get(ctx context.Context, target interface{}) diag.Diagnostics
Get populates the struct passed as `target` with the entire state.
func (State) GetAttribute ¶
func (s State) GetAttribute(ctx context.Context, path path.Path, target interface{}) diag.Diagnostics
GetAttribute retrieves the attribute or block found at `path` and populates the `target` with the value. This method is intended for top level schema attributes or blocks. Use `types` package methods or custom types to step into collections.
Attributes or elements under null or unknown collections return null values, however this behavior is not protected by compatibility promises.
func (State) PathMatches ¶ added in v0.10.0
func (s State) PathMatches(ctx context.Context, pathExpr path.Expression) (path.Paths, diag.Diagnostics)
PathMatches returns all matching path.Paths from the given path.Expression.
If a parent path is null or unknown, which would prevent a full expression from matching, the parent path is returned rather than no match to prevent false positives.
func (*State) RemoveResource ¶
RemoveResource removes the entire resource from state.
If a Resource type Delete method is completed without error, this is automatically called on the DeleteResourceResponse.State.
func (*State) Set ¶
func (s *State) Set(ctx context.Context, val interface{}) diag.Diagnostics
Set populates the entire state using the supplied Go value. The value `val` should be a struct whose values have one of the attr.Value types. Each field must be tagged with the corresponding schema field.
func (*State) SetAttribute ¶
SetAttribute sets the attribute at `path` using the supplied Go value.
The attribute path and value must be valid with the current schema. If the attribute path already has a value, it will be overwritten. If the attribute path does not have a value, it will be added, including any parent attribute paths as necessary.
The value must not be an untyped nil. Use a typed nil or types package null value function instead. For example with a types.StringType attribute, use (*string)(nil) or types.StringNull().
Lists can only have the next element added according to the current length.