mirror of https://github.com/status-im/consul.git
Change how namespaces are specified for the CLI (#6960)
This commit is contained in:
parent
3faee222f2
commit
34e6e23d43
|
@ -71,6 +71,10 @@ const (
|
||||||
// client in this package but is defined here for consistency with all the
|
// client in this package but is defined here for consistency with all the
|
||||||
// other ENV names we use.
|
// other ENV names we use.
|
||||||
GRPCAddrEnvName = "CONSUL_GRPC_ADDR"
|
GRPCAddrEnvName = "CONSUL_GRPC_ADDR"
|
||||||
|
|
||||||
|
// HTTPNamespaceEnvVar defines an environment variable name which sets
|
||||||
|
// the HTTP Namespace to be used by default. This can still be overridden.
|
||||||
|
HTTPNamespaceEnvName = "CONSUL_NAMESPACE"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryOptions are used to parameterize a query
|
// QueryOptions are used to parameterize a query
|
||||||
|
@ -427,6 +431,10 @@ func defaultConfig(transportFn func() *http.Transport) *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v := os.Getenv(HTTPNamespaceEnvName); v != "" {
|
||||||
|
config.Namespace = v
|
||||||
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,7 @@ func (f *HTTPFlags) ServerFlags() *flag.FlagSet {
|
||||||
|
|
||||||
func (f *HTTPFlags) NamespaceFlags() *flag.FlagSet {
|
func (f *HTTPFlags) NamespaceFlags() *flag.FlagSet {
|
||||||
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
// TODO (namespaces) Do we want to allow setting via an env var? CONSUL_NAMESPACE
|
fs.Var(&f.namespace, "namespace",
|
||||||
fs.Var(&f.namespace, "ns",
|
|
||||||
"Specifies the namespace to query. If not provided, the namespace will"+
|
"Specifies the namespace to query. If not provided, the namespace will"+
|
||||||
"default to the `default` namespace. Namespaces is a Consul Enterprise feature.")
|
"default to the `default` namespace. Namespaces is a Consul Enterprise feature.")
|
||||||
return fs
|
return fs
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
* `-ns=<string>` - Specifies the namespace to query. If not provided, the namespace
|
* `-namespace=<string>` - Specifies the namespace to query. If not provided, the namespace will default
|
||||||
will default to the `default` namespace. Namespaces is a Consul Enterprise feature added in v1.7.0.
|
to the value of the `CONSUL_NAMESPACE` environment variable or `default` if neither is set. Namespaces
|
||||||
|
is a Consul Enterprise feature added in v1.7.0.
|
||||||
|
|
Loading…
Reference in New Issue