khenaidoo | 5fc5cea | 2021-08-11 17:39:16 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | // Package env acts a single source of definition for all environment variables |
| 20 | // related to the xDS implementation in gRPC. |
| 21 | package env |
| 22 | |
| 23 | import ( |
| 24 | "os" |
| 25 | "strings" |
| 26 | ) |
| 27 | |
| 28 | const ( |
| 29 | // BootstrapFileNameEnv is the env variable to set bootstrap file name. |
| 30 | // Do not use this and read from env directly. Its value is read and kept in |
| 31 | // variable BootstrapFileName. |
| 32 | // |
| 33 | // When both bootstrap FileName and FileContent are set, FileName is used. |
| 34 | BootstrapFileNameEnv = "GRPC_XDS_BOOTSTRAP" |
| 35 | // BootstrapFileContentEnv is the env variable to set bootstrapp file |
| 36 | // content. Do not use this and read from env directly. Its value is read |
| 37 | // and kept in variable BootstrapFileName. |
| 38 | // |
| 39 | // When both bootstrap FileName and FileContent are set, FileName is used. |
| 40 | BootstrapFileContentEnv = "GRPC_XDS_BOOTSTRAP_CONFIG" |
| 41 | |
| 42 | ringHashSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" |
| 43 | clientSideSecuritySupportEnv = "GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT" |
| 44 | aggregateAndDNSSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER" |
| 45 | retrySupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY" |
| 46 | rbacSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RBAC" |
| 47 | |
| 48 | c2pResolverSupportEnv = "GRPC_EXPERIMENTAL_GOOGLE_C2P_RESOLVER" |
| 49 | c2pResolverTestOnlyTrafficDirectorURIEnv = "GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI" |
| 50 | ) |
| 51 | |
| 52 | var ( |
| 53 | // BootstrapFileName holds the name of the file which contains xDS bootstrap |
| 54 | // configuration. Users can specify the location of the bootstrap file by |
| 55 | // setting the environment variable "GRPC_XDS_BOOTSTRAP". |
| 56 | // |
| 57 | // When both bootstrap FileName and FileContent are set, FileName is used. |
| 58 | BootstrapFileName = os.Getenv(BootstrapFileNameEnv) |
| 59 | // BootstrapFileContent holds the content of the xDS bootstrap |
| 60 | // configuration. Users can specify the bootstrap config by |
| 61 | // setting the environment variable "GRPC_XDS_BOOTSTRAP_CONFIG". |
| 62 | // |
| 63 | // When both bootstrap FileName and FileContent are set, FileName is used. |
| 64 | BootstrapFileContent = os.Getenv(BootstrapFileContentEnv) |
| 65 | // RingHashSupport indicates whether ring hash support is enabled, which can |
| 66 | // be disabled by setting the environment variable |
| 67 | // "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" to "false". |
| 68 | RingHashSupport = !strings.EqualFold(os.Getenv(ringHashSupportEnv), "false") |
| 69 | // ClientSideSecuritySupport is used to control processing of security |
| 70 | // configuration on the client-side. |
| 71 | // |
| 72 | // Note that there is no env var protection for the server-side because we |
| 73 | // have a brand new API on the server-side and users explicitly need to use |
| 74 | // the new API to get security integration on the server. |
| 75 | ClientSideSecuritySupport = !strings.EqualFold(os.Getenv(clientSideSecuritySupportEnv), "false") |
| 76 | // AggregateAndDNSSupportEnv indicates whether processing of aggregated |
| 77 | // cluster and DNS cluster is enabled, which can be enabled by setting the |
| 78 | // environment variable |
| 79 | // "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER" to |
| 80 | // "true". |
| 81 | AggregateAndDNSSupportEnv = strings.EqualFold(os.Getenv(aggregateAndDNSSupportEnv), "true") |
| 82 | |
| 83 | // RetrySupport indicates whether xDS retry is enabled. |
| 84 | RetrySupport = !strings.EqualFold(os.Getenv(retrySupportEnv), "false") |
| 85 | |
| 86 | // RBACSupport indicates whether xDS configured RBAC HTTP Filter is enabled. |
| 87 | RBACSupport = strings.EqualFold(os.Getenv(rbacSupportEnv), "true") |
| 88 | |
| 89 | // C2PResolverSupport indicates whether support for C2P resolver is enabled. |
| 90 | // This can be enabled by setting the environment variable |
| 91 | // "GRPC_EXPERIMENTAL_GOOGLE_C2P_RESOLVER" to "true". |
| 92 | C2PResolverSupport = strings.EqualFold(os.Getenv(c2pResolverSupportEnv), "true") |
| 93 | // C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing. |
| 94 | C2PResolverTestOnlyTrafficDirectorURI = os.Getenv(c2pResolverTestOnlyTrafficDirectorURIEnv) |
| 95 | ) |