2021-09-27 17:01:40 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright 2020 gRPC authors.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-12-20 11:06:52 +01:00
|
|
|
package envconfig
|
2021-09-27 17:01:40 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-12-20 11:06:52 +01:00
|
|
|
// XDSBootstrapFileNameEnv is the env variable to set bootstrap file name.
|
2021-09-27 17:01:40 +02:00
|
|
|
// Do not use this and read from env directly. Its value is read and kept in
|
|
|
|
// variable BootstrapFileName.
|
|
|
|
//
|
|
|
|
// When both bootstrap FileName and FileContent are set, FileName is used.
|
2021-12-20 11:06:52 +01:00
|
|
|
XDSBootstrapFileNameEnv = "GRPC_XDS_BOOTSTRAP"
|
|
|
|
// XDSBootstrapFileContentEnv is the env variable to set bootstrapp file
|
2021-09-27 17:01:40 +02:00
|
|
|
// content. Do not use this and read from env directly. Its value is read
|
|
|
|
// and kept in variable BootstrapFileName.
|
|
|
|
//
|
|
|
|
// When both bootstrap FileName and FileContent are set, FileName is used.
|
2021-12-20 11:06:52 +01:00
|
|
|
XDSBootstrapFileContentEnv = "GRPC_XDS_BOOTSTRAP_CONFIG"
|
2021-09-27 17:01:40 +02:00
|
|
|
|
|
|
|
ringHashSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH"
|
|
|
|
clientSideSecuritySupportEnv = "GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT"
|
|
|
|
aggregateAndDNSSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER"
|
2021-11-08 11:41:15 +01:00
|
|
|
rbacSupportEnv = "GRPC_XDS_EXPERIMENTAL_RBAC"
|
2021-12-20 11:06:52 +01:00
|
|
|
federationEnv = "GRPC_EXPERIMENTAL_XDS_FEDERATION"
|
2022-01-27 12:16:16 +01:00
|
|
|
rlsInXDSEnv = "GRPC_EXPERIMENTAL_XDS_RLS_LB"
|
2021-09-27 17:01:40 +02:00
|
|
|
|
|
|
|
c2pResolverTestOnlyTrafficDirectorURIEnv = "GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2021-12-20 11:06:52 +01:00
|
|
|
// XDSBootstrapFileName holds the name of the file which contains xDS
|
|
|
|
// bootstrap configuration. Users can specify the location of the bootstrap
|
|
|
|
// file by setting the environment variable "GRPC_XDS_BOOTSTRAP".
|
2021-09-27 17:01:40 +02:00
|
|
|
//
|
|
|
|
// When both bootstrap FileName and FileContent are set, FileName is used.
|
2021-12-20 11:06:52 +01:00
|
|
|
XDSBootstrapFileName = os.Getenv(XDSBootstrapFileNameEnv)
|
|
|
|
// XDSBootstrapFileContent holds the content of the xDS bootstrap
|
|
|
|
// configuration. Users can specify the bootstrap config by setting the
|
|
|
|
// environment variable "GRPC_XDS_BOOTSTRAP_CONFIG".
|
2021-09-27 17:01:40 +02:00
|
|
|
//
|
|
|
|
// When both bootstrap FileName and FileContent are set, FileName is used.
|
2021-12-20 11:06:52 +01:00
|
|
|
XDSBootstrapFileContent = os.Getenv(XDSBootstrapFileContentEnv)
|
|
|
|
// XDSRingHash indicates whether ring hash support is enabled, which can be
|
|
|
|
// disabled by setting the environment variable
|
2021-09-27 17:01:40 +02:00
|
|
|
// "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" to "false".
|
2021-12-20 11:06:52 +01:00
|
|
|
XDSRingHash = !strings.EqualFold(os.Getenv(ringHashSupportEnv), "false")
|
|
|
|
// XDSClientSideSecurity is used to control processing of security
|
2021-09-27 17:01:40 +02:00
|
|
|
// configuration on the client-side.
|
|
|
|
//
|
|
|
|
// Note that there is no env var protection for the server-side because we
|
|
|
|
// have a brand new API on the server-side and users explicitly need to use
|
|
|
|
// the new API to get security integration on the server.
|
2021-12-20 11:06:52 +01:00
|
|
|
XDSClientSideSecurity = !strings.EqualFold(os.Getenv(clientSideSecuritySupportEnv), "false")
|
|
|
|
// XDSAggregateAndDNS indicates whether processing of aggregated cluster
|
|
|
|
// and DNS cluster is enabled, which can be enabled by setting the
|
2021-09-27 17:01:40 +02:00
|
|
|
// environment variable
|
|
|
|
// "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER" to
|
|
|
|
// "true".
|
2021-12-20 11:06:52 +01:00
|
|
|
XDSAggregateAndDNS = strings.EqualFold(os.Getenv(aggregateAndDNSSupportEnv), "true")
|
2021-09-27 17:01:40 +02:00
|
|
|
|
2021-12-20 11:06:52 +01:00
|
|
|
// XDSRBAC indicates whether xDS configured RBAC HTTP Filter is enabled,
|
2021-11-08 11:41:15 +01:00
|
|
|
// which can be disabled by setting the environment variable
|
|
|
|
// "GRPC_XDS_EXPERIMENTAL_RBAC" to "false".
|
2021-12-20 11:06:52 +01:00
|
|
|
XDSRBAC = !strings.EqualFold(os.Getenv(rbacSupportEnv), "false")
|
|
|
|
|
|
|
|
// XDSFederation indicates whether federation support is enabled.
|
|
|
|
XDSFederation = strings.EqualFold(os.Getenv(federationEnv), "true")
|
2021-09-27 17:01:40 +02:00
|
|
|
|
2022-01-27 12:16:16 +01:00
|
|
|
// XDSRLS indicates whether processing of Cluster Specifier plugins and
|
|
|
|
// support for the RLS CLuster Specifier is enabled, which can be enabled by
|
|
|
|
// setting the environment variable "GRPC_EXPERIMENTAL_XDS_RLS_LB" to
|
|
|
|
// "true".
|
|
|
|
XDSRLS = strings.EqualFold(os.Getenv(rlsInXDSEnv), "true")
|
|
|
|
|
2021-09-27 17:01:40 +02:00
|
|
|
// C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing.
|
|
|
|
C2PResolverTestOnlyTrafficDirectorURI = os.Getenv(c2pResolverTestOnlyTrafficDirectorURIEnv)
|
|
|
|
)
|