Skip to content

Commit 1787f94

Browse files
authored
xdsclient: export genericResourceTypeDecoder (#8406)
1 parent 15299cc commit 1787f94

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

xds/internal/xdsclient/xdsresource/cluster_resource_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,5 @@ func WatchCluster(p Producer, name string, w ClusterWatcher) (cancel func()) {
156156
// NewGenericClusterResourceTypeDecoder returns a xdsclient.Decoder that
157157
// wraps the xdsresource.clusterType.
158158
func NewGenericClusterResourceTypeDecoder(bc *bootstrap.Config, gServerCfgMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig) xdsclient.Decoder {
159-
return &genericResourceTypeDecoder{resourceType: clusterType, bootstrapConfig: bc, gServerConfigMap: gServerCfgMap}
159+
return &GenericResourceTypeDecoder{ResourceType: clusterType, BootstrapConfig: bc, ServerConfigMap: gServerCfgMap}
160160
}

xds/internal/xdsclient/xdsresource/endpoints_resource_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,5 @@ func WatchEndpoints(p Producer, name string, w EndpointsWatcher) (cancel func())
151151
// NewGenericEndpointsResourceTypeDecoder returns a xdsclient.Decoder that
152152
// wraps the xdsresource.endpointsType.
153153
func NewGenericEndpointsResourceTypeDecoder() xdsclient.Decoder {
154-
return &genericResourceTypeDecoder{resourceType: endpointsType}
154+
return &GenericResourceTypeDecoder{ResourceType: endpointsType}
155155
}

xds/internal/xdsclient/xdsresource/listener_resource_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,5 @@ func WatchListener(p Producer, name string, w ListenerWatcher) (cancel func()) {
185185
// NewGenericListenerResourceTypeDecoder returns a xdsclient.Decoder that wraps
186186
// the xdsresource.listenerType.
187187
func NewGenericListenerResourceTypeDecoder(bc *bootstrap.Config) xdsclient.Decoder {
188-
return &genericResourceTypeDecoder{resourceType: listenerType, bootstrapConfig: bc}
188+
return &GenericResourceTypeDecoder{ResourceType: listenerType, BootstrapConfig: bc}
189189
}

xds/internal/xdsclient/xdsresource/resource_type.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,27 +171,27 @@ func (r resourceTypeState) AllResourcesRequiredInSotW() bool {
171171
return r.allResourcesRequiredInSotW
172172
}
173173

174-
// genericResourceTypeDecoder wraps an xdsresource.Type and implements
174+
// GenericResourceTypeDecoder wraps an xdsresource.Type and implements
175175
// xdsclient.Decoder.
176176
//
177177
// TODO: #8313 - Delete this once the internal xdsclient usages are updated
178178
// to use the generic xdsclient.ResourceType interface directly.
179-
type genericResourceTypeDecoder struct {
180-
resourceType Type
181-
bootstrapConfig *bootstrap.Config
182-
gServerConfigMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig
179+
type GenericResourceTypeDecoder struct {
180+
ResourceType Type
181+
BootstrapConfig *bootstrap.Config
182+
ServerConfigMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig
183183
}
184184

185185
// Decode deserialize and validate resource bytes of an xDS resource received
186186
// from the xDS management server.
187-
func (gd *genericResourceTypeDecoder) Decode(resourceBytes []byte, gOpts xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) {
188-
raw := &anypb.Any{TypeUrl: gd.resourceType.TypeURL(), Value: resourceBytes}
189-
opts := &DecodeOptions{BootstrapConfig: gd.bootstrapConfig}
187+
func (gd *GenericResourceTypeDecoder) Decode(resourceBytes []byte, gOpts xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) {
188+
raw := &anypb.Any{TypeUrl: gd.ResourceType.TypeURL(), Value: resourceBytes}
189+
opts := &DecodeOptions{BootstrapConfig: gd.BootstrapConfig}
190190
if gOpts.ServerConfig != nil {
191-
opts.ServerConfig = gd.gServerConfigMap[*gOpts.ServerConfig]
191+
opts.ServerConfig = gd.ServerConfigMap[*gOpts.ServerConfig]
192192
}
193193

194-
result, err := gd.resourceType.Decode(opts, raw)
194+
result, err := gd.ResourceType.Decode(opts, raw)
195195
if result == nil {
196196
return nil, err
197197
}

xds/internal/xdsclient/xdsresource/route_config_resource_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,5 @@ func WatchRouteConfig(p Producer, name string, w RouteConfigWatcher) (cancel fun
153153
// NewGenericRouteConfigResourceTypeDecoder returns a xdsclient.Decoder that
154154
// wraps the xdsresource.routeConfigType.
155155
func NewGenericRouteConfigResourceTypeDecoder() xdsclient.Decoder {
156-
return &genericResourceTypeDecoder{resourceType: routeConfigType}
156+
return &GenericResourceTypeDecoder{ResourceType: routeConfigType}
157157
}

0 commit comments

Comments
 (0)