diff --git a/xds/internal/xdsclient/bootstrap/bootstrap.go b/xds/internal/xdsclient/bootstrap/bootstrap.go index 1a0971f22272..e27930357cfe 100644 --- a/xds/internal/xdsclient/bootstrap/bootstrap.go +++ b/xds/internal/xdsclient/bootstrap/bootstrap.go @@ -565,7 +565,7 @@ func newConfigFromContents(data []byte) (*Config, error) { } node.UserAgentName = gRPCUserAgentName node.UserAgentVersionType = &v3corepb.Node_UserAgentVersion{UserAgentVersion: grpc.Version} - node.ClientFeatures = AppendIfNotPresent(node.ClientFeatures, clientFeatureNoOverprovisioning, clientFeatureResourceWrapper) + node.ClientFeatures = append(node.ClientFeatures, clientFeatureNoOverprovisioning, clientFeatureResourceWrapper) config.NodeProto = node logger.Debugf("Bootstrap config for creating xds-client: %v", pretty.ToJSON(config)) diff --git a/xds/internal/xdsclient/bootstrap/utils.go b/xds/internal/xdsclient/bootstrap/utils.go deleted file mode 100644 index df185f563dc3..000000000000 --- a/xds/internal/xdsclient/bootstrap/utils.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package bootstrap - -// AppendIfNotPresent adds elems to a slice while ignoring duplicates -func AppendIfNotPresent[E comparable](slice []E, elems ...E) []E { - presented := make(map[E]struct{}) - - for _, s := range slice { - presented[s] = struct{}{} - } - - for _, e := range elems { - if _, ok := presented[e]; !ok { - slice = append(slice, e) - presented[e] = struct{}{} - } - } - return slice -} diff --git a/xds/internal/xdsclient/bootstrap/utils_test.go b/xds/internal/xdsclient/bootstrap/utils_test.go deleted file mode 100644 index b28f2b90bd66..000000000000 --- a/xds/internal/xdsclient/bootstrap/utils_test.go +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package bootstrap - -import ( - "reflect" - "testing" -) - -func TestAppendIfNotPresent(t *testing.T) { - type args struct { - slice []string - elems []string - } - tests := []struct { - name string - args args - want []string - }{ - {name: "empty", args: args{[]string{}, []string{"a"}}, want: []string{"a"}}, - {name: "just append", args: args{[]string{"a"}, []string{"b"}}, want: []string{"a", "b"}}, - {name: "ignore a", args: args{[]string{"a"}, []string{"a", "b"}}, want: []string{"a", "b"}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := AppendIfNotPresent(tt.args.slice, tt.args.elems...); !reflect.DeepEqual(got, tt.want) { - t.Errorf("appendIfNotPresent() = %v, want %v", got, tt.want) - } - }) - } -}