-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config validation #39
Conversation
Signed-off-by: zhouhao <[email protected]>
5a87b2f
to
14935fb
Compare
// check if the rootfs type is 'layers' | ||
if c.RootFS.Type != "layers" { | ||
return errors.New("RootFs is an unknown rootfs type, MUST be 'layers'") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to check this in Go, because it's checked in JSON Schema since opencontainers/image-spec#358.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,thanks for your reminder
a7f5cc0
to
b5b670b
Compare
sure, but this is just checking os and arch which isn't adding a proper config validation. Can we at least have a "CheckConfig" instead of various methods that check various stuff in the config? Also, why checking the config while finding it? should it be validated in the caller after finding it? it really seems part of "validating", not the lookup for the config file. |
Maybe I had a problem with the title name. I think config need to verify the place including rootfs (has been verified)), followed by OS and arch, I put the config validation into the findconfig function, and not a separate list of functions @runcom |
On Thu, Oct 13, 2016 at 02:56:14AM -0700, Antonio Murdaca wrote:
+1. Retrieval and validation should be separate steps (although the |
@@ -68,6 +73,30 @@ func findConfig(w walker, d *descriptor) (*config, error) { | |||
} | |||
} | |||
|
|||
func checkPlatform(c config) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The desired location for this logic is still up in the air (as far as I can tell), with some folks arguing for just JSON Schema validation in image-spec (me and maybe @vbatts) and some (maybe @philips and @stevvooe) arguing for as much JSON validation as you can get (JSON Schema or otherwise) without needing to look outside the given JSON blob (e.g. at children it references). With the latter approach, this platform check would be landing in the image-spec repo (somewhere under schema/
?). It's probably best to wait until @stevvooe has filed his proposed package structure before moving ahead with this..
f7c0d9c
to
99f9203
Compare
ok,I have separated retrieval and validation, |
On Thu, Oct 13, 2016 at 07:41:57PM -0700, Zhou Hao wrote:
The JSON Schema validation 1 should be moved to your new (c |
@wking Thank you for your suggestion, but I do not think so. The JSON Schema validation is to confirm that the format conforms to config, in order to confirm the found file is config file, after which to verify its specific content. In the manifest.go file, the JSON Schema validation is also placed in the findManifest function, rather than in the validate function |
On Thu, Oct 13, 2016 at 11:13:58PM -0700, Zhou Hao wrote:
The JSON Schema check is validation that we want to apply to any |
We went on to talk about the problem, according to you, the JSON Schema validation should be moved to validate function, if so, should the findManifest function of JSON Schema validation into the corresponding also validate function? My understanding of this aspect is not enough in-depth, thank you for your guidance @wking |
On Tue, Oct 18, 2016 at 11:43:28PM -0700, Zhou Hao wrote:
I think all validation should be moved into validation-specific Once #5 or something like it lands, I'd like to switch to |
@@ -68,6 +64,44 @@ func findConfig(w walker, d *descriptor) (*config, error) { | |||
} | |||
} | |||
|
|||
func (c *config)validate() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it belongs upstream in the spec validation code. |
Signed-off-by: zhouhao <[email protected]>
But I think it also needs to be verified here |
On Wed, Oct 19, 2016 at 07:12:47PM -0700, Zhou Hao wrote:
You can still verify it here. There are several possible approaches |
@opencontainers/image-tools-maintainers PTAL |
@wking I think it is very difficult to check Platform in the image-spec, because os and arch are a range of values rather than a fixed value. |
I don't understand. You should just be able to copy your function over into image-spec. I can work up a PR for that if it would help clarify. |
This validation component should be using |
@stevvooe In the image-spec, the verification is to rely on json file to verify, and json file can only verify the specific value and type, os and arch are uncertain values (in the array of values ), So in the json file validation only verify its type, and its value is not within the scope of the specified array is difficult to achieve (at least for me, can not be achieved). This is where I have been puzzled. |
On Sun, Nov 20, 2016 at 07:00:58PM -0800, Zhou Hao wrote:
A lot of image-spec validation is based on JSON Schema, but image-spec |
@wking I got it,I understand the wrong before, thank you |
@q384566678 It sounds to me like json-schema is a big bust. It can't seem to do the most basic of validation. More complex cases, like this, are impossible. |
Closing in favor of opencontainers/image-spec#469 |
I think the config may be validated when verifying the image file
Signed-off-by: zhouhao [email protected]