Skip to content

Commit 2f2b3ab

Browse files
Merge pull request cri-o#9118 from kolyshkin/lint-v2-followups
Lint v2 followups
2 parents cbe1e02 + fe4378b commit 2f2b3ab

File tree

5 files changed

+26
-41
lines changed

5 files changed

+26
-41
lines changed

.golangci.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ linters:
6969
- recvcheck
7070
- revive
7171
- rowserrcheck
72-
- sloglint
7372
- spancheck
74-
- sqlclosecheck
7573
- staticcheck
7674
- tagalign
7775
- testableexamples
@@ -83,9 +81,7 @@ linters:
8381
- usestdlibvars
8482
- usetesting
8583
- wastedassign
86-
- whitespace
8784
- wsl
88-
- zerologlint
8985
# - containedctx
9086
# - contextcheck
9187
# - cyclop
@@ -139,20 +135,13 @@ linters:
139135
- 22
140136
disabled: false
141137
exclusions:
142-
generated: lax
138+
generated: strict
143139
presets:
144140
- comments
145-
- common-false-positives
146-
- legacy
147141
- std-error-handling
148-
paths:
149-
- third_party$
150-
- builtin$
151-
- examples$
152142
formatters:
153143
enable:
154144
- gci
155-
- gofmt
156145
- gofumpt
157146
- goimports
158147
settings:
@@ -162,8 +151,4 @@ formatters:
162151
- default
163152
- localmodule
164153
exclusions:
165-
generated: lax
166-
paths:
167-
- third_party$
168-
- builtin$
169-
- examples$
154+
generated: strict

internal/ociartifact/impl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Impl interface {
3030
GetBlob(context.Context, types.ImageSource, types.BlobInfo, types.BlobInfoCache) (io.ReadCloser, int64, error)
3131
ReadAll(io.Reader) ([]byte, error)
3232
OCI1FromManifest([]byte) (*manifest.OCI1, error)
33-
MarshalJSON(any) ([]byte, error)
33+
ToJSON(any) ([]byte, error)
3434
ManifestFromBlob([]byte, string) (manifest.Manifest, error)
3535
ManifestConfigMediaType(manifest.Manifest) string
3636
NewCopier(*libimage.CopyOptions, *types.SystemContext, *types.ImageReference) (*libimage.Copier, error)
@@ -89,7 +89,7 @@ func (*defaultImpl) OCI1FromManifest(manifestBlob []byte) (*manifest.OCI1, error
8989
return manifest.OCI1FromManifest(manifestBlob)
9090
}
9191

92-
func (*defaultImpl) MarshalJSON(v any) ([]byte, error) {
92+
func (*defaultImpl) ToJSON(v any) ([]byte, error) {
9393
return json.Marshal(v)
9494
}
9595

internal/ociartifact/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (s *Store) buildArtifact(ctx context.Context, item *layout.ListResult) (*Ar
289289
return nil, fmt.Errorf("convert manifest: %w", err)
290290
}
291291

292-
manifestBytes, err := s.impl.MarshalJSON(mani)
292+
manifestBytes, err := s.impl.ToJSON(mani)
293293
if err != nil {
294294
return nil, fmt.Errorf("marshal manifest: %w", err)
295295
}

internal/ociartifact/store_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ var _ = t.Describe("OCIArtifact", func() {
6464
getBlobErr error
6565
newImageSourceErrs [3]error
6666
layoutNewReferenceErrs [2]error
67-
marshalJSONErr error
67+
toJSONErr error
6868
oci1FromManifestErr error
6969
getManifestErrs [2]error
7070
listErr error
@@ -81,7 +81,7 @@ var _ = t.Describe("OCIArtifact", func() {
8181
getBlobErr: nil,
8282
newImageSourceErrs: [3]error{nil, nil, nil},
8383
layoutNewReferenceErrs: [2]error{nil, nil},
84-
marshalJSONErr: nil,
84+
toJSONErr: nil,
8585
oci1FromManifestErr: nil,
8686
getManifestErrs: [2]error{nil, nil},
8787
listErr: nil,
@@ -159,11 +159,11 @@ var _ = t.Describe("OCIArtifact", func() {
159159
}
160160

161161
res = append(res,
162-
implMock.EXPECT().MarshalJSON(gomock.Any()).Return(nil, opts.marshalJSONErr),
162+
implMock.EXPECT().ToJSON(gomock.Any()).Return(nil, opts.toJSONErr),
163163
implMock.EXPECT().CloseImageSource(gomock.Any()).Return(nil),
164164
)
165165

166-
if opts.marshalJSONErr != nil {
166+
if opts.toJSONErr != nil {
167167
return res
168168
}
169169

@@ -296,9 +296,9 @@ var _ = t.Describe("OCIArtifact", func() {
296296
Expect(data).To(BeNil())
297297
})
298298

299-
It("should fail if MarshalJSON fails", func() {
299+
It("should fail if JSON fails", func() {
300300
mockOptions := defaultMockOptions()
301-
mockOptions.marshalJSONErr = errTest
301+
mockOptions.toJSONErr = errTest
302302
gomock.InOrder(mockCalls(mockOptions)...)
303303

304304
data, err := sut.PullData(context.Background(), "", nil)

test/mocks/ociartifact/ociartifact.go

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)