mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #5040 from crosbymichael/remove-context-from-config
Remove context from config
This commit is contained in:
commit
2fde8dfb83
3 changed files with 7 additions and 21 deletions
|
@ -1,10 +1,8 @@
|
||||||
package runconfig
|
package runconfig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"github.com/dotcloud/docker/engine"
|
"github.com/dotcloud/docker/engine"
|
||||||
"github.com/dotcloud/docker/nat"
|
"github.com/dotcloud/docker/nat"
|
||||||
"github.com/dotcloud/docker/runtime/execdriver"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Note: the Config structure should hold only portable information about the container.
|
// Note: the Config structure should hold only portable information about the container.
|
||||||
|
@ -36,17 +34,9 @@ type Config struct {
|
||||||
Entrypoint []string
|
Entrypoint []string
|
||||||
NetworkDisabled bool
|
NetworkDisabled bool
|
||||||
OnBuild []string
|
OnBuild []string
|
||||||
Context execdriver.Context
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContainerConfigFromJob(job *engine.Job) *Config {
|
func ContainerConfigFromJob(job *engine.Job) *Config {
|
||||||
var context execdriver.Context
|
|
||||||
val := job.Getenv("Context")
|
|
||||||
if val != "" {
|
|
||||||
if err := json.Unmarshal([]byte(val), &context); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
config := &Config{
|
config := &Config{
|
||||||
Hostname: job.Getenv("Hostname"),
|
Hostname: job.Getenv("Hostname"),
|
||||||
Domainname: job.Getenv("Domainname"),
|
Domainname: job.Getenv("Domainname"),
|
||||||
|
@ -64,7 +54,6 @@ func ContainerConfigFromJob(job *engine.Job) *Config {
|
||||||
VolumesFrom: job.Getenv("VolumesFrom"),
|
VolumesFrom: job.Getenv("VolumesFrom"),
|
||||||
WorkingDir: job.Getenv("WorkingDir"),
|
WorkingDir: job.Getenv("WorkingDir"),
|
||||||
NetworkDisabled: job.GetenvBool("NetworkDisabled"),
|
NetworkDisabled: job.GetenvBool("NetworkDisabled"),
|
||||||
Context: context,
|
|
||||||
}
|
}
|
||||||
job.GetenvJson("ExposedPorts", &config.ExposedPorts)
|
job.GetenvJson("ExposedPorts", &config.ExposedPorts)
|
||||||
job.GetenvJson("Volumes", &config.Volumes)
|
job.GetenvJson("Volumes", &config.Volumes)
|
||||||
|
@ -86,6 +75,5 @@ func ContainerConfigFromJob(job *engine.Job) *Config {
|
||||||
if Entrypoint := job.GetenvList("Entrypoint"); Entrypoint != nil {
|
if Entrypoint := job.GetenvList("Entrypoint"); Entrypoint != nil {
|
||||||
config.Entrypoint = Entrypoint
|
config.Entrypoint = Entrypoint
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ func init() {
|
||||||
type Driver struct {
|
type Driver struct {
|
||||||
*DeviceSet
|
*DeviceSet
|
||||||
home string
|
home string
|
||||||
MountLabel string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Init = func(home string) (graphdriver.Driver, error) {
|
var Init = func(home string) (graphdriver.Driver, error) {
|
||||||
|
@ -62,12 +61,11 @@ func (d *Driver) Cleanup() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Create(id, parent string, mountLabel string) error {
|
func (d *Driver) Create(id, parent string, mountLabel string) error {
|
||||||
d.MountLabel = mountLabel
|
|
||||||
if err := d.DeviceSet.AddDevice(id, parent); err != nil {
|
if err := d.DeviceSet.AddDevice(id, parent); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
mp := path.Join(d.home, "mnt", id)
|
mp := path.Join(d.home, "mnt", id)
|
||||||
if err := d.mount(id, mp, d.MountLabel); err != nil {
|
if err := d.mount(id, mp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +115,7 @@ func (d *Driver) Remove(id string) error {
|
||||||
|
|
||||||
func (d *Driver) Get(id string) (string, error) {
|
func (d *Driver) Get(id string) (string, error) {
|
||||||
mp := path.Join(d.home, "mnt", id)
|
mp := path.Join(d.home, "mnt", id)
|
||||||
if err := d.mount(id, mp, d.MountLabel); err != nil {
|
if err := d.mount(id, mp); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,13 +128,13 @@ func (d *Driver) Put(id string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) mount(id, mountPoint string, mountLabel string) error {
|
func (d *Driver) mount(id, mountPoint string) error {
|
||||||
// Create the target directories if they don't exist
|
// Create the target directories if they don't exist
|
||||||
if err := osMkdirAll(mountPoint, 0755); err != nil && !osIsExist(err) {
|
if err := osMkdirAll(mountPoint, 0755); err != nil && !osIsExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Mount the device
|
// Mount the device
|
||||||
return d.DeviceSet.MountDevice(id, mountPoint, mountLabel)
|
return d.DeviceSet.MountDevice(id, mountPoint, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Exists(id string) bool {
|
func (d *Driver) Exists(id string) bool {
|
||||||
|
|
|
@ -499,7 +499,7 @@ func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe
|
||||||
}
|
}
|
||||||
|
|
||||||
initID := fmt.Sprintf("%s-init", container.ID)
|
initID := fmt.Sprintf("%s-init", container.ID)
|
||||||
if err := runtime.driver.Create(initID, img.ID, config.Context["mount_label"]); err != nil {
|
if err := runtime.driver.Create(initID, img.ID, ""); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
initPath, err := runtime.driver.Get(initID)
|
initPath, err := runtime.driver.Get(initID)
|
||||||
|
@ -512,7 +512,7 @@ func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := runtime.driver.Create(container.ID, initID, config.Context["mount_label"]); err != nil {
|
if err := runtime.driver.Create(container.ID, initID, ""); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
resolvConf, err := utils.GetResolvConf()
|
resolvConf, err := utils.GetResolvConf()
|
||||||
|
|
Loading…
Add table
Reference in a new issue