github.com/bdwilliams/libcompose@v0.3.1-0.20160826154243-d81a9bdacff0/project/project_config.go (about) 1 package project 2 3 import ( 4 "github.com/docker/libcompose/config" 5 "gopkg.in/yaml.v2" 6 ) 7 8 // ExportedConfig holds config attribute that will be exported 9 type ExportedConfig struct { 10 Version string `yaml:"version,omitempty"` 11 Services map[string]*config.ServiceConfig `yaml:"services"` 12 Volumes map[string]*config.VolumeConfig `yaml:"volumes"` 13 Networks map[string]*config.NetworkConfig `yaml:"networks"` 14 } 15 16 // Config validates and print the compose file. 17 func (p *Project) Config() (string, error) { 18 cfg := ExportedConfig{ 19 Version: "2.0", 20 Services: p.ServiceConfigs.All(), 21 Volumes: p.VolumeConfigs, 22 Networks: p.NetworkConfigs, 23 } 24 25 bytes, err := yaml.Marshal(cfg) 26 return string(bytes), err 27 }