Int32 function parameters expect a 32-bit integer number value from a practitioner configuration. Values are accessible in function logic by the Go built-in int32
type, Go built-in *int32
type, or the framework int32 type.
In this Terraform configuration example, a int32 parameter is set to the value 123
:
provider::example::example(123)
Use the function.Int32Parameter
type in the function definition to accept a int32 value.
In this example, a function definition includes a first position int32 parameter:
func (f ExampleFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) {
resp.Definition = function.Definition{
// ... other Definition fields ...
Parameters: []function.Parameter{
function.Int32Parameter{
Name: "int32_param",
// ... potentially other Int32Parameter fields ...
},
},
}
}
If the int32 value should be the element type of a collection parameter type, set the ElementType
field according to the framework int32 type. Refer to the collection parameter type documentation for additional details.
If the int32 value should be a value type of an object parameter type, set the AttributeTypes
map value according to the framework int32 type. Refer to the object parameter type documentation for additional details.
By default, Terraform will not pass null values to the function logic. Use the AllowNullValue
field to explicitly allow null values, if there is a meaningful distinction that should occur in function logic. Enabling AllowNullValue
requires using a Go pointer type or framework int32 type when reading argument data.
By default, Terraform will not pass unknown values to the function logic. Use the AllowUnknownValues
field to explicitly allow unknown values, if there is a meaningful distinction that should occur in function logic. Enabling AllowUnknownValues
requires using a framework int32 type when reading argument data.
You may want to build your own data value and type implementations to allow your provider to combine validation and other behaviors into a reusable bundle. This helps avoid duplication and ensures consistency. These implementations use the CustomType
field in the parameter type.
Refer to Custom Types for further details on creating provider-defined types and values.
DocumentationRefer to function documentation for information about the Name
, Description
, and MarkdownDescription
fields available.
The function implementation documentation covers the general methods for reading function argument data in function logic.
When retrieving the argument value for this parameter:
CustomType
is set, use its associated value type.AllowUnknownValues
is enabled, you must use the framework int32 type.AllowNullValue
is enabled, you must use the Go built-in *int32
type or framework int32 type.int32
type, Go built-in *int32
type, or framework int32 type.In this example, a function defines a single int32 parameter and accesses its argument value:
func (f ExampleFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) {
resp.Definition = function.Definition{
// ... other Definition fields ...
Parameters: []function.Parameter{
function.Int32Parameter{
Name: "int32_param",
// ... potentially other Int32Parameter fields ...
},
},
}
}
func (f ExampleFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) {
var int32Arg int32
// var int32Arg *int32 // e.g. with AllowNullValue, where Go nil equals Terraform null
// var int32Arg types.Int32 // e.g. with AllowUnknownValues or AllowNullValue
resp.Error = function.ConcatFuncErrors(resp.Error, req.Arguments.Get(ctx, &int32Arg))
// int32Arg is now populated
// ... other logic ...
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4