Change how namespaces are specified for the CLI (#6960)
This commit is contained in:
parent
af1d101937
commit
5c56aab3be
|
@ -71,6 +71,10 @@ const (
|
|||
// client in this package but is defined here for consistency with all the
|
||||
// other ENV names we use.
|
||||
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
|
||||
|
@ -427,6 +431,10 @@ func defaultConfig(transportFn func() *http.Transport) *Config {
|
|||
}
|
||||
}
|
||||
|
||||
if v := os.Getenv(HTTPNamespaceEnvName); v != "" {
|
||||
config.Namespace = v
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ func (f *HTTPFlags) ServerFlags() *flag.FlagSet {
|
|||
|
||||
func (f *HTTPFlags) NamespaceFlags() *flag.FlagSet {
|
||||
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
||||
// TODO (namespaces) Do we want to allow setting via an env var? CONSUL_NAMESPACE
|
||||
fs.Var(&f.namespace, "ns",
|
||||
fs.Var(&f.namespace, "namespace",
|
||||
"Specifies the namespace to query. If not provided, the namespace will"+
|
||||
"default to the `default` namespace. Namespaces is a Consul Enterprise feature.")
|
||||
return fs
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
* `-ns=<string>` - Specifies the namespace to query. If not provided, the namespace
|
||||
will default to the `default` namespace. Namespaces is a Consul Enterprise feature added in v1.7.0.
|
||||
* `-namespace=<string>` - Specifies the namespace to query. If not provided, the namespace will default
|
||||
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