func CreateBootstrapConfig()

in src/go/bootstrap/ads/bootstrap.go [30:95]


func CreateBootstrapConfig(opts options.AdsBootstrapperOptions) (string, error) {
	apiVersion := corepb.ApiVersion_V3

	// Parse ADS connect timeout
	connectTimeoutProto := durationpb.New(opts.AdsConnectTimeout)

	bt := &bootstrappb.Bootstrap{
		// Node info
		Node: bt.CreateNode(opts.CommonOptions),

		// admin
		Admin: bt.CreateAdmin(opts.CommonOptions),

		// layer runtime
		LayeredRuntime: bt.CreateLayeredRuntime(),

		// Dynamic resource
		DynamicResources: &bootstrappb.Bootstrap_DynamicResources{
			LdsConfig: &corepb.ConfigSource{
				ConfigSourceSpecifier: &corepb.ConfigSource_Ads{
					Ads: &corepb.AggregatedConfigSource{},
				},
				ResourceApiVersion: apiVersion,
			},
			CdsConfig: &corepb.ConfigSource{
				ConfigSourceSpecifier: &corepb.ConfigSource_Ads{
					Ads: &corepb.AggregatedConfigSource{},
				},
				ResourceApiVersion: apiVersion,
			},
			AdsConfig: &corepb.ApiConfigSource{
				ApiType:             corepb.ApiConfigSource_GRPC,
				TransportApiVersion: apiVersion,
				GrpcServices: []*corepb.GrpcService{{
					TargetSpecifier: &corepb.GrpcService_EnvoyGrpc_{
						EnvoyGrpc: &corepb.GrpcService_EnvoyGrpc{
							ClusterName: opts.AdsNamedPipe,
						},
					},
				}},
			},
		},

		// Static resource
		StaticResources: &bootstrappb.Bootstrap_StaticResources{
			Clusters: []*clusterpb.Cluster{
				{
					Name:           opts.AdsNamedPipe,
					LbPolicy:       clusterpb.Cluster_ROUND_ROBIN,
					ConnectTimeout: connectTimeoutProto,
					ClusterDiscoveryType: &clusterpb.Cluster_Type{
						Type: clusterpb.Cluster_STATIC,
					},
					TypedExtensionProtocolOptions: util.CreateUpstreamProtocolOptions(),
					LoadAssignment:                util.CreateUdsLoadAssignment(opts.AdsNamedPipe),
				},
			},
		},
	}

	jsonStr, err := util.ProtoToJson(bt)
	if err != nil {
		return "", fmt.Errorf("failed to MarshalToString, error: %v", err)
	}
	return jsonStr, nil
}