support configuration domain suffix (#460) (#463)

Co-authored-by: 澄潭 <zty98751@alibaba-inc.com>
This commit is contained in:
teijin
2023-08-07 16:26:51 +08:00
committed by GitHub
parent d307d0e755
commit 8c206a6456
2 changed files with 8 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ import (
"fmt"
"path"
"strings"
"os"
"github.com/gogo/protobuf/types"
"github.com/golang/protobuf/jsonpb"
@@ -30,6 +31,7 @@ import (
)
const DefaultDomainSuffix = "cluster.local"
var domainSuffix = os.Getenv("DOMAIN_SUFFIX")
type ClusterNamespacedName struct {
model.NamespacedName
@@ -80,7 +82,10 @@ func MessageToGoGoStruct(msg proto.Message) (*types.Struct, error) {
}
func CreateServiceFQDN(namespace, name string) string {
return fmt.Sprintf("%s.%s.svc.%s", name, namespace, DefaultDomainSuffix)
if domainSuffix == "" {
domainSuffix = DefaultDomainSuffix
}
return fmt.Sprintf("%s.%s.svc.%s", name, namespace, domainSuffix)
}
func BuildPatchStruct(config string) *types.Struct {