mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 01:29:07 +00:00
Merge pull request #189 from ijc/image-config-substruct
Split config-related fields of Image into a substruct.
This commit is contained in:
commit
656bd87fd2
@ -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"`
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
)
|
||||
|
||||
func setupInspect(t *testing.T, label Image) types.ImageInspect {
|
||||
func setupInspect(t *testing.T, label ImageConfig) types.ImageInspect {
|
||||
var inspect types.ImageInspect
|
||||
var config container.Config
|
||||
|
||||
@ -30,14 +30,16 @@ func TestOverrides(t *testing.T) {
|
||||
var yamlCaps = []string{"CAP_SYS_ADMIN"}
|
||||
|
||||
var yaml = Image{
|
||||
Name: "test",
|
||||
Image: "testimage",
|
||||
Capabilities: &yamlCaps,
|
||||
Name: "test",
|
||||
Image: "testimage",
|
||||
ImageConfig: ImageConfig{
|
||||
Capabilities: &yamlCaps,
|
||||
},
|
||||
}
|
||||
|
||||
var labelCaps = []string{"CAP_SYS_CHROOT"}
|
||||
|
||||
var label = Image{
|
||||
var label = ImageConfig{
|
||||
Capabilities: &labelCaps,
|
||||
Cwd: "/label/directory",
|
||||
}
|
||||
@ -66,7 +68,7 @@ func TestInvalidCap(t *testing.T) {
|
||||
}
|
||||
|
||||
labelCaps := []string{"NOT_A_CAP"}
|
||||
var label = Image{
|
||||
var label = ImageConfig{
|
||||
Capabilities: &labelCaps,
|
||||
}
|
||||
|
||||
@ -87,11 +89,13 @@ func TestIdMap(t *testing.T) {
|
||||
yaml := Image{
|
||||
Name: "test",
|
||||
Image: "testimage",
|
||||
UID: &uid,
|
||||
GID: &gid,
|
||||
ImageConfig: ImageConfig{
|
||||
UID: &uid,
|
||||
GID: &gid,
|
||||
},
|
||||
}
|
||||
|
||||
var label = Image{}
|
||||
var label = ImageConfig{}
|
||||
|
||||
inspect := setupInspect(t, label)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user