Skip to content

Commit 2b065c1

Browse files
authored
Merge pull request #20 from datainfrahq/Fix-19-Lookup
Fix-19-Lookup
2 parents 26674c2 + 2320fda commit 2b065c1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/datainfrahq/operator-runtime
33
go 1.19
44

55
require (
6+
github.com/go-logr/logr v1.2.3
67
k8s.io/api v0.26.1
78
k8s.io/apimachinery v0.26.2
89
k8s.io/client-go v0.26.1
@@ -13,7 +14,6 @@ require (
1314
github.com/davecgh/go-spew v1.1.1 // indirect
1415
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
1516
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
16-
github.com/go-logr/logr v1.2.3 // indirect
1717
github.com/go-openapi/jsonpointer v0.19.5 // indirect
1818
github.com/go-openapi/jsonreference v0.20.0 // indirect
1919
github.com/go-openapi/swag v0.19.14 // indirect

utils/utils.go

+22
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ import (
44
"crypto/sha1"
55
"encoding/base64"
66
"encoding/json"
7+
"os"
8+
"time"
79

10+
"github.com/go-logr/logr"
811
"sigs.k8s.io/controller-runtime/pkg/client"
912
)
1013

14+
const (
15+
ReconcileWait string = "RECONCILE_WAIT"
16+
)
17+
1118
type ConfigMapHash struct {
1219
Object client.Object
1320
}
@@ -69,3 +76,18 @@ func unique[T comparable](s []T) []T {
6976
}
7077
return result
7178
}
79+
80+
func LookupReconcileTime(log logr.Logger) time.Duration {
81+
val, exists := os.LookupEnv(ReconcileWait)
82+
if !exists {
83+
return time.Second * 10
84+
} else {
85+
v, err := time.ParseDuration(val)
86+
if err != nil {
87+
log.Error(err, err.Error())
88+
// Exit Program if not valid
89+
os.Exit(1)
90+
}
91+
return v
92+
}
93+
}

0 commit comments

Comments
 (0)