Skip to content

Commit 8280ec3

Browse files
committed
Fix lint errors
1 parent 8cd2845 commit 8280ec3

File tree

7 files changed

+28
-30
lines changed

7 files changed

+28
-30
lines changed

examples/cluster-inventory-api/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242
mcbuilder "sigs.k8s.io/multicluster-runtime/pkg/builder"
4343
mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"
4444
mcreconcile "sigs.k8s.io/multicluster-runtime/pkg/reconcile"
45-
4645
clusterinventoryapi "sigs.k8s.io/multicluster-runtime/providers/cluster-inventory-api"
4746
"sigs.k8s.io/multicluster-runtime/providers/cluster-inventory-api/kubeconfigstrategy"
4847
)

providers/cluster-inventory-api/kubeconfigstrategy/credentialsprovider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package kubeconfigstrategy
33
import (
44
"context"
55

6+
"sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
7+
"sigs.k8s.io/cluster-inventory-api/pkg/credentials"
8+
69
"k8s.io/client-go/rest"
710

811
"sigs.k8s.io/controller-runtime/pkg/client"
912
"sigs.k8s.io/controller-runtime/pkg/log"
10-
11-
"sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
12-
"sigs.k8s.io/cluster-inventory-api/pkg/credentials"
1313
)
1414

1515
var _ Interface = &credentialsProviderStrategy{}

