1
0
mirror of https://github.com/rancher/os.git synced 2025-09-10 03:01:02 +00:00

Add multi docker command

This commit is contained in:
Jason-ZW
2018-06-27 12:08:32 +08:00
committed by niusmallnan
parent 05c2a40aa5
commit 0821c9a4ea
9 changed files with 489 additions and 14 deletions

View File

@@ -10,6 +10,7 @@ import (
yaml "github.com/cloudfoundry-incubator/candiedyaml"
composeConfig "github.com/docker/libcompose/config"
"github.com/rancher/os/config"
"github.com/rancher/os/log"
)
@@ -165,3 +166,30 @@ func LoadServiceResource(name string, useNetwork bool, cfg *config.CloudConfig)
return nil, err
}
func LoadMultiEngineResource(name string) ([]byte, error) {
composeConfigs := map[string]composeConfig.ServiceConfigV1{}
if _, err := os.Stat(config.MultiDockerConfFile); err == nil {
multiEngineBytes, err := ioutil.ReadFile(config.MultiDockerConfFile)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(multiEngineBytes, &composeConfigs)
if err != nil {
return nil, err
}
}
if _, ok := composeConfigs[name]; !ok {
return nil, errors.New("Failed to found " + name + " from " + config.MultiDockerConfFile + " will load from network")
}
foundServiceConfig := map[string]composeConfig.ServiceConfigV1{}
foundServiceConfig[name] = composeConfigs[name]
bytes, err := yaml.Marshal(foundServiceConfig)
if err == nil {
return bytes, err
}
return nil, err
}