Skip to content

Commit 8c167b2

Browse files
crenshaw-devenneitex
authored andcommitted
chore: enable lint for unused private fields (argoproj#23242)
Signed-off-by: Michael Crenshaw <[email protected]> Signed-off-by: enneitex <[email protected]>
1 parent a05a2c9 commit 8c167b2

File tree

79 files changed

+160
-432
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+160
-432
lines changed

.golangci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ linters:
221221
disable:
222222
- go-require
223223

224+
unused:
225+
field-writes-are-uses: false
226+
exported-fields-are-used: false
227+
224228
usetesting:
225229
os-mkdir-temp: false
226230

applicationset/generators/cluster.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77

88
log "github.com/sirupsen/logrus"
99

10-
"github.com/argoproj/argo-cd/v3/util/settings"
11-
1210
corev1 "k8s.io/api/core/v1"
1311
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1412
"k8s.io/client-go/kubernetes"
@@ -27,21 +25,17 @@ type ClusterGenerator struct {
2725
ctx context.Context
2826
clientset kubernetes.Interface
2927
// namespace is the Argo CD namespace
30-
namespace string
31-
settingsManager *settings.SettingsManager
28+
namespace string
3229
}
3330

3431
var render = &utils.Render{}
3532

3633
func NewClusterGenerator(ctx context.Context, c client.Client, clientset kubernetes.Interface, namespace string) Generator {
37-
settingsManager := settings.NewSettingsManager(ctx, clientset, namespace)
38-
3934
g := &ClusterGenerator{
40-
Client: c,
41-
ctx: ctx,
42-
clientset: clientset,
43-
namespace: namespace,
44-
settingsManager: settingsManager,
35+
Client: c,
36+
ctx: ctx,
37+
clientset: clientset,
38+
namespace: namespace,
4539
}
4640
return g
4741
}

applicationset/generators/duck_type.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
log "github.com/sirupsen/logrus"
1111
"sigs.k8s.io/controller-runtime/pkg/client"
1212

13-
"github.com/argoproj/argo-cd/v3/util/settings"
14-
1513
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1614
"k8s.io/apimachinery/pkg/fields"
1715
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -26,22 +24,18 @@ var _ Generator = (*DuckTypeGenerator)(nil)
2624

2725
// DuckTypeGenerator generates Applications for some or all clusters registered with ArgoCD.
2826
type DuckTypeGenerator struct {
29-
ctx context.Context
30-
dynClient dynamic.Interface
31-
clientset kubernetes.Interface
32-
namespace string // namespace is the Argo CD namespace
33-
settingsManager *settings.SettingsManager
27+
ctx context.Context
28+
dynClient dynamic.Interface
29+
clientset kubernetes.Interface
30+
namespace string // namespace is the Argo CD namespace
3431
}
3532

3633
func NewDuckTypeGenerator(ctx context.Context, dynClient dynamic.Interface, clientset kubernetes.Interface, namespace string) Generator {
37-
settingsManager := settings.NewSettingsManager(ctx, clientset, namespace)
38-
3934
g := &DuckTypeGenerator{
40-
ctx: ctx,
41-
dynClient: dynClient,
42-
clientset: clientset,
43-
namespace: namespace,
44-
settingsManager: settingsManager,
35+
ctx: ctx,
36+
dynClient: dynClient,
37+
clientset: clientset,
38+
namespace: namespace,
4539
}
4640
return g
4741
}

applicationset/generators/plugin.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"github.com/jeremywohl/flatten"
1212
corev1 "k8s.io/api/core/v1"
13-
"k8s.io/client-go/kubernetes"
1413
"sigs.k8s.io/controller-runtime/pkg/client"
1514

1615
argoprojiov1alpha1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
@@ -27,16 +26,12 @@ var _ Generator = (*PluginGenerator)(nil)
2726

2827
type PluginGenerator struct {
2928
client client.Client
30-
ctx context.Context
31-
clientset kubernetes.Interface
3229
namespace string
3330
}
3431

35-
func NewPluginGenerator(ctx context.Context, client client.Client, clientset kubernetes.Interface, namespace string) Generator {
32+
func NewPluginGenerator(client client.Client, namespace string) Generator {
3633
g := &PluginGenerator{
3734
client: client,
38-
ctx: ctx,
39-
clientset: clientset,
4035
namespace: namespace,
4136
}
4237
return g

applicationset/generators/plugin_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
corev1 "k8s.io/api/core/v1"
1515
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1616
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17-
"k8s.io/apimachinery/pkg/runtime"
18-
kubefake "k8s.io/client-go/kubernetes/fake"
1917
"sigs.k8s.io/controller-runtime/pkg/client"
2018
"sigs.k8s.io/controller-runtime/pkg/client/fake"
2119

@@ -628,8 +626,6 @@ func TestPluginGenerateParams(t *testing.T) {
628626
},
629627
}
630628

631-
ctx := t.Context()
632-
633629
for _, testCase := range testCases {
634630
t.Run(testCase.name, func(t *testing.T) {
635631
generatorConfig := argoprojiov1alpha1.ApplicationSetGenerator{
@@ -666,11 +662,9 @@ func TestPluginGenerateParams(t *testing.T) {
666662
testCase.configmap.Data["baseUrl"] = fakeServer.URL
667663
}
668664

669-
fakeClient := kubefake.NewSimpleClientset(append([]runtime.Object{}, testCase.configmap, testCase.secret)...)
670-
671665
fakeClientWithCache := fake.NewClientBuilder().WithObjects([]client.Object{testCase.configmap, testCase.secret}...).Build()
672666

673-
pluginGenerator := NewPluginGenerator(ctx, fakeClientWithCache, fakeClient, "default")
667+
pluginGenerator := NewPluginGenerator(fakeClientWithCache, "default")
674668

675669
applicationSetInfo := argoprojiov1alpha1.ApplicationSet{
676670
ObjectMeta: metav1.ObjectMeta{

applicationset/generators/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func GetGenerators(ctx context.Context, c client.Client, k8sClient kubernetes.In
1818
"SCMProvider": NewSCMProviderGenerator(c, scmConfig),
1919
"ClusterDecisionResource": NewDuckTypeGenerator(ctx, dynamicClient, k8sClient, namespace),
2020
"PullRequest": NewPullRequestGenerator(c, scmConfig),
21-
"Plugin": NewPluginGenerator(ctx, c, k8sClient, namespace),
21+
"Plugin": NewPluginGenerator(c, namespace),
2222
}
2323

2424
nestedGenerators := map[string]Generator{

applicationset/services/scm_provider/azure_devops.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func (factory *devopsFactoryImpl) GetClient(ctx context.Context) (azureGit.Clien
4747
type AzureDevOpsProvider struct {
4848
organization string
4949
teamProject string
50-
accessToken string
5150
clientFactory AzureDevOpsClientFactory
5251
allBranches bool
5352
}
@@ -69,7 +68,7 @@ func NewAzureDevOpsProvider(accessToken string, org string, url string, project
6968

7069
connection := azuredevops.NewPatConnection(devOpsURL, accessToken)
7170

72-
return &AzureDevOpsProvider{organization: org, teamProject: project, accessToken: accessToken, clientFactory: &devopsFactoryImpl{connection: connection}, allBranches: allBranches}, nil
71+
return &AzureDevOpsProvider{organization: org, teamProject: project, clientFactory: &devopsFactoryImpl{connection: connection}, allBranches: allBranches}, nil
7372
}
7473

7574
func (g *AzureDevOpsProvider) ListRepos(ctx context.Context, _ string) ([]*Repository, error) {

applicationset/webhook/webhook.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const payloadQueueSize = 50000
3232

3333
type WebhookHandler struct {
3434
sync.WaitGroup // for testing
35-
namespace string
3635
github *github.Webhook
3736
gitlab *gitlab.Webhook
3837
azuredevops *azuredevops.Webhook
@@ -69,7 +68,7 @@ type prGeneratorGitlabInfo struct {
6968
APIHostname string
7069
}
7170

72-
func NewWebhookHandler(namespace string, webhookParallelism int, argocdSettingsMgr *argosettings.SettingsManager, client client.Client, generators map[string]generators.Generator) (*WebhookHandler, error) {
71+
func NewWebhookHandler(webhookParallelism int, argocdSettingsMgr *argosettings.SettingsManager, client client.Client, generators map[string]generators.Generator) (*WebhookHandler, error) {
7372
// register the webhook secrets stored under "argocd-secret" for verifying incoming payloads
7473
argocdSettings, err := argocdSettingsMgr.GetSettings()
7574
if err != nil {
@@ -89,7 +88,6 @@ func NewWebhookHandler(namespace string, webhookParallelism int, argocdSettingsM
8988
}
9089

9190
webhookHandler := &WebhookHandler{
92-
namespace: namespace,
9391
github: githubHandler,
9492
gitlab: gitlabHandler,
9593
azuredevops: azuredevopsHandler,

applicationset/webhook/webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func TestWebhookHandler(t *testing.T) {
230230
fakeAppWithMergeAndNestedGitGenerator("merge-nested-git-github", namespace, "https://github.com/org/repo"),
231231
).Build()
232232
set := argosettings.NewSettingsManager(t.Context(), fakeClient, namespace)
233-
h, err := NewWebhookHandler(namespace, webhookParallelism, set, fc, mockGenerators())
233+
h, err := NewWebhookHandler(webhookParallelism, set, fc, mockGenerators())
234234
require.NoError(t, err)
235235

236236
req := httptest.NewRequest(http.MethodPost, "/api/webhook", nil)

cmd/argocd-applicationset-controller/commands/applicationset_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func NewCommand() *cobra.Command {
198198
topLevelGenerators := generators.GetGenerators(ctx, mgr.GetClient(), k8sClient, namespace, argoCDService, dynamicClient, scmConfig)
199199

200200
// start a webhook server that listens to incoming webhook payloads
201-
webhookHandler, err := webhook.NewWebhookHandler(namespace, webhookParallelism, argoSettingsMgr, mgr.GetClient(), topLevelGenerators)
201+
webhookHandler, err := webhook.NewWebhookHandler(webhookParallelism, argoSettingsMgr, mgr.GetClient(), topLevelGenerators)
202202
if err != nil {
203203
log.Error(err, "failed to create webhook handler")
204204
}

0 commit comments

Comments
 (0)