Skip to content

Commit

Permalink
Merge pull request #20 from datainfrahq/Fix-19-Lookup
Browse files Browse the repository at this point in the history
Fix-19-Lookup
  • Loading branch information
AdheipSingh authored May 1, 2023
2 parents 26674c2 + 2320fda commit 2b065c1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/datainfrahq/operator-runtime
go 1.19

require (
github.com/go-logr/logr v1.2.3
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.2
k8s.io/client-go v0.26.1
Expand All @@ -13,7 +14,6 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
Expand Down
22 changes: 22 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import (
"crypto/sha1"
"encoding/base64"
"encoding/json"
"os"
"time"

"github.com/go-logr/logr"
"sigs.k8s.io/controller-runtime/pkg/client"
)

const (
ReconcileWait string = "RECONCILE_WAIT"
)

type ConfigMapHash struct {
Object client.Object
}
Expand Down Expand Up @@ -69,3 +76,18 @@ func unique[T comparable](s []T) []T {
}
return result
}

func LookupReconcileTime(log logr.Logger) time.Duration {
val, exists := os.LookupEnv(ReconcileWait)
if !exists {
return time.Second * 10
} else {
v, err := time.ParseDuration(val)
if err != nil {
log.Error(err, err.Error())
// Exit Program if not valid
os.Exit(1)
}
return v
}
}

0 comments on commit 2b065c1

Please sign in to comment.