forked from openshift/library-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.go
31 lines (26 loc) · 1.14 KB
/
render.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package render
import (
"fmt"
"io/ioutil"
"path/filepath"
"github.com/openshift/library-go/pkg/assets"
"github.com/openshift/library-go/pkg/operator/render/options"
)
// WriteFiles writes the manifests and the bootstrap config file.
func WriteFiles(opt *options.GenericOptions, fileConfig *options.FileConfig, templateData interface{}, additionalPredicates ...assets.FileInfoPredicate) error {
// write assets
for _, manifestDir := range []string{"bootstrap-manifests", "manifests"} {
manifests, err := assets.New(filepath.Join(opt.TemplatesDir, manifestDir), templateData, append(additionalPredicates, assets.OnlyYaml)...)
if err != nil {
return fmt.Errorf("failed rendering assets: %v", err)
}
if err := manifests.WriteFiles(filepath.Join(opt.AssetOutputDir, manifestDir)); err != nil {
return fmt.Errorf("failed writing assets to %q: %v", filepath.Join(opt.AssetOutputDir, manifestDir), err)
}
}
// create bootstrap configuration
if err := ioutil.WriteFile(opt.ConfigOutputFile, fileConfig.BootstrapConfig, 0644); err != nil {
return fmt.Errorf("failed to write merged config to %q: %v", opt.ConfigOutputFile, err)
}
return nil
}