xds.go 4.4 KB

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