Skip to content

Commit 98ae1aa

Browse files
committed
lint the cli code
Signed-off-by: Karol Szwaj <[email protected]> On-behalf-of: @SAP [email protected]
1 parent 176d761 commit 98ae1aa

File tree

24 files changed

+58
-110
lines changed

24 files changed

+58
-110
lines changed

cli/cmd/kubectl-create-workspace/cmd/kubectlCreateWorkspace.go

-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@ func KubectlCreateWorkspaceCommand() *cobra.Command {
4141
klog.InitFlags(fs)
4242
createWorkspaceCommand.PersistentFlags().AddGoFlagSet(fs)
4343
return createWorkspaceCommand
44-
4544
}

cli/cmd/kubectl-ws/cmd/kubectlWs.go

-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@ func KubectlWsCommand() *cobra.Command {
4141
klog.InitFlags(fs)
4242
wsCommand.PersistentFlags().AddGoFlagSet(fs)
4343
return wsCommand
44-
4544
}

cli/pkg/workspace/plugin/context_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ func TestCreateContext(t *testing.T) {
196196
},
197197
}
198198
for _, tt := range tests {
199-
tt := tt
200-
201199
t.Run(tt.name, func(t *testing.T) {
202200
var got *clientcmdapi.Config
203201

cli/pkg/workspace/plugin/create_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ func TestCreate(t *testing.T) {
184184

185185
var got *clientcmdapi.Config
186186

187-
cluster := tt.config.Clusters[tt.config.Contexts[tt.config.CurrentContext].Cluster] //nolint:govet // TODO(sttts): fixing this above breaks the test
187+
cluster := tt.config.Clusters[tt.config.Contexts[tt.config.CurrentContext].Cluster]
188188
u := parseURLOrDie(cluster.Server)
189189
currentClusterName := logicalcluster.NewPath(strings.TrimPrefix(u.Path, "/clusters/"))
190190
u.Path = ""
191191

192192
objects := []runtime.Object{}
193-
for _, name := range tt.existingWorkspaces { //nolint:govet // TODO(sttts): fixing this above breaks the test
193+
for _, name := range tt.existingWorkspaces {
194194
objects = append(objects, &tenancyv1alpha1.Workspace{
195195
ObjectMeta: metav1.ObjectMeta{
196196
Name: name,
@@ -217,7 +217,7 @@ func TestCreate(t *testing.T) {
217217
}
218218
}
219219

220-
if tt.markReady { //nolint:govet // TODO(sttts): fixing this above breaks the test
220+
if tt.markReady {
221221
client.PrependReactor("create", "workspaces", func(action kcptesting.Action) (handled bool, ret runtime.Object, err error) {
222222
obj := action.(kcptesting.CreateAction).GetObject().(*tenancyv1alpha1.Workspace)
223223
obj.Status.Phase = corev1alpha1.LogicalClusterPhaseReady
@@ -233,30 +233,30 @@ func TestCreate(t *testing.T) {
233233
}
234234

235235
opts := NewCreateWorkspaceOptions(genericclioptions.NewTestIOStreamsDiscard())
236-
opts.Name = tt.newWorkspaceName //nolint:govet // TODO(sttts): fixing this above breaks the test
236+
opts.Name = tt.newWorkspaceName
237237
opts.Type = workspaceType.Path + ":" + string(workspaceType.Name)
238-
opts.IgnoreExisting = tt.ignoreExisting //nolint:govet // TODO(sttts): fixing this above breaks the test
239-
opts.EnterAfterCreate = tt.useAfterCreation //nolint:govet // TODO(sttts): fixing this above breaks the test
238+
opts.IgnoreExisting = tt.ignoreExisting
239+
opts.EnterAfterCreate = tt.useAfterCreation
240240
opts.ReadyWaitTimeout = time.Second
241241
opts.modifyConfig = func(configAccess clientcmd.ConfigAccess, config *clientcmdapi.Config) error {
242242
got = config
243243
return nil
244244
}
245245
opts.kcpClusterClient = client
246-
opts.ClientConfig = clientcmd.NewDefaultClientConfig(*tt.config.DeepCopy(), nil) //nolint:govet // TODO(sttts): fixing this above breaks the test
246+
opts.ClientConfig = clientcmd.NewDefaultClientConfig(*tt.config.DeepCopy(), nil)
247247
err := opts.Run(context.Background())
248-
if tt.wantErr { //nolint:govet // TODO(sttts): fixing this above breaks the test
248+
if tt.wantErr {
249249
require.Error(t, err)
250250
} else {
251251
require.NoError(t, err)
252252
}
253253

254-
if got != nil && tt.expected == nil { //nolint:govet // TODO(sttts): fixing this above breaks the test
254+
if got != nil && tt.expected == nil {
255255
t.Errorf("unexpected kubeconfig write")
256-
} else if got == nil && tt.expected != nil { //nolint:govet // TODO(sttts): fixing this above breaks the test
256+
} else if got == nil && tt.expected != nil {
257257
t.Errorf("expected a kubeconfig write, but didn't see one")
258-
} else if got != nil && !reflect.DeepEqual(got, tt.expected) { //nolint:govet // TODO(sttts): fixing this above breaks the test
259-
t.Errorf("unexpected config, diff (expected, got): %s", cmp.Diff(tt.expected, got)) //nolint:govet // TODO(sttts): fixing this above breaks the test
258+
} else if got != nil && !reflect.DeepEqual(got, tt.expected) {
259+
t.Errorf("unexpected config, diff (expected, got): %s", cmp.Diff(tt.expected, got))
260260
}
261261
})
262262
}

cli/pkg/workspace/plugin/use.go

+2-22
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ func (o *UseWorkspaceOptions) Run(ctx context.Context) (err error) {
206206
if err != nil && !apierrors.IsForbidden(err) {
207207
return err
208208
}
209-
denied := false
210-
if apierrors.IsForbidden(err) || len(groups.Groups) == 0 {
211-
denied = true
212-
}
209+
denied := apierrors.IsForbidden(err) || len(groups.Groups) == 0
213210

214211
// first try to get Workspace from parent to potentially get a 404. A 403 in the parent though is
215212
// not a blocker to enter the workspace. We do discovery as a final check.
@@ -260,9 +257,7 @@ func resolveDots(pth string) (logicalcluster.Path, error) {
260257
return ret, nil
261258
}
262259

263-
// swapContexts moves to previous context from the config.
264-
// It will update existing configuration by swapping current & previous configurations.
265-
// This method already commits. Do not use with commitConfig
260+
// This method already commits. Do not use with commitConfig.
266261
func (o *UseWorkspaceOptions) swapContexts(ctx context.Context, currentContext *clientcmdapi.Context) (string, error) {
267262
currentContext = currentContext.DeepCopy()
268263

@@ -370,21 +365,6 @@ func (o *UseWorkspaceOptions) homePath(ctx context.Context) (logicalcluster.Path
370365
return logicalcluster.NewPath(strings.TrimPrefix(uh.Path, "/clusters/")), nil
371366
}
372367

373-
func (o *UseWorkspaceOptions) legacyRootURL() (*url.URL, error) {
374-
cluster := logicalcluster.NewPath(o.Name)
375-
if !cluster.IsValid() {
376-
return nil, fmt.Errorf("invalid workspace name format: %s", o.Name)
377-
}
378-
379-
u, _, err := o.parseCurrentLogicalCluster()
380-
if err != nil {
381-
return nil, err
382-
}
383-
// root workspace
384-
u.Path = path.Join(u.Path, cluster.RequestPath())
385-
return u, nil
386-
}
387-
388368
func (o *UseWorkspaceOptions) currentRootURL() (*url.URL, error) {
389369
u, currentClusterName, err := o.parseCurrentLogicalCluster()
390370
if err != nil {

cli/pkg/workspace/plugin/use_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ func TestUse(t *testing.T) {
429429
param: "~/..",
430430
expected: NewKubeconfig().WithKcpCurrent("root:users:ab:cd").WithKcpPrevious("root:foo").Build(),
431431
destination: homeWorkspace.String(),
432-
wantStdout: []string{fmt.Sprintf("Current workspace is 'root:users:ab:cd'")},
432+
wantStdout: []string{"Current workspace is 'root:users:ab:cd'"},
433433
},
434434
{
435435
name: "~ unfolded",
@@ -736,8 +736,6 @@ func TestUse(t *testing.T) {
736736
},
737737
}
738738
for _, tt := range tests {
739-
tt := tt
740-
741739
t.Run(tt.name, func(t *testing.T) {
742740
var got *clientcmdapi.Config
743741

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
apiVersion: apis.kcp.io/v1alpha2
1+
apiVersion: apis.kcp.io/v1alpha1
22
kind: APIExport
33
metadata:
44
creationTimestamp: null
55
name: shards.core.kcp.io
66
spec:
7-
resources:
8-
- group: core.kcp.io
9-
name: shards
10-
schema: v240903-d6797056a.shards.core.kcp.io
11-
storage:
12-
crd: {}
7+
latestResourceSchemas:
8+
- v240903-d6797056a.shards.core.kcp.io
139
status: {}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
apiVersion: apis.kcp.io/v1alpha2
1+
apiVersion: apis.kcp.io/v1alpha1
22
kind: APIExport
33
metadata:
44
creationTimestamp: null
55
name: tenancy.kcp.io
66
spec:
7+
latestResourceSchemas:
8+
- v250325-c1864de17.workspacetypes.tenancy.kcp.io
9+
- v250421-25d98218b.workspaces.tenancy.kcp.io
710
maximalPermissionPolicy:
811
local: {}
9-
resources:
10-
- group: tenancy.kcp.io
11-
name: workspaces
12-
schema: v250421-25d98218b.workspaces.tenancy.kcp.io
13-
storage:
14-
crd: {}
15-
- group: tenancy.kcp.io
16-
name: workspacetypes
17-
schema: v250325-c1864de17.workspacetypes.tenancy.kcp.io
18-
storage:
19-
crd: {}
2012
status: {}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
apiVersion: apis.kcp.io/v1alpha2
1+
apiVersion: apis.kcp.io/v1alpha1
22
kind: APIExport
33
metadata:
44
creationTimestamp: null
55
name: topology.kcp.io
66
spec:
7-
resources:
8-
- group: topology.kcp.io
9-
name: partitions
10-
schema: v240903-d6797056a.partitions.topology.kcp.io
11-
storage:
12-
crd: {}
13-
- group: topology.kcp.io
14-
name: partitionsets
15-
schema: v240903-d6797056a.partitionsets.topology.kcp.io
16-
storage:
17-
crd: {}
7+
latestResourceSchemas:
8+
- v240903-d6797056a.partitions.topology.kcp.io
9+
- v240903-d6797056a.partitionsets.topology.kcp.io
1810
status: {}

pkg/openapi/zz_generated.openapi.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/apis/apis/v1alpha1/types_apiresourceschema.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ type CustomResourceConversion struct {
170170
// ConversionStrategyType describes different conversion types.
171171
type ConversionStrategyType string
172172

173-
// WebhookConversion describes how to call a conversion webhook
173+
// WebhookConversion describes how to call a conversion webhook.
174174
type WebhookConversion struct {
175175
// clientConfig is the instructions for how to call the webhook if strategy is `Webhook`.
176176
// +optional

sdk/apis/core/install/install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1"
2626
)
2727

28-
// Install registers the API group and adds types to a scheme
28+
// Install registers the API group and adds types to a scheme.
2929
func Install(scheme *runtime.Scheme) {
3030
utilruntime.Must(v1alpha1.AddToScheme(scheme))
3131
}

sdk/apis/core/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ const (
3737
var (
3838
// RootCluster is the root of workspace based logical clusters.
3939
RootCluster = logicalcluster.Name("root")
40-
// SystemCluster is the system logical cluster
40+
// SystemCluster is the system logical cluster.
4141
SystemCluster = logicalcluster.Name("system")
4242
)

sdk/apis/core/v1alpha1/logicalcluster_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const (
6767
LogicalClusterPhaseInitializing LogicalClusterPhaseType = "Initializing"
6868
LogicalClusterPhaseReady LogicalClusterPhaseType = "Ready"
6969
// LogicalClusterPhaseUnavailable phase is used to indicate that the logical cluster is unavailable to be used.
70-
// It will will not be served via front-proxy when in this state.
70+
// It will not be served via front-proxy when in this state.
7171
// Possible state transitions are from Ready to Unavailable and from Unavailable to Ready.
7272
// This should be used when we really can't serve the logical cluster content and not some
7373
// temporary flakes, like readiness probe failing.

sdk/apis/roundtrip_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
sdktesting "github.com/kcp-dev/kcp/sdk/testing"
3737
)
3838

39-
// in non-race-detection mode, a higher number of iterations is reasonable
39+
// in non-race-detection mode, a higher number of iterations is reasonable.
4040
const defaultFuzzIters = 200
4141

4242
var FuzzIters = flag.Int("fuzz-iters", defaultFuzzIters, "How many fuzzing iterations to do.")
@@ -56,7 +56,6 @@ func TestRoundTripTypes(t *testing.T) {
5656
seed := rand.Int63()
5757
fuzzer := fuzzer.FuzzerFor(sdktesting.FuzzerFuncs, rand.NewSource(seed), codecs)
5858
roundtrip.RoundTripExternalTypesWithoutProtobuf(t, scheme, codecs, fuzzer, nil)
59-
6059
}
6160

6261
type ConvertionTests struct {

sdk/apis/third_party/conditions/apis/conditions/v1alpha1/constants.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const (
7575
// ControlPlaneReadyCondition reports the ready condition from the control plane object defined for this cluster.
7676
// This condition is mirrored from the Ready condition in the control plane ref object, and
7777
// the absence of this condition might signal problems in the reconcile external loops or the fact that
78-
// the control plane provider does not not implements the Ready condition yet.
78+
// the control plane provider does not implements the Ready condition yet.
7979
ControlPlaneReadyCondition ConditionType = "ControlPlaneReady"
8080

8181
// WaitingForControlPlaneFallbackReason (Severity=Info) documents a cluster waiting for the control plane

sdk/apis/third_party/conditions/apis/conditions/v1alpha1/register.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ import (
2020
"k8s.io/apimachinery/pkg/runtime/schema"
2121
)
2222

23-
// SchemeGroupVersion is group version used to register these objects
23+
// SchemeGroupVersion is group version used to register these objects.
2424
var SchemeGroupVersion = schema.GroupVersion{Group: "conditions.kcp.io", Version: "v1alpha1"}

sdk/apis/third_party/conditions/util/conditions/getter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func mirror(from Getter, targetCondition conditionsapi.ConditionType, options ..
235235
return condition
236236
}
237237

238-
// Aggregates all the the Ready condition from a list of dependent objects into the target object;
238+
// Aggregates all the Ready condition from a list of dependent objects into the target object;
239239
// if the Ready condition does not exists in one of the source object, the object is excluded from
240240
// the aggregation; if none of the source object have ready condition, no target conditions is generated.
241241
func aggregate(from []Getter, targetCondition conditionsapi.ConditionType, options ...MergeOption) *conditionsapi.Condition {

sdk/apis/third_party/conditions/util/conditions/merge.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,25 @@ func (g conditionGroups) Swap(i, j int) {
132132
g[i], g[j] = g[j], g[i]
133133
}
134134

135-
// TopGroup returns the the condition group with the highest mergePriority.
135+
// TopGroup returns the condition group with the highest mergePriority.
136136
func (g conditionGroups) TopGroup() *conditionGroup {
137137
if len(g) == 0 {
138138
return nil
139139
}
140140
return &g[0]
141141
}
142142

143-
// TrueGroup returns the the condition group with status True, if any.
143+
// TrueGroup returns the condition group with status True, if any.
144144
func (g conditionGroups) TrueGroup() *conditionGroup {
145145
return g.getByStatusAndSeverity(corev1.ConditionTrue, conditionsapi.ConditionSeverityNone)
146146
}
147147

148-
// ErrorGroup returns the the condition group with status False and severity Error, if any.
148+
// ErrorGroup returns the condition group with status False and severity Error, if any.
149149
func (g conditionGroups) ErrorGroup() *conditionGroup {
150150
return g.getByStatusAndSeverity(corev1.ConditionFalse, conditionsapi.ConditionSeverityError)
151151
}
152152

153-
// WarningGroup returns the the condition group with status False and severity Warning, if any.
153+
// WarningGroup returns the condition group with status False and severity Warning, if any.
154154
func (g conditionGroups) WarningGroup() *conditionGroup {
155155
return g.getByStatusAndSeverity(corev1.ConditionFalse, conditionsapi.ConditionSeverityWarning)
156156
}

sdk/apis/third_party/conditions/util/conditions/setter.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ func SetSummary(to Setter, options ...MergeOption) {
127127
Set(to, summary(to, options...))
128128
}
129129

130-
// SetMirror creates a new condition by mirroring the the Ready condition from a dependent object;
130+
// SetMirror creates a new condition by mirroring the Ready condition from a dependent object;
131131
// if the Ready condition does not exists in the source object, no target conditions is generated.
132132
func SetMirror(to Setter, targetCondition conditionsapi.ConditionType, from Getter, options ...MirrorOptions) {
133133
Set(to, mirror(from, targetCondition, options...))
134134
}
135135

136-
// SetAggregate creates a new condition with the aggregation of all the the Ready condition
136+
// SetAggregate creates a new condition with the aggregation of all the Ready condition
137137
// from a list of dependent objects; if the Ready condition does not exists in one of the source object,
138138
// the object is excluded from the aggregation; if none of the source object have ready condition,
139139
// no target conditions is generated.

sdk/testing/fuzzer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
apisfuzzer "github.com/kcp-dev/kcp/sdk/apis/apis/fuzzer"
2323
)
2424

25-
// FuzzerFuncs is a list of fuzzer functions
25+
// FuzzerFuncs is a list of fuzzer functions.
2626
var FuzzerFuncs = fuzzer.MergeFuzzerFuncs(
2727
apisfuzzer.Funcs,
2828
)

sdk/testing/server/fixture.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func NewFixture(t TestingT, cfgs ...Config) Fixture {
102102
t.Log("Starting kcp servers...")
103103
ctx, cancel := context.WithCancel(context.Background())
104104
t.Cleanup(cancel)
105-
g, ctx := errgroup.WithContext(ctx)
105+
g, _ := errgroup.WithContext(ctx)
106106
for i, srv := range servers {
107107
err := srv.Run(t)
108108
require.NoError(t, err)

0 commit comments

Comments
 (0)