Skip to content

Commit 7a84b20

Browse files
author
Rui Yang
authored
Merge pull request #328 from concourse/issue/327-malform-check-version
Try to fix malform version for check command
2 parents 07859af + e66e93e commit 7a84b20

File tree

6 files changed

+114
-500
lines changed

6 files changed

+114
-500
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ Run the tests with the following commands for both `alpine` and `ubuntu` images:
581581

582582
```sh
583583
docker build -t registry-image-resource --target tests -f dockerfiles/alpine/Dockerfile .
584-
docker build -t registry-image-resource --target tests -f dockerfiles/ubuntu/Dockerfile .
584+
docker build -t registry-image-resource --target tests -f dockerfiles/ubuntu/Dockerfile --build-arg base_image=ubuntu:latest .
585+
585586
```
586587

587588
#### Integration tests

check_test.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ var _ = Describe("Check", func() {
115115

116116
BeforeEach(func() {
117117
registry.AppendHandlers(
118-
ghttp.CombineHandlers(
119-
ghttp.VerifyRequest("GET", "/v2/"),
120-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
121-
),
122118
ghttp.CombineHandlers(
123119
ghttp.VerifyRequest("GET", "/v2/"),
124120
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -129,10 +125,6 @@ var _ = Describe("Check", func() {
129125
"Content-Length": LATEST_FAKE_HEADERS["Content-Length"],
130126
}),
131127
),
132-
ghttp.CombineHandlers(
133-
ghttp.VerifyRequest("GET", "/v2/"),
134-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
135-
),
136128
ghttp.CombineHandlers(
137129
ghttp.VerifyRequest("GET", "/v2/fake-image/manifests/latest"),
138130
ghttp.RespondWith(http.StatusOK, `{"fake":"manifest"}`, http.Header{
@@ -160,10 +152,6 @@ var _ = Describe("Check", func() {
160152
registry = ghttp.NewTLSServer()
161153

162154
registry.AppendHandlers(
163-
ghttp.CombineHandlers(
164-
ghttp.VerifyRequest("GET", "/v2/"),
165-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
166-
),
167155
ghttp.CombineHandlers(
168156
ghttp.VerifyRequest("GET", "/v2/"),
169157
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -230,10 +218,6 @@ var _ = Describe("Check", func() {
230218
registry = ghttp.NewServer()
231219

232220
registry.AppendHandlers(
233-
ghttp.CombineHandlers(
234-
ghttp.VerifyRequest("GET", "/v2/"),
235-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
236-
),
237221
ghttp.CombineHandlers(
238222
ghttp.VerifyRequest("GET", "/v2/"),
239223
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -264,10 +248,6 @@ var _ = Describe("Check", func() {
264248
Context("which has the image", func() {
265249
BeforeEach(func() {
266250
mirror.AppendHandlers(
267-
ghttp.CombineHandlers(
268-
ghttp.VerifyRequest("GET", "/v2/"),
269-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
270-
),
271251
ghttp.CombineHandlers(
272252
ghttp.VerifyRequest("GET", "/v2/"),
273253
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -293,10 +273,6 @@ var _ = Describe("Check", func() {
293273
Context("which is missing the image", func() {
294274
BeforeEach(func() {
295275
mirror.AppendHandlers(
296-
ghttp.CombineHandlers(
297-
ghttp.VerifyRequest("GET", "/v2/"),
298-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
299-
),
300276
ghttp.CombineHandlers(
301277
ghttp.VerifyRequest("GET", "/v2/"),
302278
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -404,10 +380,6 @@ var _ = Describe("Check", func() {
404380
Context("which has the image", func() {
405381
BeforeEach(func() {
406382
mirror.AppendHandlers(
407-
ghttp.CombineHandlers(
408-
ghttp.VerifyRequest("GET", "/v2/"),
409-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
410-
),
411383
ghttp.CombineHandlers(
412384
ghttp.VerifyRequest("GET", "/v2/"),
413385
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -438,10 +410,6 @@ var _ = Describe("Check", func() {
438410
Context("which is missing the image", func() {
439411
BeforeEach(func() {
440412
mirror.AppendHandlers(
441-
ghttp.CombineHandlers(
442-
ghttp.VerifyRequest("GET", "/v2/"),
443-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
444-
),
445413
ghttp.CombineHandlers(
446414
ghttp.VerifyRequest("GET", "/v2/"),
447415
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -544,10 +512,6 @@ var _ = Describe("Check", func() {
544512
Context("which has the image", func() {
545513
BeforeEach(func() {
546514
mirror.AppendHandlers(
547-
ghttp.CombineHandlers(
548-
ghttp.VerifyRequest("GET", "/v2/"),
549-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
550-
),
551515
ghttp.CombineHandlers(
552516
ghttp.VerifyRequest("GET", "/v2/"),
553517
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -556,10 +520,6 @@ var _ = Describe("Check", func() {
556520
ghttp.VerifyRequest("HEAD", "/v2/library/fake-image/manifests/latest"),
557521
ghttp.RespondWith(http.StatusOK, ``, LATEST_FAKE_HEADERS),
558522
),
559-
ghttp.CombineHandlers(
560-
ghttp.VerifyRequest("GET", "/v2/"),
561-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
562-
),
563523
ghttp.CombineHandlers(
564524
ghttp.VerifyRequest("HEAD", "/v2/library/fake-image/manifests/"+OLDER_FAKE_DIGEST),
565525
ghttp.RespondWith(http.StatusOK, ``, OLDER_FAKE_HEADERS),
@@ -584,10 +544,6 @@ var _ = Describe("Check", func() {
584544
Context("which is missing the image", func() {
585545
BeforeEach(func() {
586546
mirror.AppendHandlers(
587-
ghttp.CombineHandlers(
588-
ghttp.VerifyRequest("GET", "/v2/"),
589-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
590-
),
591547
ghttp.CombineHandlers(
592548
ghttp.VerifyRequest("GET", "/v2/"),
593549
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -680,10 +636,6 @@ var _ = Describe("Check", func() {
680636
Context("which has the image", func() {
681637
BeforeEach(func() {
682638
mirror.AppendHandlers(
683-
ghttp.CombineHandlers(
684-
ghttp.VerifyRequest("GET", "/v2/"),
685-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
686-
),
687639
ghttp.CombineHandlers(
688640
ghttp.VerifyRequest("GET", "/v2/"),
689641
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
@@ -692,10 +644,6 @@ var _ = Describe("Check", func() {
692644
ghttp.VerifyRequest("HEAD", "/v2/library/fake-image/manifests/latest"),
693645
ghttp.RespondWith(http.StatusOK, ``, LATEST_FAKE_HEADERS),
694646
),
695-
ghttp.CombineHandlers(
696-
ghttp.VerifyRequest("GET", "/v2/"),
697-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
698-
),
699647
ghttp.CombineHandlers(
700648
ghttp.VerifyRequest("HEAD", "/v2/library/fake-image/manifests/"+req.Version.Digest),
701649
ghttp.RespondWith(http.StatusNotFound, `{"errors":[{"code": "MANIFEST_UNKNOWN", "message": "ruh roh", "detail": "not here"}]}`),
@@ -717,10 +665,6 @@ var _ = Describe("Check", func() {
717665
Context("which is missing the image", func() {
718666
BeforeEach(func() {
719667
mirror.AppendHandlers(
720-
ghttp.CombineHandlers(
721-
ghttp.VerifyRequest("GET", "/v2/"),
722-
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
723-
),
724668
ghttp.CombineHandlers(
725669
ghttp.VerifyRequest("GET", "/v2/"),
726670
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),

commands/check.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,17 @@ func headOrGet(ref name.Reference, imageOpts ...remote.Option) (v1.Hash, bool, e
331331
return v1.Hash{}, false, err
332332
}
333333

334+
if (remoteDesc.Digest == v1.Hash{}) {
335+
return v1.Hash{}, false, nil
336+
}
337+
334338
return remoteDesc.Digest, true, nil
335339
}
336340

341+
if (v1Desc.Digest == v1.Hash{}) {
342+
return v1.Hash{}, false, nil
343+
}
344+
337345
return v1Desc.Digest, true, nil
338346
}
339347

go.mod

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ require (
66
github.com/aws/aws-sdk-go v1.44.5
77
github.com/cenkalti/backoff v2.2.1+incompatible
88
github.com/concourse/go-archive v1.0.1
9-
github.com/containerd/stargz-snapshotter/estargz v0.11.4 // indirect
109
github.com/fatih/color v1.13.0
1110
github.com/go-sql-driver/mysql v1.5.0 // indirect
12-
github.com/golang/protobuf v1.5.2 // indirect
13-
github.com/google/go-containerregistry v0.9.0
11+
github.com/google/go-containerregistry v0.12.1
1412
github.com/onsi/ginkgo v1.16.4
1513
github.com/onsi/gomega v1.19.0
1614
github.com/simonshyu/notary-gcr v0.0.0-20220601090547-d99a631aa58b
17-
github.com/sirupsen/logrus v1.8.1
18-
github.com/theupdateframework/notary v0.6.1 // indirect
15+
github.com/sirupsen/logrus v1.9.0
1916
github.com/vbauerster/mpb v3.4.0+incompatible
2017
)
2118

0 commit comments

Comments
 (0)