Skip to content

Commit ab07959

Browse files
committed
adding server_feature in bootstrap config
1 parent 0b57abb commit ab07959

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

internal/xds/bootstrap/bootstrap.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343

4444
const (
4545
serverFeaturesIgnoreResourceDeletion = "ignore_resource_deletion"
46+
serverFeatureTrustedXDSServer = "trusted_xds_server"
4647
gRPCUserAgentName = "gRPC Go"
4748
clientFeatureNoOverprovisioning = "envoy.lb.does_not_support_overprovisioning"
4849
clientFeatureResourceWrapper = "xds.config.resource-in-sotw"
@@ -211,6 +212,18 @@ func (sc *ServerConfig) ServerFeaturesIgnoreResourceDeletion() bool {
211212
return false
212213
}
213214

215+
// ServerFeaturesTrustedXDSServer returns true if this server is trusted,
216+
// and gRPC should accept security-config-affecting fields from the server
217+
// as described in gRFC A81.
218+
func (sc *ServerConfig) ServerFeaturesTrustedXDSServer() bool {
219+
for _, sf := range sc.serverFeatures {
220+
if sf == serverFeatureTrustedXDSServer {
221+
return true
222+
}
223+
}
224+
return false
225+
}
226+
214227
// SelectedCreds returns the selected credentials configuration for
215228
// communicating with this server.
216229
func (sc *ServerConfig) SelectedCreds() ChannelCreds {

internal/xds/bootstrap/bootstrap_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,22 @@ var (
196196
"server_features" : ["ignore_resource_deletion", "xds_v3"]
197197
}]
198198
}`,
199+
"serverSupportsTrustedXDSServer": `
200+
{
201+
"node": {
202+
"id": "ENVOY_NODE_ID",
203+
"metadata": {
204+
"TRAFFICDIRECTOR_GRPC_HOSTNAME": "trafficdirector"
205+
}
206+
},
207+
"xds_servers" : [{
208+
"server_uri": "trafficdirector.googleapis.com:443",
209+
"channel_creds": [
210+
{ "type": "google_default" }
211+
],
212+
"server_features" : ["trusted_xds_server", "xds_v3"]
213+
}]
214+
}`,
199215
}
200216
metadata = &structpb.Struct{
201217
Fields: map[string]*structpb.Value{
@@ -267,6 +283,16 @@ var (
267283
node: v3Node,
268284
clientDefaultListenerResourceNameTemplate: "%s",
269285
}
286+
configWithGoogleDefaultCredsAndTrustedXDSServer = &Config{
287+
xDSServers: []*ServerConfig{{
288+
serverURI: "trafficdirector.googleapis.com:443",
289+
channelCreds: []ChannelCreds{{Type: "google_default"}},
290+
serverFeatures: []string{"trusted_xds_server", "xds_v3"},
291+
selectedCreds: ChannelCreds{Type: "google_default"},
292+
}},
293+
node: v3Node,
294+
clientDefaultListenerResourceNameTemplate: "%s",
295+
}
270296
configWithGoogleDefaultCredsAndNoServerFeatures = &Config{
271297
xDSServers: []*ServerConfig{{
272298
serverURI: "trafficdirector.googleapis.com:443",
@@ -432,6 +458,7 @@ func (s) TestGetConfiguration_Success(t *testing.T) {
432458
{"goodBootstrap", configWithGoogleDefaultCredsAndV3},
433459
{"multipleXDSServers", configWithMultipleServers},
434460
{"serverSupportsIgnoreResourceDeletion", configWithGoogleDefaultCredsAndIgnoreResourceDeletion},
461+
{"serverSupportsTrustedXDSServer", configWithGoogleDefaultCredsAndTrustedXDSServer},
435462
}
436463

437464
for _, test := range tests {

0 commit comments

Comments
 (0)