utils

package
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SKEServiceId          = "cloud.stackit.ske"
	ModelServingServiceId = "cloud.stackit.model-serving"
)

Variables

View Source
var (
	LegacyProjectRoles = []string{"project.admin", "project.auditor", "project.member", "project.owner"}
)

Functions

func AdaptRegion

func AdaptRegion(ctx context.Context, configRegion types.String, planRegion *types.String, defaultRegion string, resp *resource.ModifyPlanResponse)

AdaptRegion rewrites the region of a terraform plan

func BuildInternalTerraformId

func BuildInternalTerraformId(idParts ...string) types.String

func CheckListRemoval

func CheckListRemoval(ctx context.Context, configModelList, planModelList types.List, destination path.Path, listType attr.Type, createEmptyList bool, resp *resource.ModifyPlanResponse)

If a List was completely removed from the terraform config this is not recognized by terraform. This helper function checks if that is the case and adjusts the plan accordingly.

func ConvertPointerSliceToStringSlice

func ConvertPointerSliceToStringSlice(pointerSlice []*string) []string

ConvertPointerSliceToStringSlice safely converts a slice of string pointers to a slice of strings.

func FormatPossibleValues

func FormatPossibleValues(values ...string) string

FormatPossibleValues formats a slice into a comma-separated-list for usage in the provider docs

func GetTimeFromStringAttribute

func GetTimeFromStringAttribute(ctx context.Context, attributePath path.Path, source attributeGetter, dateFormat string, target *time.Time) (diags diag.Diagnostics)

GetTimeFromStringAttribute retrieves a string attribute from e.g. a [plan.Plan], tfsdk.Config or a tfsdk.State and converts it to a time.Time object with a given format, if possible.

func IsLegacyProjectRole

func IsLegacyProjectRole(role string) bool

func IsUndefined

func IsUndefined(val value) bool

IsUndefined checks if a passed value is unknown or null

func ListValuetoStringSlice

func ListValuetoStringSlice(list basetypes.ListValue) ([]string, error)

func LogError

func LogError(ctx context.Context, inputDiags *diag.Diagnostics, err error, summary, defaultDescription string, descriptions map[int]string)

LogError logs errors. In descriptions different messages for http status codes can be passed. When no one matches the defaultDescription will be used

func ReconcileStringSlices

func ReconcileStringSlices(list1, list2 []string) []string

ReconcileStringSlices reconciles two string lists by removing elements from the first list that are not in the second list and appending elements from the second list that are not in the first list. This preserves the order of the elements in the first list that are also in the second list, which is useful when using ListAttributes in Terraform. The source of truth for the order is the first list and the source of truth for the content is the second list.

func SetAndLogStateFields

func SetAndLogStateFields(ctx context.Context, diags *diag.Diagnostics, state *tfsdk.State, values map[string]any)

SetAndLogStateFields writes the given map of key-value pairs to the state

func SimplifyBackupSchedule

func SimplifyBackupSchedule(schedule string) string

SimplifyBackupSchedule removes leading 0s from backup schedule numbers (e.g. "00 00 * * *" becomes "0 0 * * *") Needed as the API does it internally and would otherwise cause inconsistent result in Terraform

func ToTime

func ToTime(ctx context.Context, format string, val types.String, target *time.Time) (diags diag.Diagnostics)

func UseStateForUnknownIf

func UseStateForUnknownIf(f UseStateForUnknownIfFunc, description string) planmodifier.String

UseStateForUnknownIf returns a plan modifier similar to UseStateForUnknown with a conditional

func UserAgentConfigOption

func UserAgentConfigOption(providerVersion string) config.ConfigurationOption

Types

type UseStateForUnknownFuncResponse

type UseStateForUnknownFuncResponse struct {
	UseStateForUnknown bool
	Diagnostics        diag.Diagnostics
}

type UseStateForUnknownIfFunc

UseStateForUnknownIfFunc is a conditional function used in UseStateForUnknownIf

Jump to

Keyboard shortcuts

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