mirror of
https://github.com/rancher/norman.git
synced 2025-09-16 23:29:16 +00:00
Update template to use no change update env var
This commit is contained in:
@@ -2,6 +2,7 @@ package generator
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
@@ -9,6 +10,10 @@ import (
|
||||
"github.com/rancher/norman/types/convert"
|
||||
)
|
||||
|
||||
const (
|
||||
managementContextType = "mgmt"
|
||||
)
|
||||
|
||||
func funcs() template.FuncMap {
|
||||
return template.FuncMap{
|
||||
"capitalize": convert.Capitalize,
|
||||
@@ -53,3 +58,21 @@ func getCollectionOutput(output, codeName string) string {
|
||||
}
|
||||
return convert.Capitalize(output)
|
||||
}
|
||||
|
||||
// SyncOnlyChangedObjects check whether the CATTLE_SKIP_NO_CHANGE_UPDATE env var is
|
||||
// configured to skip the update handler for events on the management context
|
||||
// that do not contain a change to the object.
|
||||
func SyncOnlyChangedObjects() bool {
|
||||
skipNoChangeUpdate := os.Getenv("CATTLE_SYNC_ONLY_CHANGED_OBJECTS")
|
||||
if skipNoChangeUpdate == "" {
|
||||
return false
|
||||
}
|
||||
parts := strings.Split(skipNoChangeUpdate, ",")
|
||||
|
||||
for _, part := range parts {
|
||||
if part == managementContextType {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user