mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-11-02 06:05:10 +00:00
This removes outputs from yaml, instead you can do ``` moby build -output tar -output qcow2 file.yaml ``` or alternative syntax ``` moby build -output tar,qcow2 file.yaml ``` In future we may change this to be available in a `moby package` step, but lets try this for now. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types/container"
|
|
)
|
|
|
|
func TestOverrides(t *testing.T) {
|
|
var yamlCaps = []string{"CAP_SYS_ADMIN"}
|
|
|
|
var yaml = MobyImage{
|
|
Name: "test",
|
|
Image: "testimage",
|
|
Capabilities: &yamlCaps,
|
|
}
|
|
|
|
var labelCaps = []string{"CAP_SYS_CHROOT"}
|
|
|
|
var label = MobyImage{
|
|
Capabilities: &labelCaps,
|
|
Cwd: "/label/directory",
|
|
}
|
|
|
|
var inspect types.ImageInspect
|
|
var config container.Config
|
|
|
|
labelJSON, err := json.Marshal(label)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
config.Labels = map[string]string{"org.mobyproject.config": string(labelJSON)}
|
|
|
|
inspect.Config = &config
|
|
|
|
oci, err := ConfigInspectToOCI(yaml, inspect)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if !reflect.DeepEqual(oci.Process.Capabilities.Bounding, yamlCaps) {
|
|
t.Error("Expected yaml capabilities to override but got", oci.Process.Capabilities.Bounding)
|
|
}
|
|
if oci.Process.Cwd != label.Cwd {
|
|
t.Error("Expected label Cwd to be applied, got", oci.Process.Cwd)
|
|
}
|
|
}
|