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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user