@@ -4,6 +4,8 @@ package provider
44
55import (
66 "fmt"
7+ "math/rand"
8+ "time"
79
810 "strconv"
911
@@ -13,6 +15,9 @@ import (
1315 "github.com/hashicorp/terraform/helper/schema"
1416)
1517
18+ const charset = "abcdefghijklmnopqrstuvwxyz" +
19+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
20+
1621func literalTypeHashCodeForSets (m interface {}) int {
1722 return hashcode .String (fmt .Sprintf ("%v" , m ))
1823}
@@ -82,6 +87,18 @@ func int64StringDiffSuppressFunction(key string, old string, new string, d *sche
8287 return oldIntVal == newIntVal
8388}
8489
90+ func timeDiffSuppressFunction (key string , old string , new string , d * schema.ResourceData ) bool {
91+ oldTime , err := time .Parse (time .RFC3339Nano , old )
92+ if err != nil {
93+ return false
94+ }
95+ newTime , err := time .Parse (time .RFC3339Nano , new )
96+ if err != nil {
97+ return false
98+ }
99+ return oldTime .Equal (newTime )
100+ }
101+
85102func convertMapOfStringSlicesToMapOfStrings (rm map [string ][]string ) (map [string ]string , error ) {
86103 result := map [string ]string {}
87104 for k , v := range rm {
@@ -94,3 +111,13 @@ func convertMapOfStringSlicesToMapOfStrings(rm map[string][]string) (map[string]
94111 }
95112 return result , nil
96113}
114+
115+ func randomString (length int , charset string ) string {
116+ var seededRand * rand.Rand = rand .New (
117+ rand .NewSource (time .Now ().UnixNano ()))
118+ b := make ([]byte , length )
119+ for i := range b {
120+ b [i ] = charset [seededRand .Intn (len (charset ))]
121+ }
122+ return string (b )
123+ }
0 commit comments