diff --git a/internal/pkg/params/params.go b/internal/pkg/params/params.go index 7279595..a2c4038 100644 --- a/internal/pkg/params/params.go +++ b/internal/pkg/params/params.go @@ -103,4 +103,5 @@ var ( CreateStatefulSetPersistentVolumeClaim bool = false StatefulSetPersistentVolumeClaimStorageClass string StatefulSetPersistentVolumeClaimSize string + IgnoreMissingEnv = false // Command line flag to ignore missing environment variables in metagraf.json ) diff --git a/mg/cmd/create-deployment.go b/mg/cmd/create-deployment.go index cfb6659..ef36cfe 100644 --- a/mg/cmd/create-deployment.go +++ b/mg/cmd/create-deployment.go @@ -31,6 +31,7 @@ func init() { createDeploymentCmd.Flags().StringVar(¶ms.PodAntiAffinityTopologyKey, "anti-affinity-topology-key", "", "Define which node label to use as a topologyKey (describing a datacenter, zone or a rack as an example)") createDeploymentCmd.Flags().Int32Var(¶ms.PodAntiAffinityWeight, "pod-anti-affinity-weight", params.PodAntiAffinityWeightDefault, "Weight for WeightedPodAffinityTerm.") createDeploymentCmd.Flags().BoolVar(¶ms.DownwardAPIEnvVars,"downward-api-envvars",false,"Enables generation of environment variables from Downward API. An opinionated selection.") + createDeploymentCmd.Flags().BoolVar(&IgnoreMissingEnv, "ignore-missing-env", false, "Ignore missing environment variables") } var createDeploymentCmd = &cobra.Command{ diff --git a/mg/cmd/properties.go b/mg/cmd/properties.go index d37cf82..6c51031 100644 --- a/mg/cmd/properties.go +++ b/mg/cmd/properties.go @@ -238,4 +238,5 @@ func FlagPassingHack() { modules.OName = OName modules.Context = Context modules.CreateGlobals = CreateGlobals + modules.IgnoreMissingEnv = IgnoreMissingEnv } diff --git a/mg/cmd/root.go b/mg/cmd/root.go index e7ccb5d..189bdcb 100644 --- a/mg/cmd/root.go +++ b/mg/cmd/root.go @@ -61,6 +61,7 @@ var ( // Holds a slice of paths to ignore in mg dev watch cmd. IgnoredPaths []string + IgnoreMissingEnv bool = false // Command line flag to ignore missing environment variables in metagraf.json ) // Array of available config keys diff --git a/pkg/modules/common.go b/pkg/modules/common.go index a2904d2..4f1148f 100644 --- a/pkg/modules/common.go +++ b/pkg/modules/common.go @@ -56,6 +56,7 @@ var ( CreateGlobals bool // Sets the default pull policy for all metagraf modules PullPolicy corev1.PullPolicy = corev1.PullIfNotPresent + IgnoreMissingEnv bool = false ) var Variables metagraf.MGProperties diff --git a/pkg/modules/deployment.go b/pkg/modules/deployment.go index 25a0266..085e51d 100644 --- a/pkg/modules/deployment.go +++ b/pkg/modules/deployment.go @@ -100,7 +100,7 @@ func GenDeployment(mg *metagraf.MetaGraf, namespace string) { } EnvVars, err = GetEnvVars(mg, Variables) - if err != nil { + if err != nil && IgnoreMissingEnv == false { glog.Error(err) panic(err) }