From 493aeaa78dee39bd272932839b93494a35bd8d76 Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Tue, 4 Apr 2017 11:28:30 +0100 Subject: [PATCH] Split out OCI generation function This is to make unit testing easier for #1481 Signed-off-by: Justin Cormack --- src/cmd/moby/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cmd/moby/config.go b/src/cmd/moby/config.go index ab788091e..b7ebef06c 100644 --- a/src/cmd/moby/config.go +++ b/src/cmd/moby/config.go @@ -10,6 +10,7 @@ import ( "strings" log "github.com/Sirupsen/logrus" + "github.com/docker/engine-api/types" "github.com/opencontainers/runtime-spec/specs-go" "gopkg.in/yaml.v2" ) @@ -76,7 +77,6 @@ func NewConfig(config []byte) (*Moby, error) { // ConfigToOCI converts a config specification to an OCI config file func ConfigToOCI(image *MobyImage) ([]byte, error) { - oci := specs.Spec{} // TODO pass through same docker client to all functions cli, err := dockerClient() @@ -89,6 +89,13 @@ func ConfigToOCI(image *MobyImage) ([]byte, error) { return []byte{}, err } + return ConfigInspectToOCI(image, inspect) +} + +// ConfigInspectToOCI converts a config and the output of image inspect to an OCI config file +func ConfigInspectToOCI(image *MobyImage, inspect types.ImageInspect) ([]byte, error) { + oci := specs.Spec{} + config := inspect.Config if config == nil { return []byte{}, errors.New("empty image config")