blob: 9bad03cec64f0a82e06e81d49850987ae43b7720 [file] [log] [blame]
khenaidoo257f3192021-12-15 16:46:37 -05001/*
2 *
3 * Copyright 2020 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19package envconfig
20
21import (
22 "os"
23 "strings"
24)
25
26const (
27 // XDSBootstrapFileNameEnv is the env variable to set bootstrap file name.
28 // Do not use this and read from env directly. Its value is read and kept in
29 // variable BootstrapFileName.
30 //
31 // When both bootstrap FileName and FileContent are set, FileName is used.
32 XDSBootstrapFileNameEnv = "GRPC_XDS_BOOTSTRAP"
33 // XDSBootstrapFileContentEnv is the env variable to set bootstrapp file
34 // content. Do not use this and read from env directly. Its value is read
35 // and kept in variable BootstrapFileName.
36 //
37 // When both bootstrap FileName and FileContent are set, FileName is used.
38 XDSBootstrapFileContentEnv = "GRPC_XDS_BOOTSTRAP_CONFIG"
39
40 ringHashSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH"
41 clientSideSecuritySupportEnv = "GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT"
42 aggregateAndDNSSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER"
43 rbacSupportEnv = "GRPC_XDS_EXPERIMENTAL_RBAC"
44 federationEnv = "GRPC_EXPERIMENTAL_XDS_FEDERATION"
45 rlsInXDSEnv = "GRPC_EXPERIMENTAL_XDS_RLS_LB"
46
47 c2pResolverTestOnlyTrafficDirectorURIEnv = "GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI"
48)
49
50var (
51 // XDSBootstrapFileName holds the name of the file which contains xDS
52 // bootstrap configuration. Users can specify the location of the bootstrap
53 // file by setting the environment variable "GRPC_XDS_BOOTSTRAP".
54 //
55 // When both bootstrap FileName and FileContent are set, FileName is used.
56 XDSBootstrapFileName = os.Getenv(XDSBootstrapFileNameEnv)
57 // XDSBootstrapFileContent holds the content of the xDS bootstrap
58 // configuration. Users can specify the bootstrap config by setting the
59 // environment variable "GRPC_XDS_BOOTSTRAP_CONFIG".
60 //
61 // When both bootstrap FileName and FileContent are set, FileName is used.
62 XDSBootstrapFileContent = os.Getenv(XDSBootstrapFileContentEnv)
63 // XDSRingHash indicates whether ring hash support is enabled, which can be
64 // disabled by setting the environment variable
65 // "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" to "false".
66 XDSRingHash = !strings.EqualFold(os.Getenv(ringHashSupportEnv), "false")
67 // XDSClientSideSecurity is used to control processing of security
68 // configuration on the client-side.
69 //
70 // Note that there is no env var protection for the server-side because we
71 // have a brand new API on the server-side and users explicitly need to use
72 // the new API to get security integration on the server.
73 XDSClientSideSecurity = !strings.EqualFold(os.Getenv(clientSideSecuritySupportEnv), "false")
74 // XDSAggregateAndDNS indicates whether processing of aggregated cluster
75 // and DNS cluster is enabled, which can be enabled by setting the
76 // environment variable
77 // "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER" to
78 // "true".
79 XDSAggregateAndDNS = strings.EqualFold(os.Getenv(aggregateAndDNSSupportEnv), "true")
80
81 // XDSRBAC indicates whether xDS configured RBAC HTTP Filter is enabled,
82 // which can be disabled by setting the environment variable
83 // "GRPC_XDS_EXPERIMENTAL_RBAC" to "false".
84 XDSRBAC = !strings.EqualFold(os.Getenv(rbacSupportEnv), "false")
85
86 // XDSFederation indicates whether federation support is enabled.
87 XDSFederation = strings.EqualFold(os.Getenv(federationEnv), "true")
88
89 // XDSRLS indicates whether processing of Cluster Specifier plugins and
90 // support for the RLS CLuster Specifier is enabled, which can be enabled by
91 // setting the environment variable "GRPC_EXPERIMENTAL_XDS_RLS_LB" to
92 // "true".
93 XDSRLS = strings.EqualFold(os.Getenv(rlsInXDSEnv), "true")
94
95 // C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing.
96 C2PResolverTestOnlyTrafficDirectorURI = os.Getenv(c2pResolverTestOnlyTrafficDirectorURIEnv)
97)