1 package fn 2 3 import ( 4 "os" 5 6 "sigs.k8s.io/kustomize/kyaml/fn/framework/command" 7 ) 8 9 const ( 10 standaloneEnv = "EDGE_KPT_FN_STANDALONE" 11 ) 12 13 // Standalone reads the environment to determine if this function 14 // should be standalone or not: https://pkg.go.dev/sigs.k8s.io/kustomize/kyaml@v0.10.19/fn/framework/command#Build 15 // 16 // checks for environment variable EDGE_KPT_FN_STANDALONE: 17 // 18 // - if it is present (with any value, or empty value), standalone mode is enabled 19 // 20 // - if it isnt present, standalone mode is disabled 21 func Standalone() command.CLIMode { 22 _, set := os.LookupEnv(standaloneEnv) 23 if set { 24 return command.StandaloneEnabled 25 } 26 27 return command.StandaloneDisabled 28 } 29 30 // EnableStandalone allows enabling standalone mode in Edge Kpt functions 31 // programmatically. 32 // 33 // It is a thin wrapper around the internal constant for the standalone mode 34 // environment variable name. 35 func EnableStandalone() { 36 os.Setenv(standaloneEnv, "true") 37 } 38