@@ -69,10 +69,10 @@ func loadSettings(files []string) (map[string]interface{}, error) {
69
69
}
70
70
71
71
// Render renders the composefile for this app, merging in settings files, other compose files, end env
72
- func Render (appname string , composeFiles []string , settingsFile []string , env map [string ]string ) (string , error ) {
72
+ func Render (appname string , composeFiles []string , settingsFile []string , env map [string ]string ) (* composetypes. Config , error ) {
73
73
appname , cleanup , err := Extract (appname )
74
74
if err != nil {
75
- return "" , err
75
+ return nil , err
76
76
}
77
77
defer cleanup ()
78
78
// prepend the app settings to the argument settings
@@ -81,18 +81,18 @@ func Render(appname string, composeFiles []string, settingsFile []string, env ma
81
81
// load the settings into a struct
82
82
settings , err := loadSettings (sf )
83
83
if err != nil {
84
- return "" , err
84
+ return nil , err
85
85
}
86
86
// inject our metadata
87
87
metaFile := path .Join (appname , "metadata.yml" )
88
88
meta := make (map [interface {}]interface {})
89
89
metaContent , err := ioutil .ReadFile (metaFile )
90
90
if err != nil {
91
- return "" , err
91
+ return nil , err
92
92
}
93
93
err = yaml .Unmarshal (metaContent , & meta )
94
94
if err != nil {
95
- return "" , err
95
+ return nil , err
96
96
}
97
97
metaPrefixed := make (map [interface {}]interface {})
98
98
metaPrefixed ["app" ] = meta
@@ -109,7 +109,7 @@ func Render(appname string, composeFiles []string, settingsFile []string, env ma
109
109
var converted interface {}
110
110
err = yaml .Unmarshal ([]byte (v ), & converted )
111
111
if err != nil {
112
- return "" , err
112
+ return nil , err
113
113
}
114
114
val [ss [len (ss )- 1 ]] = converted
115
115
merge (settings , valroot )
@@ -125,20 +125,20 @@ func Render(appname string, composeFiles []string, settingsFile []string, env ma
125
125
for _ , c := range composes {
126
126
data , err := ioutil .ReadFile (c )
127
127
if err != nil {
128
- return "" , err
128
+ return nil , err
129
129
}
130
130
tmpl , err := template .New ("compose" ).Parse (string (data ))
131
131
if err != nil {
132
- return "" , err
132
+ return nil , err
133
133
}
134
134
yaml := bytes .NewBuffer (nil )
135
135
err = tmpl .Execute (yaml , settings )
136
136
if err != nil {
137
- return "" , err
137
+ return nil , err
138
138
}
139
139
parsed , err := loader .ParseYAML (yaml .Bytes ())
140
140
if err != nil {
141
- return "" , err
141
+ return nil , err
142
142
}
143
143
configFiles = append (configFiles , composetypes.ConfigFile {Config : parsed })
144
144
}
@@ -149,9 +149,5 @@ func Render(appname string, composeFiles []string, settingsFile []string, env ma
149
149
ConfigFiles : configFiles ,
150
150
Environment : finalEnv ,
151
151
})
152
- if err != nil {
153
- return "" , err
154
- }
155
- res , err := yaml .Marshal (rendered )
156
- return string (res ), err
152
+ return rendered , err
157
153
}
0 commit comments