Skip to content

Commit 49cab49

Browse files
committed
all: run staticcheck and fix results
Change/remove some deprecated useages. Wire up `cmdGetBlob` in `cmd/ocisrv` - although it's currently unused, it might be useful in the future. Signed-off-by: Roger Peppe <rogpeppe@gmail.com> Change-Id: Ic77ed6a48599d8fbe8d1b6a32386ccf12ec1e9ea Reviewed-on: https://review.gerrithub.io/c/cue-labs/oci/+/1218351 TryBot-Result: CUE porcuepine <cue.porcuepine@gmail.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
1 parent 69d4dfa commit 49cab49

3 files changed

Lines changed: 14 additions & 19 deletions

File tree

cmd/ocisrv/main_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,9 @@ func init() {
4848
}
4949

5050
func TestMain(m *testing.M) {
51-
os.Exit(testscript.RunMain(m, map[string]func() int{
52-
"ocisrv": func() int {
53-
main()
54-
return 0
55-
},
56-
}))
51+
testscript.Main(m, map[string]func(){
52+
"ocisrv": main,
53+
})
5754
}
5855

5956
func TestScript(t *testing.T) {
@@ -65,6 +62,7 @@ func TestScript(t *testing.T) {
6562
},
6663
Cmds: map[string]func(ts *testscript.TestScript, neg bool, args []string){
6764
"pushblob": cmdPushBlob,
65+
"getblob": cmdGetBlob,
6866
},
6967
})
7068
}

ociregistry/ociauth/authfile_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import (
1616
func TestMain(m *testing.M) {
1717
// We're using testscript, not for txtar tests,
1818
// but to access the test executable functionality.
19-
os.Exit(testscript.RunMain(m, map[string]func() int{
19+
testscript.Main(m, map[string]func(){
2020
"docker-credential-test": helperMain,
21-
}))
21+
})
2222
}
2323

2424
func TestLoadWithNoConfig(t *testing.T) {
@@ -406,7 +406,7 @@ func noRunner(helperName string, serverURL string) (ConfigEntry, error) {
406406
}
407407

408408
// helperMain implements a docker credential command main function.
409-
func helperMain() int {
409+
func helperMain() {
410410
flag.Parse()
411411
if flag.NArg() != 1 || flag.Arg(0) != "get" {
412412
log.Fatal("usage: docker-credential-test get")
@@ -437,10 +437,9 @@ func helperMain() int {
437437
}`, os.Getenv("TEST_SECRET"))
438438
case "registry-with-error.com":
439439
fmt.Fprintf(os.Stderr, "some error\n")
440-
return 1
440+
os.Exit(1)
441441
default:
442442
fmt.Printf("credentials not found in native keychain\n")
443-
return 1
443+
os.Exit(1)
444444
}
445-
return 0
446445
}

ociregistry/ociserver/mediatype.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ import (
1919
)
2020

2121
const (
22-
mediaTypeOCIImageIndex = ocispec.MediaTypeImageIndex
23-
mediaTypeOCIRestrictedLayer = ocispec.MediaTypeImageLayerNonDistributableGzip
24-
mediaTypeOCIUncompressedRestrictedLayer = ocispec.MediaTypeImageLayerNonDistributable
25-
mediaTypeOCIManifestSchema1 = ocispec.MediaTypeImageManifest
26-
mediaTypeOCIConfigJSON = ocispec.MediaTypeImageConfig
27-
mediaTypeDockerConfigJSON = "application/vnd.docker.container.image.v1+json"
28-
mediaTypeOctetStream = "application/octet-stream"
22+
mediaTypeOCIImageIndex = ocispec.MediaTypeImageIndex
23+
mediaTypeOCIManifestSchema1 = ocispec.MediaTypeImageManifest
24+
mediaTypeOCIConfigJSON = ocispec.MediaTypeImageConfig
25+
mediaTypeDockerConfigJSON = "application/vnd.docker.container.image.v1+json"
26+
mediaTypeOctetStream = "application/octet-stream"
2927
)

0 commit comments

Comments
 (0)