Move Config and HostConfig from runconfig to types/container.

- Make the API client library completely standalone.
- Move windows partition isolation detection to the client, so the
  driver doesn't use external types.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2015-12-18 13:36:17 -05:00
parent 747dccde41
commit 7ac4232e70
65 changed files with 732 additions and 686 deletions

View File

@@ -10,7 +10,7 @@ import (
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/runconfig"
"github.com/docker/docker/api/types/container"
)
// Context represents a file system tree.
@@ -113,7 +113,7 @@ type Backend interface {
// Kill stops the container execution abruptly.
ContainerKill(containerID string, sig uint64) error
// Start starts a new container
ContainerStart(containerID string, hostConfig *runconfig.HostConfig) error
ContainerStart(containerID string, hostConfig *container.HostConfig) error
// ContainerWait stops processing until the given container is stopped.
ContainerWait(containerID string, timeout time.Duration) (int, error)
@@ -135,5 +135,5 @@ type Backend interface {
type ImageCache interface {
// GetCachedImage returns a reference to a cached image whose parent equals `parent`
// and runconfig equals `cfg`. A cache miss is expected to return an empty ID and a nil error.
GetCachedImage(parentID string, cfg *runconfig.Config) (imageID string, err error)
GetCachedImage(parentID string, cfg *container.Config) (imageID string, err error)
}

View File

@@ -10,11 +10,11 @@ import (
"sync"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/builder"
"github.com/docker/docker/builder/dockerfile/parser"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/ulimit"
"github.com/docker/docker/runconfig"
)
var validCommitCommands = map[string]bool{
@@ -52,7 +52,7 @@ type Config struct {
ForceRemove bool
Pull bool
BuildArgs map[string]string // build-time args received in build context for expansion/substitution and commands in 'run'.
Isolation runconfig.IsolationLevel
Isolation container.IsolationLevel
// resource constraints
// TODO: factor out to be reused with Run ?
@@ -81,7 +81,7 @@ type Builder struct {
context builder.Context
dockerfile *parser.Node
runConfig *runconfig.Config // runconfig for cmd, run, entrypoint etc.
runConfig *container.Config // runconfig for cmd, run, entrypoint etc.
flags *BFlags
tmpContainers map[string]struct{}
image string // imageID
@@ -114,7 +114,7 @@ func NewBuilder(config *Config, docker builder.Backend, context builder.Context,
Stderr: os.Stderr,
docker: docker,
context: context,
runConfig: new(runconfig.Config),
runConfig: new(container.Config),
tmpContainers: map[string]struct{}{},
cancelled: make(chan struct{}),
id: stringid.GenerateNonCryptoID(),
@@ -206,7 +206,7 @@ func (b *Builder) Cancel() {
// - call parse.Parse() to get AST root from Dockerfile entries
// - do build by calling builder.dispatch() to call all entries' handling routines
// TODO: remove?
func BuildFromConfig(config *runconfig.Config, changes []string) (*runconfig.Config, error) {
func BuildFromConfig(config *container.Config, changes []string) (*container.Config, error) {
ast, err := parser.Parse(bytes.NewBufferString(strings.Join(changes, "\n")))
if err != nil {
return nil, err

View File

@@ -21,6 +21,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/builder"
"github.com/docker/docker/builder/dockerfile/parser"
@@ -34,7 +35,6 @@ import (
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/pkg/tarsum"
"github.com/docker/docker/pkg/urlutil"
"github.com/docker/docker/runconfig"
)
func (b *Builder) commit(id string, autoCmd *strslice.StrSlice, comment string) error {
@@ -476,7 +476,7 @@ func (b *Builder) create() (string, error) {
}
b.runConfig.Image = b.image
resources := runconfig.Resources{
resources := container.Resources{
CgroupParent: b.CgroupParent,
CPUShares: b.CPUShares,
CPUPeriod: b.CPUPeriod,
@@ -489,7 +489,7 @@ func (b *Builder) create() (string, error) {
}
// TODO: why not embed a hostconfig in builder?
hostConfig := &runconfig.HostConfig{
hostConfig := &container.HostConfig{
Isolation: b.Isolation,
ShmSize: b.ShmSize,
Resources: resources,

View File

@@ -1,9 +1,9 @@
package builder
import "github.com/docker/docker/runconfig"
import "github.com/docker/docker/api/types/container"
// Image represents a Docker image used by the builder.
type Image interface {
ID() string
Config() *runconfig.Config
Config() *container.Config
}