Documentation
¶
Index ¶
- func Addr[T any](t T) *T
- func ConvertModelToTerraformObject[T TerraformObjectConvertible](ctx context.Context, model *T) (types.Object, diag.Diagnostics)
- func GenerateUpdateTimestamp() basetypes.StringValue
- func IsKnown(value attr.Value) bool
- func IsNull(value attr.Value) bool
- func ListIDsToModify(ctx context.Context, plan, state types.List) (idsToAdd, idsToRemove []string, diags diag.Diagnostics)
- func ListTypeAs[T any](ctx context.Context, list types.List, diags *diag.Diagnostics) []T
- func MapTypeAs[T any](ctx context.Context, mapIn types.Map, diags *diag.Diagnostics) map[string]T
- func MarkdownDescription(section, description string, apiScopes []scopes.Scope) string
- func MatchesWildcard(text, pattern string) bool
- func MissingElements(a, b []string) []string
- func OptionalString(value *string) types.String
- func PancicPrettyPrint(v interface{})
- func PlanAwareStringValue(plan types.String, apiValue *string) types.String
- func SetIDsToModify(ctx context.Context, plan, state types.Set) (idsToAdd, idsToRemove []string, diags diag.Diagnostics)
- func SetInt64FromAPIIfNotZero(currentValue types.Int64, apiValue int64) types.Int64
- func SetStringFromAPIIfNotEmpty(currentValue types.String, apiValue string) types.String
- func SliceToListTypeObject[T any](ctx context.Context, elems []T, attrs map[string]attr.Type, ...) types.List
- func SliceToListTypeString(ctx context.Context, elems []string, diags *diag.Diagnostics) types.List
- func ValidateEmptyIDs(ctx context.Context, checkSet types.Set, attrPath string) diag.Diagnostics
- func ValidateEmptyIDsList(ctx context.Context, checkList types.Set, attrPath string) diag.Diagnostics
- type SearchQueryInfo
- type TerraformObjectConvertible
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertModelToTerraformObject ¶ added in v0.0.33
func ConvertModelToTerraformObject[T TerraformObjectConvertible]( ctx context.Context, model *T, ) (types.Object, diag.Diagnostics)
ConvertModelToTerraformObject converts a model pointer to a Terraform object. If the model is nil, returns a null object with the provided attribute types.
func GenerateUpdateTimestamp ¶ added in v0.0.23
func GenerateUpdateTimestamp() basetypes.StringValue
func ListIDsToModify ¶
func ListIDsToModify( ctx context.Context, plan, state types.List, ) (idsToAdd, idsToRemove []string, diags diag.Diagnostics)
ListIDsToModify takes a list of unique IDs from plan and state and returns the IDs to add and remove to get from the state to the plan. idsToAdd is the slice of IDs that are in the plan but not in the state. idsToRemove is the slice of IDs that are in the state but not in the plan. useful for resources with HostGroups, RuleGroups, etc.
func ListTypeAs ¶ added in v0.0.11
ListTypeAs converts a types.List into a known []T.
func MapTypeAs ¶ added in v0.0.29
func MapTypeAs[T any]( ctx context.Context, mapIn types.Map, diags *diag.Diagnostics, ) map[string]T
MapTypeAs converts a types.Map into a known map[string]T.
func MarkdownDescription ¶ added in v0.0.23
MarkdownDescription generates a markdown description that works for generating terraform docs.
func MatchesWildcard ¶ added in v0.0.45
MatchesWildcard checks if a text string matches a wildcard pattern. The pattern can contain asterisks (*) which match zero or more characters. Matching is case-insensitive. Examples:
- "admin*" matches "admin@example.com", "Administrator", "ADMIN"
- "*admin*" matches "system-admin@example.com", "Admin"
- "example*more" matches "example-test-more", "EXAMPLEMORE"
func MissingElements ¶ added in v0.0.26
MissingElements checks if any elements in slice `a` are missing from slice `b`. It returns a slice containing the missing elements.
func OptionalString ¶ added in v0.0.33
OptionalString converts a string pointer to types.String, returning null if pointer is nil or empty.
func PancicPrettyPrint ¶ added in v0.0.20
func PancicPrettyPrint(v interface{})
PancicPrettyPrint converts the interface into a json string and panics.
func PlanAwareStringValue ¶ added in v0.0.40
PlanAwareStringValue converts a string pointer to a types.String, treating null and empty string as equivalent. This is useful for properties like description where the API often returns "" for descriptions that are unset. This allows us to handle cases where an omitted field and a field with "" value should be treated the same.
If the plan value is null and the API returns nil or empty string, the result will be null. Otherwise, the API value is used as-is (nil becomes null, empty string becomes empty string, etc.). This prevents Terraform inconsistent state errors when the API returns "" for omitted fields.
func SetIDsToModify ¶
func SetIDsToModify( ctx context.Context, plan, state types.Set, ) (idsToAdd, idsToRemove []string, diags diag.Diagnostics)
SetIDsToModify takes a set of IDs from plan and state and returns the IDs to add and remove to get from the state to the plan. idsToAdd is the slice of IDs that are in the plan but not in the state. idsToRemove is the slice of IDs that are in the state but not in the plan. useful for resources with HostGroups, RuleGroups, etc.
func SetInt64FromAPIIfNotZero ¶ added in v0.0.33
SetInt64FromAPIIfNotZero sets an Int64 value from API response, keeping null if current is null and API value is 0.
func SetStringFromAPIIfNotEmpty ¶ added in v0.0.33
SetStringFromAPIIfNotEmpty sets a String value from API response, keeping null if current is null and API value is "".
func SliceToListTypeObject ¶ added in v0.0.29
func SliceToListTypeObject[T any]( ctx context.Context, elems []T, attrs map[string]attr.Type, diags *diag.Diagnostics, ) types.List
SliceToListTypeObject converts []T into types.List with an attr.Type of types.Object{}. Empty or null []T will result in an types.List with the state of Known. Nil pointers in the slice are filtered out before conversion.
func SliceToListTypeString ¶ added in v0.0.29
func SliceToListTypeString( ctx context.Context, elems []string, diags *diag.Diagnostics, ) types.List
SliceToListTypeString converts []string into types.List with an attr.Type of types.String. Empty []string will result in an empty types.List.
func ValidateEmptyIDs ¶ added in v0.0.20
ValidateEmptyIDs checks if a set contains empty IDs. Returns a attribute error at path.
func ValidateEmptyIDsList ¶ added in v0.0.29
func ValidateEmptyIDsList( ctx context.Context, checkList types.Set, attrPath string, ) diag.Diagnostics
ValidateEmptyIDsList checks if a list contains empty IDs. Returns a attribute error at path.
Types ¶
type SearchQueryInfo ¶ added in v0.0.45
type SearchQueryInfo struct {
APIQuery string // The query to send to the API
ClientFilter func(string) bool // The client-side filter function to apply
NeedsClientFilter bool // Whether client-side filtering is needed
}
SearchQueryInfo represents the information needed for querying and filtering.
func ProcessDescriptionSearchPattern ¶ added in v0.0.45
func ProcessDescriptionSearchPattern(pattern string) SearchQueryInfo
ProcessDescriptionSearchPattern processes a description pattern according to the specified rules: Pattern 3: "foo bar" -> API: description:*"foo" + client filter: equals "foo bar" Pattern 4: "foo bar*" -> API: description:*"foo" + client filter: contains "foo bar".
func ProcessNameSearchPattern ¶ added in v0.0.45
func ProcessNameSearchPattern(pattern string) SearchQueryInfo
ProcessNameSearchPattern processes a name pattern according to the specified rules: Pattern 1: "foo bar" -> API: name.raw:"foo bar" (exact match) Pattern 2: "foo bar*" -> API: name:*"foo" + client filter: contains "foo bar".
func ProcessUserFieldSearchPattern ¶ added in v0.0.45
func ProcessUserFieldSearchPattern(pattern, fieldName string) SearchQueryInfo
ProcessUserFieldSearchPattern processes a user field pattern (created_by, modified_by) according to the following rules: - Split on "@" to get username part for API query - Use exact matching (no wildcard) or contains matching (with wildcard) - Case-sensitive matching for user fields.
type TerraformObjectConvertible ¶ added in v0.0.33
TerraformObjectConvertible is an interface for models that can be converted to Terraform objects.