mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 18:11:35 +00:00
Turn Images into references
We want to modify some of the content of the Image structure and thus have to pass them by reference. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
e8a5728ca3
commit
1713f59e4f
@ -121,7 +121,7 @@ func enforceContentTrust(fullImageName string, config *TrustConfig) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func outputImage(image Image, section string, prefix string, m Moby, idMap map[string]uint32, dupMap map[string]string, pull bool, iw *tar.Writer) error {
|
||||
func outputImage(image *Image, section string, prefix string, m Moby, idMap map[string]uint32, dupMap map[string]string, pull bool, iw *tar.Writer) error {
|
||||
log.Infof(" Create OCI config for %s", image.Image)
|
||||
useTrust := enforceContentTrust(image.Image, &m.Trust)
|
||||
oci, runtime, err := ConfigToOCI(image, useTrust, idMap)
|
||||
|
@ -20,9 +20,9 @@ import (
|
||||
type Moby struct {
|
||||
Kernel KernelConfig `kernel:"cmdline" json:"kernel,omitempty"`
|
||||
Init []string `init:"cmdline" json:"init"`
|
||||
Onboot []Image `yaml:"onboot" json:"onboot"`
|
||||
Onshutdown []Image `yaml:"onshutdown" json:"onshutdown"`
|
||||
Services []Image `yaml:"services" json:"services"`
|
||||
Onboot []*Image `yaml:"onboot" json:"onboot"`
|
||||
Onshutdown []*Image `yaml:"onshutdown" json:"onshutdown"`
|
||||
Services []*Image `yaml:"services" json:"services"`
|
||||
Trust TrustConfig `yaml:"trust" json:"trust,omitempty"`
|
||||
Files []File `yaml:"files" json:"files"`
|
||||
}
|
||||
@ -290,7 +290,7 @@ func NewImage(config []byte) (Image, error) {
|
||||
}
|
||||
|
||||
// ConfigToOCI converts a config specification to an OCI config file and a runtime config
|
||||
func ConfigToOCI(image Image, trust bool, idMap map[string]uint32) (specs.Spec, Runtime, error) {
|
||||
func ConfigToOCI(image *Image, trust bool, idMap map[string]uint32) (specs.Spec, Runtime, error) {
|
||||
|
||||
// TODO pass through same docker client to all functions
|
||||
cli, err := dockerClient()
|
||||
@ -649,7 +649,7 @@ func idNumeric(v interface{}, idMap map[string]uint32) (uint32, error) {
|
||||
}
|
||||
|
||||
// ConfigInspectToOCI converts a config and the output of image inspect to an OCI config
|
||||
func ConfigInspectToOCI(yaml Image, inspect types.ImageInspect, idMap map[string]uint32) (specs.Spec, Runtime, error) {
|
||||
func ConfigInspectToOCI(yaml *Image, inspect types.ImageInspect, idMap map[string]uint32) (specs.Spec, Runtime, error) {
|
||||
oci := specs.Spec{}
|
||||
runtime := Runtime{}
|
||||
|
||||
|
@ -44,7 +44,7 @@ func TestOverrides(t *testing.T) {
|
||||
|
||||
inspect := setupInspect(t, label)
|
||||
|
||||
oci, _, err := ConfigInspectToOCI(yaml, inspect, idMap)
|
||||
oci, _, err := ConfigInspectToOCI(&yaml, inspect, idMap)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@ -72,7 +72,7 @@ func TestInvalidCap(t *testing.T) {
|
||||
|
||||
inspect := setupInspect(t, label)
|
||||
|
||||
_, _, err := ConfigInspectToOCI(yaml, inspect, idMap)
|
||||
_, _, err := ConfigInspectToOCI(&yaml, inspect, idMap)
|
||||
if err == nil {
|
||||
t.Error("expected error, got valid OCI config")
|
||||
}
|
||||
@ -95,7 +95,7 @@ func TestIdMap(t *testing.T) {
|
||||
|
||||
inspect := setupInspect(t, label)
|
||||
|
||||
oci, _, err := ConfigInspectToOCI(yaml, inspect, idMap)
|
||||
oci, _, err := ConfigInspectToOCI(&yaml, inspect, idMap)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user