Skip to content

Commit 4fd3f75

Browse files
committed
lint
On-behalf-of: @SAP [email protected]
1 parent 4eb8c44 commit 4fd3f75

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

internal/discovery/client.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,9 @@ func (c *Client) RetrieveCRD(ctx context.Context, gk schema.GroupKind) (*apiexte
9797
}
9898

9999
// res could describe the main resource or one of its subresources.
100-
name := res.Name
101-
subresource := ""
102-
if strings.Contains(name, "/") {
103-
parts := strings.SplitN(name, "/", 2)
104-
name = parts[0]
100+
var subresource string
101+
if strings.Contains(res.Name, "/") {
102+
parts := strings.SplitN(res.Name, "/", 2)
105103
subresource = parts[1]
106104
}
107105

internal/projection/projection.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,16 @@ func ApplyProjection(crd *apiextensionsv1.CustomResourceDefinition, pubRes *sync
111111
func stripUnwantedVersions(crd *apiextensionsv1.CustomResourceDefinition, pubRes *syncagentv1alpha1.PublishedResource) (*apiextensionsv1.CustomResourceDefinition, error) {
112112
src := pubRes.Spec.Resource
113113

114+
//nolint:staticcheck
114115
if src.Version != "" && len(src.Versions) > 0 {
115116
return nil, errors.New("cannot configure both .version and .versions in as the source of a PublishedResource")
116117
}
117118

118119
crd.Spec.Versions = slices.DeleteFunc(crd.Spec.Versions, func(ver apiextensionsv1.CustomResourceDefinitionVersion) bool {
119120
switch {
121+
//nolint:staticcheck
120122
case src.Version != "":
123+
//nolint:staticcheck
121124
return ver.Name != src.Version
122125
case len(src.Versions) > 0:
123126
return !slices.Contains(src.Versions, ver.Name)
@@ -128,7 +131,9 @@ func stripUnwantedVersions(crd *apiextensionsv1.CustomResourceDefinition, pubRes
128131

129132
if len(crd.Spec.Versions) == 0 {
130133
switch {
134+
//nolint:staticcheck
131135
case src.Version != "":
136+
//nolint:staticcheck
132137
return nil, fmt.Errorf("CRD does not contain version %s", src.Version)
133138
case len(src.Versions) > 0:
134139
return nil, fmt.Errorf("CRD does not contain any of versions %v", src.Versions)
@@ -185,11 +190,13 @@ func projectCRD(crd *apiextensionsv1.CustomResourceDefinition, pubRes *syncagent
185190

186191
// We already validated that Version and Versions can be set at the same time.
187192

193+
//nolint:staticcheck
188194
if projection.Version != "" {
189195
if size := len(crd.Spec.Versions); size != 1 {
190196
return nil, fmt.Errorf("cannot project CRD version to a single version %q because it contains %d versions", projection.Version, size)
191197
}
192198

199+
//nolint:staticcheck
193200
crd.Spec.Versions[0].Name = projection.Version
194201
} else if len(projection.Versions) > 0 {
195202
for _, mut := range projection.Versions {

internal/projection/projection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"testing"
2121

2222
syncagentv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/syncagent/v1alpha1"
23-
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2423

24+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2525
"k8s.io/apimachinery/pkg/runtime/schema"
2626
)
2727

0 commit comments

Comments
 (0)