Split config-related fields of Image into a substruct.

Where "config-related" here means "ones you might find in the
"org.mobyproject.config" label on an image.

By making this new struct an anonymous member of the existing Image struct the
Go json parser does the right thing (i.e. inlines into the parent) when parsing
a complete image (from a yml assembly) by default. The Go yaml library which we
use requires a tag on the anonymous field to achieve the same.

Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
Ian Campbell 2017-11-27 12:37:03 +00:00
parent 63a5dedd28
commit aec82c4cdf

View File

@ -62,8 +62,14 @@ type File struct {
// Image is the type of an image config
type Image struct {
Name string `yaml:"name" json:"name"`
Image string `yaml:"image" json:"image"`
Name string `yaml:"name" json:"name"`
Image string `yaml:"image" json:"image"`
ImageConfig `yaml:",inline"`
}
// ImageConfig is the configuration part of Image, it is the subset
// which is valid in a "org.mobyproject.config" label on an image.
type ImageConfig struct {
Capabilities *[]string `yaml:"capabilities" json:"capabilities,omitempty"`
Ambient *[]string `yaml:"ambient" json:"ambient,omitempty"`
Mounts *[]specs.Mount `yaml:"mounts" json:"mounts,omitempty"`