dubbo.apache.org/dubbo-go/v3@v3.1.1/xds/utils/envconfig/xds.go (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. 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 * 20 * Copyright 2020 gRPC authors. 21 * 22 */ 23 24 package envconfig 25 26 import ( 27 "os" 28 "strings" 29 ) 30 31 const ( 32 // XDSBootstrapFileNameEnv is the env variable to set bootstrap file name. 33 // Do not use this and read from env directly. Its value is read and kept in 34 // variable BootstrapFileName. 35 // 36 // When both bootstrap FileName and FileContent are set, FileName is used. 37 XDSBootstrapFileNameEnv = "GRPC_XDS_BOOTSTRAP" 38 // XDSBootstrapFileContentEnv is the env variable to set bootstrapp file 39 // content. Do not use this and read from env directly. Its value is read 40 // and kept in variable BootstrapFileName. 41 // 42 // When both bootstrap FileName and FileContent are set, FileName is used. 43 XDSBootstrapFileContentEnv = "GRPC_XDS_BOOTSTRAP_CONFIG" 44 45 ringHashSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" 46 clientSideSecuritySupportEnv = "GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT" 47 aggregateAndDNSSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER" 48 rbacSupportEnv = "GRPC_XDS_EXPERIMENTAL_RBAC" 49 federationEnv = "GRPC_EXPERIMENTAL_XDS_FEDERATION" 50 rlsInXDSEnv = "GRPC_EXPERIMENTAL_XDS_RLS_LB" 51 52 c2pResolverTestOnlyTrafficDirectorURIEnv = "GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI" 53 ) 54 55 var ( 56 // XDSBootstrapFileName holds the name of the file which contains xDS 57 // bootstrap configuration. Users can specify the location of the bootstrap 58 // file by setting the environment variable "GRPC_XDS_BOOTSTRAP". 59 // 60 // When both bootstrap FileName and FileContent are set, FileName is used. 61 XDSBootstrapFileName = os.Getenv(XDSBootstrapFileNameEnv) 62 // XDSBootstrapFileContent holds the content of the xDS bootstrap 63 // configuration. Users can specify the bootstrap config by setting the 64 // environment variable "GRPC_XDS_BOOTSTRAP_CONFIG". 65 // 66 // When both bootstrap FileName and FileContent are set, FileName is used. 67 XDSBootstrapFileContent = os.Getenv(XDSBootstrapFileContentEnv) 68 // XDSRingHash indicates whether ring hash support is enabled, which can be 69 // disabled by setting the environment variable 70 // "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" to "false". 71 XDSRingHash = !strings.EqualFold(os.Getenv(ringHashSupportEnv), "false") 72 // XDSClientSideSecurity is used to control processing of security 73 // configuration on the client-side. 74 // 75 // Note that there is no env var protection for the server-side because we 76 // have a brand new API on the server-side and users explicitly need to use 77 // the new API to get security integration on the server. 78 XDSClientSideSecurity = false // !strings.EqualFold(os.Getenv(clientSideSecuritySupportEnv), "true") 79 // XDSAggregateAndDNS indicates whether processing of aggregated cluster 80 // and DNS cluster is enabled, which can be enabled by setting the 81 // environment variable 82 // "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER" to 83 // "true". 84 XDSAggregateAndDNS = strings.EqualFold(os.Getenv(aggregateAndDNSSupportEnv), "true") 85 86 // XDSRBAC indicates whether xDS configured RBAC HTTP Filter is enabled, 87 // which can be disabled by setting the environment variable 88 // "GRPC_XDS_EXPERIMENTAL_RBAC" to "false". 89 XDSRBAC = !strings.EqualFold(os.Getenv(rbacSupportEnv), "false") 90 91 // XDSFederation indicates whether federation support is enabled. 92 XDSFederation = strings.EqualFold(os.Getenv(federationEnv), "true") 93 94 // XDSRLS indicates whether processing of Cluster Specifier plugins and 95 // support for the RLS CLuster Specifier is enabled, which can be enabled by 96 // setting the environment variable "GRPC_EXPERIMENTAL_XDS_RLS_LB" to 97 // "true". 98 XDSRLS = strings.EqualFold(os.Getenv(rlsInXDSEnv), "true") 99 100 // C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing. 101 C2PResolverTestOnlyTrafficDirectorURI = os.Getenv(c2pResolverTestOnlyTrafficDirectorURIEnv) 102 )