dubbo.apache.org/dubbo-go/v3@v3.1.1/remoting/xds/mapping/metadata.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 mapping
    19  
    20  import (
    21  	structpb "github.com/golang/protobuf/ptypes/struct"
    22  )
    23  
    24  import (
    25  	"dubbo.apache.org/dubbo-go/v3/common/constant"
    26  )
    27  
    28  // GetDubboGoMetadata create metadata of dubbo-go-app and register to istiod
    29  func GetDubboGoMetadata(dubboGoMetadata string) *structpb.Struct {
    30  	return &structpb.Struct{
    31  		Fields: map[string]*structpb.Value{
    32  			constant.XDSMetadataClusterIDKey: {
    33  				// Set cluster id to Kubernetes to ensure dubbo-go's xds client can get service
    34  				// istiod.istio-system.svc.cluster.local's
    35  				// pods ip from istiod by eds, to call no-endpoint port of istio like 8080
    36  				Kind: &structpb.Value_StringValue{StringValue: constant.XDSMetadataDefaultDomainName},
    37  			},
    38  			constant.XDSMetadataLabelsKey: {
    39  				Kind: &structpb.Value_StructValue{StructValue: &structpb.Struct{
    40  					Fields: map[string]*structpb.Value{
    41  						constant.XDSMetadataDubboGoMapperKey: {
    42  							Kind: &structpb.Value_StringValue{StringValue: dubboGoMetadata},
    43  						},
    44  					},
    45  				}},
    46  			},
    47  		},
    48  	}
    49  }