Skip to content

Commit 8a4ffa3

Browse files
author
Ravi Tandon
committed
Update helpers.go to fix build errors
1 parent 760b6e0 commit 8a4ffa3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

oci/helpers.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package provider
44

55
import (
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+
1621
func 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+
85102
func 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

Comments
 (0)