Documentation ¶
Index ¶
- Constants
- Variables
- func AllowedValuesDescription(description string, allowedValues []string) string
- func CheckReadError(resourceType string, d *schema.ResourceData, err error) (returnValue diag.Diagnostics, shouldReturn bool)
- func CloneResourceSchemaForDatasource(r *schema.Resource, updates map[string]*schema.Schema) map[string]*schema.Schema
- func ComputedInt() *schema.Schema
- func ComputedIntWithDescription(description string) *schema.Schema
- func ComputedString() *schema.Schema
- func ComputedStringWithDescription(description string) *schema.Schema
- func Int32SliceToIntList(list []int32) []interface{}
- func Int32SliceToSet(src []int32) *schema.Set
- func IsNotFoundError(err error) bool
- func JSONBytesEqual(b1, b2 []byte) bool
- func ListOfSetsToStringSlice(listSet []interface{}) [][]string
- func ListToIntSlice[T int | int64](src []interface{}) []T
- func ListToStringSlice(src []interface{}) []string
- func Ref[T any](v T) *T
- func SchemaDiffFloat32(k, old string, nw string, d *schema.ResourceData) bool
- func SetToIntSlice[T int | int64](src *schema.Set) []T
- func SetToStringSlice(src *schema.Set) []string
- func StringSliceToList(list []string) []interface{}
- func StringSliceToSet(src []string) *schema.Set
- func SuppressEquivalentJSONDiffs(k, old, new string, d *schema.ResourceData) bool
- func UnpackMap[T any](m interface{}) map[string]T
- func ValidateDuration(i interface{}, p cty.Path) diag.Diagnostics
- func ValidateDurationWithDays(i interface{}, p cty.Path) diag.Diagnostics
- func WarnMissing(resourceType string, d *schema.ResourceData) diag.Diagnostics
- func WithAlertingMutex[...](f T) T
- type Client
- type Resource
- type ResourceID
- type ResourceIDField
- type ResourceIDFieldType
Constants ¶
const ( ResourceIDFieldTypeInt = ResourceIDFieldType("int") ResourceIDFieldTypeString = ResourceIDFieldType("string") )
const NotFoundError = "status: 404"
Variables ¶
var ( IDRegexp = regexp.MustCompile(`^\d+$`) UIDRegexp = regexp.MustCompile(`^[a-zA-Z0-9-_]+$`) EmailRegexp = regexp.MustCompile(`.+\@.+\..+`) SHA256Regexp = regexp.MustCompile(`^[A-Fa-f0-9]{64}$`) )
Functions ¶
func CheckReadError ¶
func CheckReadError(resourceType string, d *schema.ResourceData, err error) (returnValue diag.Diagnostics, shouldReturn bool)
CheckReadError checks for common cases on resource read/delete paths: - If the resource no longer exists and 404s, it should be removed from state and return nil, to stop processing the read. - If there is an error, return the error. - Otherwise, do not return to continue processing the read.
func ComputedInt ¶
func ComputedString ¶
func Int32SliceToIntList ¶
func Int32SliceToIntList(list []int32) []interface{}
func Int32SliceToSet ¶
func IsNotFoundError ¶
func JSONBytesEqual ¶
func ListOfSetsToStringSlice ¶
func ListOfSetsToStringSlice(listSet []interface{}) [][]string
func ListToIntSlice ¶
func ListToStringSlice ¶
func ListToStringSlice(src []interface{}) []string
func SchemaDiffFloat32 ¶
func SchemaDiffFloat32(k, old string, nw string, d *schema.ResourceData) bool
SchemaDiffFloat32 is a SchemaDiffSuppressFunc for diffing float32 values. schema.TypeFloat uses float64, which is a problem for API types that use float32. Terraform automatically converts float32 to float64 which changes the precision and causes incorrect diffs.
For example, synthetic_monitoring.Probe.Latitude is float32. Attempting to set grafanacloud_synthetic_monitoring_probe.latitude to 27.98606 results in 27.986059188842773. The solution is to diff old and new values as float32.
func SetToStringSlice ¶
func StringSliceToList ¶
func StringSliceToList(list []string) []interface{}
func StringSliceToSet ¶
func SuppressEquivalentJSONDiffs ¶
func SuppressEquivalentJSONDiffs(k, old, new string, d *schema.ResourceData) bool
func ValidateDuration ¶
func ValidateDuration(i interface{}, p cty.Path) diag.Diagnostics
func ValidateDurationWithDays ¶
func ValidateDurationWithDays(i interface{}, p cty.Path) diag.Diagnostics
func WarnMissing ¶
func WarnMissing(resourceType string, d *schema.ResourceData) diag.Diagnostics
func WithAlertingMutex ¶
func WithAlertingMutex[T schema.CreateContextFunc | schema.ReadContextFunc | schema.UpdateContextFunc | schema.DeleteContextFunc](f T) T
WithAlertingMutex is a helper function that wraps a CRUD Terraform function with a mutex.
Types ¶
type Client ¶
type Client struct { GrafanaAPIURL string GrafanaAPIURLParsed *url.URL GrafanaAPI *goapi.GrafanaHTTPAPI GrafanaAPIConfig *goapi.TransportConfig GrafanaCloudAPI *gcom.APIClient SMAPI *SMAPI.Client MLAPI *mlapi.Client OnCallClient *onCallAPI.Client SLOClient *slo.APIClient // contains filtered or unexported fields }
func (*Client) GrafanaSubpath ¶
type Resource ¶
type Resource struct { Name string IDType *ResourceID Schema *schema.Resource PluginFrameworkSchema resource.ResourceWithConfigure }
func NewLegacySDKResource ¶ added in v2.15.0
func NewLegacySDKResource(name string, idType *ResourceID, schema *schema.Resource) *Resource
func NewResource ¶
func NewResource(name string, idType *ResourceID, schema resource.ResourceWithConfigure) *Resource
func (*Resource) ImportExample ¶
type ResourceID ¶
type ResourceID struct {
// contains filtered or unexported fields
}
func NewResourceID ¶
func NewResourceID(expectedFields ...ResourceIDField) *ResourceID
func NewResourceIDWithLegacySeparator
deprecated
func NewResourceIDWithLegacySeparator(legacySeparator string, expectedFields ...ResourceIDField) *ResourceID
Deprecated: Use NewResourceID instead We should standardize on a single separator, so that function should only be used for old resources On major versions, switch to NewResourceID and remove uses of this function
func (*ResourceID) Fields ¶ added in v2.16.0
func (id *ResourceID) Fields() []ResourceIDField
func (*ResourceID) Make ¶
func (id *ResourceID) Make(parts ...any) string
Make creates a resource ID from the given parts The parts must have the correct number of fields and types
func (*ResourceID) RequiredFields ¶ added in v2.15.0
func (id *ResourceID) RequiredFields() []ResourceIDField
type ResourceIDField ¶
type ResourceIDField struct { Name string Type ResourceIDFieldType Optional bool }
func IntIDField ¶
func IntIDField(name string) ResourceIDField
func OptionalIntIDField ¶ added in v2.15.0
func OptionalIntIDField(name string) ResourceIDField
func OptionalStringIDField ¶ added in v2.15.0
func OptionalStringIDField(name string) ResourceIDField
func StringIDField ¶
func StringIDField(name string) ResourceIDField
type ResourceIDFieldType ¶
type ResourceIDFieldType string