Skip to content

Commit f8aa7d9

Browse files
authored
Merge pull request #2466 from mrueg/drop-dynamic-client
chore: Add unused linter
2 parents b1c2e0c + ab06f81 commit f8aa7d9

File tree

5 files changed

+11
-44
lines changed

5 files changed

+11
-44
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ linters:
1717
- revive
1818
- staticcheck
1919
- unconvert
20+
- unused
2021

2122
linters-settings:
2223
goimports:

internal/discovery/discovery_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
Copyright 2023 The Kubernetes Authors All rights reserved.
3-
Licensed under the Apache License, Version 2.0 (the "License");
4-
you may not use this file except in compliance with the License.
5-
You may obtain a copy of the License at
6-
http://www.apache.org/licenses/LICENSE-2.0
7-
Unless required by applicable law or agreed to in writing, software
8-
distributed under the License is distributed on an "AS IS" BASIS,
9-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10-
See the License for the specific language governing permissions and
11-
limitations under the License.
2+
Copyright 2023 The Kubernetes Authors All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
1212
*/
1313

1414
package discovery
@@ -26,7 +26,6 @@ func TestGVKMapsResolveGVK(t *testing.T) {
2626
desc string
2727
gvkmaps *CRDiscoverer
2828
gvk schema.GroupVersionKind
29-
got []groupVersionKindPlural
3029
want []groupVersionKindPlural
3130
}
3231
testcases := []testcase{

internal/store/networkpolicy_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ func TestNetworkPolicyStore(t *testing.T) {
2929
startTime := 1501569018
3030
metav1StartTime := metav1.Unix(int64(startTime), 0)
3131

32-
const metadata = `
33-
# HELP kube_verticalpodautoscaler_labels Kubernetes labels converted to Prometheus labels.
34-
# TYPE kube_verticalpodautoscaler_labels gauge
35-
`
3632
cases := []generateMetricsTestCase{
3733
{
3834
Obj: &networkingv1.NetworkPolicy{

pkg/metrics_store/metrics_store_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ import (
2929
"k8s.io/kube-state-metrics/v2/pkg/metric"
3030
)
3131

32-
// Mock metricFamily instead of importing /pkg/metric to prevent cyclic
33-
// dependency.
34-
type metricFamily struct {
35-
value []byte
36-
}
37-
38-
// Implement FamilyByteSlicer interface.
39-
func (f *metricFamily) ByteSlice() []byte {
40-
return f.value
41-
}
42-
4332
func TestObjectsSameNameDifferentNamespaces(t *testing.T) {
4433
serviceIDs := []string{"a", "b"}
4534

pkg/util/utils.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2525
"k8s.io/apimachinery/pkg/runtime/schema"
2626
"k8s.io/client-go/discovery"
27-
"k8s.io/client-go/dynamic"
2827
clientset "k8s.io/client-go/kubernetes"
2928
"k8s.io/client-go/rest"
3029
"k8s.io/client-go/tools/clientcmd"
@@ -40,7 +39,6 @@ import (
4039
var config *rest.Config
4140
var currentKubeClient clientset.Interface
4241
var currentDiscoveryClient *discovery.DiscoveryClient
43-
var currentDynamicClient *dynamic.DynamicClient
4442

4543
// CreateKubeClient creates a Kubernetes clientset and a custom resource clientset.
4644
func CreateKubeClient(apiserver string, kubeconfig string) (clientset.Interface, error) {
@@ -120,22 +118,6 @@ func CreateDiscoveryClient(apiserver string, kubeconfig string) (*discovery.Disc
120118
return currentDiscoveryClient, err
121119
}
122120

123-
// CreateDynamicClient creates a Kubernetes dynamic client.
124-
func CreateDynamicClient(apiserver string, kubeconfig string) (*dynamic.DynamicClient, error) {
125-
if currentDynamicClient != nil {
126-
return currentDynamicClient, nil
127-
}
128-
var err error
129-
if config == nil {
130-
config, err = clientcmd.BuildConfigFromFlags(apiserver, kubeconfig)
131-
if err != nil {
132-
return nil, err
133-
}
134-
}
135-
currentDynamicClient, err = dynamic.NewForConfig(config)
136-
return currentDynamicClient, err
137-
}
138-
139121
// GVRFromType returns the GroupVersionResource for a given type.
140122
func GVRFromType(resourceName string, expectedType interface{}) *schema.GroupVersionResource {
141123
if _, ok := expectedType.(*testUnstructuredMock.Foo); ok {

0 commit comments

Comments
 (0)