khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [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 envconfig |
| 20 | |
| 21 | import ( |
| 22 | "os" |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 23 | ) |
| 24 | |
| 25 | const ( |
| 26 | // XDSBootstrapFileNameEnv is the env variable to set bootstrap file name. |
| 27 | // Do not use this and read from env directly. Its value is read and kept in |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 28 | // variable XDSBootstrapFileName. |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 29 | // |
| 30 | // When both bootstrap FileName and FileContent are set, FileName is used. |
| 31 | XDSBootstrapFileNameEnv = "GRPC_XDS_BOOTSTRAP" |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 32 | // XDSBootstrapFileContentEnv is the env variable to set bootstrap file |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 33 | // content. Do not use this and read from env directly. Its value is read |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 34 | // and kept in variable XDSBootstrapFileContent. |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 35 | // |
| 36 | // When both bootstrap FileName and FileContent are set, FileName is used. |
| 37 | XDSBootstrapFileContentEnv = "GRPC_XDS_BOOTSTRAP_CONFIG" |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 38 | ) |
| 39 | |
| 40 | var ( |
| 41 | // XDSBootstrapFileName holds the name of the file which contains xDS |
| 42 | // bootstrap configuration. Users can specify the location of the bootstrap |
| 43 | // file by setting the environment variable "GRPC_XDS_BOOTSTRAP". |
| 44 | // |
| 45 | // When both bootstrap FileName and FileContent are set, FileName is used. |
| 46 | XDSBootstrapFileName = os.Getenv(XDSBootstrapFileNameEnv) |
| 47 | // XDSBootstrapFileContent holds the content of the xDS bootstrap |
| 48 | // configuration. Users can specify the bootstrap config by setting the |
| 49 | // environment variable "GRPC_XDS_BOOTSTRAP_CONFIG". |
| 50 | // |
| 51 | // When both bootstrap FileName and FileContent are set, FileName is used. |
| 52 | XDSBootstrapFileContent = os.Getenv(XDSBootstrapFileContentEnv) |
| 53 | // XDSRingHash indicates whether ring hash support is enabled, which can be |
| 54 | // disabled by setting the environment variable |
| 55 | // "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" to "false". |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 56 | XDSRingHash = boolFromEnv("GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH", true) |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 57 | // XDSClientSideSecurity is used to control processing of security |
| 58 | // configuration on the client-side. |
| 59 | // |
| 60 | // Note that there is no env var protection for the server-side because we |
| 61 | // have a brand new API on the server-side and users explicitly need to use |
| 62 | // the new API to get security integration on the server. |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 63 | XDSClientSideSecurity = boolFromEnv("GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT", true) |
| 64 | // XDSAggregateAndDNS indicates whether processing of aggregated cluster and |
| 65 | // DNS cluster is enabled, which can be disabled by setting the environment |
| 66 | // variable "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER" |
| 67 | // to "false". |
| 68 | XDSAggregateAndDNS = boolFromEnv("GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER", true) |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 69 | |
| 70 | // XDSRBAC indicates whether xDS configured RBAC HTTP Filter is enabled, |
| 71 | // which can be disabled by setting the environment variable |
| 72 | // "GRPC_XDS_EXPERIMENTAL_RBAC" to "false". |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 73 | XDSRBAC = boolFromEnv("GRPC_XDS_EXPERIMENTAL_RBAC", true) |
| 74 | // XDSOutlierDetection indicates whether outlier detection support is |
| 75 | // enabled, which can be disabled by setting the environment variable |
| 76 | // "GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION" to "false". |
| 77 | XDSOutlierDetection = boolFromEnv("GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION", true) |
| 78 | // XDSFederation indicates whether federation support is enabled, which can |
| 79 | // be enabled by setting the environment variable |
| 80 | // "GRPC_EXPERIMENTAL_XDS_FEDERATION" to "true". |
| 81 | XDSFederation = boolFromEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION", true) |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 82 | |
| 83 | // XDSRLS indicates whether processing of Cluster Specifier plugins and |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 84 | // support for the RLS CLuster Specifier is enabled, which can be disabled by |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 85 | // setting the environment variable "GRPC_EXPERIMENTAL_XDS_RLS_LB" to |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 86 | // "false". |
| 87 | XDSRLS = boolFromEnv("GRPC_EXPERIMENTAL_XDS_RLS_LB", true) |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 88 | |
| 89 | // C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing. |
Akash Kankanala | 761955c | 2024-02-21 19:32:20 +0530 | [diff] [blame^] | 90 | C2PResolverTestOnlyTrafficDirectorURI = os.Getenv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI") |
| 91 | // XDSCustomLBPolicy indicates whether Custom LB Policies are enabled, which |
| 92 | // can be disabled by setting the environment variable |
| 93 | // "GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG" to "false". |
| 94 | XDSCustomLBPolicy = boolFromEnv("GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG", true) |
khenaidoo | 257f319 | 2021-12-15 16:46:37 -0500 | [diff] [blame] | 95 | ) |