providers/cluster-inventory-api/kubeconfigstrategy/interface.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package kubeconfigstrategy
33
import (
44
"context"
55

6-
"k8s.io/client-go/rest"
7-
86
clusterinventoryv1alpha1 "sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
97

8+
"k8s.io/client-go/rest"
9+
1010
"sigs.k8s.io/controller-runtime/pkg/builder"
1111
"sigs.k8s.io/controller-runtime/pkg/client"
1212
"sigs.k8s.io/controller-runtime/pkg/handler"

providers/cluster-inventory-api/kubeconfigstrategy/secret.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"fmt"
66

7+
"sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
8+
79
corev1 "k8s.io/api/core/v1"
810
"k8s.io/apimachinery/pkg/types"
911
"k8s.io/client-go/rest"
@@ -15,14 +17,15 @@ import (
1517
"sigs.k8s.io/controller-runtime/pkg/log"
1618
"sigs.k8s.io/controller-runtime/pkg/predicate"
1719
"sigs.k8s.io/controller-runtime/pkg/reconcile"
18-
19-
"sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
2020
)
2121

2222
const (
23+
// SecretLabelKeyClusterInventoryConsumer is the label key used to identify the consumer of the kubeconfig Secret.
2324
SecretLabelKeyClusterInventoryConsumer = "x-k8s.io/cluster-inventory-consumer"
24-
SecretLabelKeyClusterProfile = "x-k8s.io/cluster-profile"
25-
SecretDataKeyKubeConfig = "Config" // data key in the Secret that contains the kubeconfig.
25+
// SecretLabelKeyClusterProfile is the label key used to identify the ClusterProfile associated with the kubeconfig Secret.
26+
SecretLabelKeyClusterProfile = "x-k8s.io/cluster-profile"
27+
// SecretDataKeyKubeConfig is the key in the Secret data that contains the kubeconfig.
28+
SecretDataKeyKubeConfig = "Config"
2629
)
2730

2831
var _ Interface = &secretStrategy{}
@@ -31,6 +34,7 @@ type secretStrategy struct {
3134
consumerName string
3235
}
3336

37+
// SecretStrategyOption holds options for the Secret strategy.
3438
type SecretStrategyOption struct {
3539
ConsumerName string
3640
}

providers/cluster-inventory-api/provider.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"time"
2525

2626
"github.com/go-logr/logr"
27+
clusterinventoryv1alpha1 "sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
2728

2829
apierrors "k8s.io/apimachinery/pkg/api/errors"
2930
"k8s.io/apimachinery/pkg/api/meta"
@@ -39,9 +40,6 @@ import (
3940

4041
mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"
4142
"sigs.k8s.io/multicluster-runtime/pkg/multicluster"
42-
43-
clusterinventoryv1alpha1 "sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
44-
4543
"sigs.k8s.io/multicluster-runtime/providers/cluster-inventory-api/kubeconfigstrategy"
4644
)
4745

@@ -82,7 +80,7 @@ type Provider struct {
8280
indexers []index
8381
}
8482

85-
func setDefaults(opts *Options, cli client.Client) {
83+
func setDefaults(opts *Options) {
8684
if opts.NewCluster == nil {
8785
opts.NewCluster = func(ctx context.Context, clp *clusterinventoryv1alpha1.ClusterProfile, cfg *rest.Config, opts ...cluster.Option) (cluster.Cluster, error) {
8886
return cluster.New(cfg, opts...)
@@ -107,7 +105,7 @@ func New(opts Options) (*Provider, error) {
107105
kubeconfig: map[string]*rest.Config{},
108106
strategy: strategy,
109107
}
110-
setDefaults(&p.opts, p.client)
108+
setDefaults(&p.opts)
111109
return p, nil
112110
}
113111

providers/cluster-inventory-api/provider_test.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"time"
2626

2727
"golang.org/x/sync/errgroup"
28+
clusterinventoryv1alpha1 "sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
29+
"sigs.k8s.io/cluster-inventory-api/pkg/credentials"
2830

2931
authenticationv1 "k8s.io/api/authentication/v1"
3032
corev1 "k8s.io/api/core/v1"
@@ -50,10 +52,6 @@ import (
5052
mccontroller "sigs.k8s.io/multicluster-runtime/pkg/controller"
5153
mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"
5254
mcreconcile "sigs.k8s.io/multicluster-runtime/pkg/reconcile"
53-
54-
clusterinventoryv1alpha1 "sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
55-
"sigs.k8s.io/cluster-inventory-api/pkg/credentials"
56-
5755
"sigs.k8s.io/multicluster-runtime/providers/cluster-inventory-api/kubeconfigstrategy"
5856

5957
. "github.com/onsi/ginkgo/v2"
@@ -323,8 +321,8 @@ var _ = Describe("Provider Cluster Inventory API", Ordered, func() {
323321
})
324322
Expect(cliHub.Status().Update(ctx, profileMember)).To(Succeed())
325323

326-
_, sa1TokenMember = mustCreateAdminSAAndToken(ctx, cliMember, "sa1", "default")
327-
_ = mustCreateOrUpdateKubeConfigSecretFromTokenSecret(
324+
sa1TokenMember = mustCreateAdminSAAndToken(ctx, cliMember, "sa1", "default")
325+
mustCreateOrUpdateKubeConfigSecretFromTokenSecret(
328326
ctx, cliHub, cfgMember,
329327
consumerName,
330328
*profileMember,
@@ -340,8 +338,8 @@ var _ = Describe("Provider Cluster Inventory API", Ordered, func() {
340338

341339
It("re-engages the cluster when kubeconfig of the cluster profile changes", func(ctx context.Context) {
342340
By("Update the kubeconfig for the member ClusterProfile", func() {
343-
_, sa2TokenMember = mustCreateAdminSAAndToken(ctx, cliMember, "sa2", "default")
344-
_ = mustCreateOrUpdateKubeConfigSecretFromTokenSecret(
341+
sa2TokenMember = mustCreateAdminSAAndToken(ctx, cliMember, "sa2", "default")
342+
mustCreateOrUpdateKubeConfigSecretFromTokenSecret(
345343
ctx, cliHub, cfgMember,
346344
consumerName,
347345
*profileMember,
@@ -391,7 +389,7 @@ var _ = Describe("Provider Cluster Inventory API", Ordered, func() {
391389
createClusters()
392390

393391
By("Setting up the Provider", func() {
394-
_, sa1TokenMember := mustCreateAdminSAAndToken(ctx, cliMember, "sa1", "default")
392+
sa1TokenMember := mustCreateAdminSAAndToken(ctx, cliMember, "sa1", "default")
395393
execPluginOutput := fmt.Sprintf(`{
396394
"apiVersion": "client.authentication.k8s.io/v1beta1",
397395
"kind": "ExecCredential",
@@ -482,7 +480,7 @@ func ignoreCanceled(err error) error {
482480
return err
483481
}
484482

485-
func mustCreateAdminSAAndToken(ctx context.Context, cli client.Client, name, namespace string) (corev1.ServiceAccount, string) {
483+
func mustCreateAdminSAAndToken(ctx context.Context, cli client.Client, name, namespace string) string {
486484
sa := corev1.ServiceAccount{
487485
ObjectMeta: metav1.ObjectMeta{
488486
Name: name,
@@ -518,7 +516,7 @@ func mustCreateAdminSAAndToken(ctx context.Context, cli client.Client, name, nam
518516
}
519517
Expect(client.IgnoreAlreadyExists(cli.Create(ctx, &adminClusterRoleBinding))).To(Succeed())
520518

521-
return sa, tokenRequest.Status.Token
519+
return tokenRequest.Status.Token
522520
}
523521

524522
func mustCreateOrUpdateKubeConfigSecretFromTokenSecret(
@@ -528,7 +526,7 @@ func mustCreateOrUpdateKubeConfigSecretFromTokenSecret(
528526
consumerName string,
529527
clusterProfile clusterinventoryv1alpha1.ClusterProfile,
530528
token string,
531-
) corev1.Secret {
529+
) {
532530
kubeconfigStr := fmt.Sprintf(`apiVersion: v1
533531
clusters:
534532
- cluster:
@@ -568,5 +566,4 @@ users:
568566
return nil
569567
})
570568
Expect(err).NotTo(HaveOccurred())
571-
return *kubeConfigSecret
572569
}

providers/cluster-inventory-api/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import (
2323
"path/filepath"
2424
"testing"
2525

26+
clusterinventoryv1alpha1 "sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
27+
2628
"k8s.io/apimachinery/pkg/util/runtime"
2729
"k8s.io/client-go/kubernetes/scheme"
2830

2931
logf "sigs.k8s.io/controller-runtime/pkg/log"
3032
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3133
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3234

33-
clusterinventoryv1alpha1 "sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
34-
3535
. "github.com/onsi/ginkgo/v2"
3636
. "github.com/onsi/gomega"
3737
)

0 commit comments

Comments
 (0)