image-tools icon indicating copy to clipboard operation
image-tools copied to clipboard

master broken: unable to validate: open /config-schema.json: no such file or directory

Open philips opened this issue 7 years ago • 6 comments

From @wking on June 21, 2016 3:17

This is probably due to the floating dependencies without #148, but recent builds in a clean Go directory break with:

$ make test
go test -race ./...
?       github.com/opencontainers/image-spec/cmd/oci-image-tool [no test files]
?       github.com/opencontainers/image-spec/image      [no test files]
--- FAIL: TestConfig (0.00s)
        config_test.go:162: test 6: expected validation failure false but got true, err schema application/vnd.oci.image.serialization.config.v1+json: unable to validate: open /config-schema.json: no such file or directory
…

Copied from original issue: opencontainers/image-spec#162

philips avatar Sep 21 '16 02:09 philips

From @wking on June 21, 2016 3:26

Spun off from earlier discussion in #161.

philips avatar Sep 21 '16 02:09 philips

From @wking on June 21, 2016 4:0

And the problem is (not surprisingly, given the error message) with http/FileSystem (see discussion in #150). The tests pass with the following patch:

diff --git a/schema/validator.go b/schema/validator.go
index abc8d6d..537314a 100644
--- a/schema/validator.go
+++ b/schema/validator.go
@@ -19,6 +19,7 @@ import (
    "fmt"
    "io"
    "io/ioutil"
+   "path/filepath"

    "github.com/pkg/errors"
    "github.com/xeipuuv/gojsonschema"
@@ -44,7 +45,12 @@ func (v Validator) Validate(src io.Reader) error {
        return errors.Wrap(err, "unable to read manifest")
    }

-   sl := gojsonschema.NewReferenceLoaderFileSystem("file:///"+specs[v], fs)
+   //sl := gojsonschema.NewReferenceLoaderFileSystem("file:///"+specs[v], fs)
+   refPath, err := filepath.Abs(specs[v])
+   if err != nil {
+       return err
+   }
+   sl := gojsonschema.NewReferenceLoader("file://" + refPath)
    ml := gojsonschema.NewStringLoader(string(buf))

    result, err := gojsonschema.Validate(sl, ml)

philips avatar Sep 21 '16 02:09 philips

From @wking on June 21, 2016 4:13

Rolling back assorted dependencies, the issue was introduced by xeipuuv/gojsonschema#103, and there are already comments there about broken loading as a result. So folks who want a working test suite should pin thier gojsonschema before that PR landed or wait until they roll out a fix.

philips avatar Sep 21 '16 02:09 philips

From @vbatts on June 21, 2016 14:10

correct. rolling back https://github.com/xeipuuv/gojsonschema/commit/ac948b64b57aa1beeb91c87069730e6f24bc91d9 lets the tests pass again. :-\

philips avatar Sep 21 '16 02:09 philips

From @petemoore on June 21, 2016 17:43

I think https://github.com/xeipuuv/gojsonschema/pull/105 fixed a bug introduced in https://github.com/xeipuuv/gojsonschema/pull/103 - so you might not need to pin anymore...

philips avatar Sep 21 '16 02:09 philips

From @vbatts on June 21, 2016 17:45

nope. 105 did not fix the issue.

On Tue, Jun 21, 2016 at 1:43 PM, Pete Moore [email protected] wrote:

I think xeipuuv/gojsonschema#105 https://github.com/xeipuuv/gojsonschema/pull/105 fixed a bug introduced in xeipuuv/gojsonschema#103 https://github.com/xeipuuv/gojsonschema/pull/103 - so you might not need to pin anymore...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/opencontainers/image-spec/issues/162#issuecomment-227516349, or mute the thread https://github.com/notifications/unsubscribe/AAEF6eMLXQhr52m7X1lzPZ_pGd7uyoU9ks5qOCLFgaJpZM4I6Uyb .

philips avatar Sep 21 '16 02:09 philips