dubbo.apache.org/dubbo-go/v3@v3.1.1/xds/credentials/env.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 package credentials 19 20 import ( 21 "os" 22 ) 23 24 const ( 25 DefaultKubernetesServiceAccountPath = "/var/run/secrets/kubernetes.io/serviceaccount/token" 26 DefaultIsitoCaServiceAccountPath = "/var/run/secrets/tokens/istio-token" 27 DefaultRootCertPath = "/var/run/secrets/istio/root-cert.pem" 28 DefaultIstioCAEndpoint = "istiod.istio-system.svc:15012" 29 DefaultCertSigner = "kubernetes.default.svc" 30 DefaultClusterID = "Kubernetes" 31 ) 32 33 var ( 34 PodNamespace = f(os.Getenv("POD_NAMESPACE"), "default") 35 CertTTL = f(os.Getenv("CERT_TTL"), "31536000") 36 RootCertPath = f(os.Getenv("ROOT_CERT_PATH"), DefaultRootCertPath) 37 IstioCAEndpoint = f(os.Getenv("ISTIO_CA_ENDPOINT"), DefaultIstioCAEndpoint) 38 ServiceAccountPath = f(os.Getenv("SERVICE_ACCOUNT_PATH"), DefaultIsitoCaServiceAccountPath) 39 certSigner = f(os.Getenv("CERT_SIGNER"), DefaultCertSigner) 40 clusterID = f(os.Getenv("CLUSTER_ID"), DefaultClusterID) 41 URIPrefix = f(os.Getenv("URI_PREFIX"), "spiffe://") 42 Domain = f(os.Getenv("DOMAIN"), "cluster.local") 43 ServiceAccountName = f(os.Getenv("SERVICE_ACCOUNT_NAME"), "default") 44 ) 45 46 var f = func(a, b string) string { 47 if "" == a { 48 return b 49 } 50 return a 51 }