1- package provider
1+ package common
22
33import (
44 "fmt"
@@ -8,21 +8,21 @@ import (
88 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
99)
1010
11- // schemaDiffFloat32 is a SchemaDiffSuppressFunc for diffing float32 values.
11+ // SchemaDiffFloat32 is a SchemaDiffSuppressFunc for diffing float32 values.
1212// schema.TypeFloat uses float64, which is a problem for API types that use
1313// float32. Terraform automatically converts float32 to float64 which changes
1414// the precision and causes incorrect diffs.
1515//
1616// For example, synthetic_monitoring.Probe.Latitude is float32. Attempting to
1717// set grafanacloud_synthetic_monitoring_probe.latitude to 27.98606 results in
1818// 27.986059188842773. The solution is to diff old and new values as float32.
19- func schemaDiffFloat32 (k , old string , nw string , d * schema.ResourceData ) bool {
19+ func SchemaDiffFloat32 (k , old string , nw string , d * schema.ResourceData ) bool {
2020 old32 , _ := strconv .ParseFloat (old , 32 )
2121 nw32 , _ := strconv .ParseFloat (nw , 32 )
2222 return old32 == nw32
2323}
2424
25- func cloneResourceSchemaForDatasource (r * schema.Resource , updates map [string ]* schema.Schema ) map [string ]* schema.Schema {
25+ func CloneResourceSchemaForDatasource (r * schema.Resource , updates map [string ]* schema.Schema ) map [string ]* schema.Schema {
2626 resourceSchema := r .Schema
2727 clone := make (map [string ]* schema.Schema )
2828 for k , v := range resourceSchema {
@@ -47,6 +47,6 @@ func cloneResourceSchemaForDatasource(r *schema.Resource, updates map[string]*sc
4747 return clone
4848}
4949
50- func allowedValuesDescription (description string , allowedValues []string ) string {
50+ func AllowedValuesDescription (description string , allowedValues []string ) string {
5151 return fmt .Sprintf ("%s. Allowed values: `%s`." , description , strings .Join (allowedValues , "`, `" ))
5252}
0 commit comments