Skip to content

Commit

Permalink
Merge pull request #328 from concourse/issue/327-malform-check-version
Browse files Browse the repository at this point in the history
Try to fix malform version for check command
  • Loading branch information
Rui Yang authored Nov 18, 2022
2 parents 07859af + e66e93e commit 7a84b20
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 500 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ Run the tests with the following commands for both `alpine` and `ubuntu` images:

```sh
docker build -t registry-image-resource --target tests -f dockerfiles/alpine/Dockerfile .
docker build -t registry-image-resource --target tests -f dockerfiles/ubuntu/Dockerfile .
docker build -t registry-image-resource --target tests -f dockerfiles/ubuntu/Dockerfile --build-arg base_image=ubuntu:latest .
```

#### Integration tests
Expand Down
56 changes: 0 additions & 56 deletions check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ var _ = Describe("Check", func() {

BeforeEach(func() {
registry.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand All @@ -129,10 +125,6 @@ var _ = Describe("Check", func() {
"Content-Length": LATEST_FAKE_HEADERS["Content-Length"],
}),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/fake-image/manifests/latest"),
ghttp.RespondWith(http.StatusOK, `{"fake":"manifest"}`, http.Header{
Expand Down Expand Up @@ -160,10 +152,6 @@ var _ = Describe("Check", func() {
registry = ghttp.NewTLSServer()

registry.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand Down Expand Up @@ -230,10 +218,6 @@ var _ = Describe("Check", func() {
registry = ghttp.NewServer()

registry.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand Down Expand Up @@ -264,10 +248,6 @@ var _ = Describe("Check", func() {
Context("which has the image", func() {
BeforeEach(func() {
mirror.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand All @@ -293,10 +273,6 @@ var _ = Describe("Check", func() {
Context("which is missing the image", func() {
BeforeEach(func() {
mirror.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand Down Expand Up @@ -404,10 +380,6 @@ var _ = Describe("Check", func() {
Context("which has the image", func() {
BeforeEach(func() {
mirror.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand Down Expand Up @@ -438,10 +410,6 @@ var _ = Describe("Check", func() {
Context("which is missing the image", func() {
BeforeEach(func() {
mirror.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand Down Expand Up @@ -544,10 +512,6 @@ var _ = Describe("Check", func() {
Context("which has the image", func() {
BeforeEach(func() {
mirror.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand All @@ -556,10 +520,6 @@ var _ = Describe("Check", func() {
ghttp.VerifyRequest("HEAD", "/v2/library/fake-image/manifests/latest"),
ghttp.RespondWith(http.StatusOK, ``, LATEST_FAKE_HEADERS),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("HEAD", "/v2/library/fake-image/manifests/"+OLDER_FAKE_DIGEST),
ghttp.RespondWith(http.StatusOK, ``, OLDER_FAKE_HEADERS),
Expand All @@ -584,10 +544,6 @@ var _ = Describe("Check", func() {
Context("which is missing the image", func() {
BeforeEach(func() {
mirror.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand Down Expand Up @@ -680,10 +636,6 @@ var _ = Describe("Check", func() {
Context("which has the image", func() {
BeforeEach(func() {
mirror.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand All @@ -692,10 +644,6 @@ var _ = Describe("Check", func() {
ghttp.VerifyRequest("HEAD", "/v2/library/fake-image/manifests/latest"),
ghttp.RespondWith(http.StatusOK, ``, LATEST_FAKE_HEADERS),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("HEAD", "/v2/library/fake-image/manifests/"+req.Version.Digest),
ghttp.RespondWith(http.StatusNotFound, `{"errors":[{"code": "MANIFEST_UNKNOWN", "message": "ruh roh", "detail": "not here"}]}`),
Expand All @@ -717,10 +665,6 @@ var _ = Describe("Check", func() {
Context("which is missing the image", func() {
BeforeEach(func() {
mirror.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/"),
ghttp.RespondWith(http.StatusOK, `welcome to zombocom`),
Expand Down
8 changes: 8 additions & 0 deletions commands/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,17 @@ func headOrGet(ref name.Reference, imageOpts ...remote.Option) (v1.Hash, bool, e
return v1.Hash{}, false, err
}

if (remoteDesc.Digest == v1.Hash{}) {
return v1.Hash{}, false, nil
}

return remoteDesc.Digest, true, nil
}

if (v1Desc.Digest == v1.Hash{}) {
return v1.Hash{}, false, nil
}

return v1Desc.Digest, true, nil
}

Expand Down
7 changes: 2 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ require (
github.com/aws/aws-sdk-go v1.44.5
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/concourse/go-archive v1.0.1
github.com/containerd/stargz-snapshotter/estargz v0.11.4 // indirect
github.com/fatih/color v1.13.0
github.com/go-sql-driver/mysql v1.5.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-containerregistry v0.9.0
github.com/google/go-containerregistry v0.12.1
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.19.0
github.com/simonshyu/notary-gcr v0.0.0-20220601090547-d99a631aa58b
github.com/sirupsen/logrus v1.8.1
github.com/theupdateframework/notary v0.6.1 // indirect
github.com/sirupsen/logrus v1.9.0
github.com/vbauerster/mpb v3.4.0+incompatible
)

Expand Down
Loading

0 comments on commit 7a84b20

Please sign in to comment.