mirror of
https://github.com/foomo/squadron.git
synced 2025-10-16 12:35:42 +00:00
exposed GenerateYaml
This commit is contained in:
parent
b967071b6c
commit
820cbc5b38
22
helm.go
22
helm.go
@ -6,7 +6,6 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type ChartDependency struct {
|
||||
@ -45,23 +44,6 @@ type JobItem struct {
|
||||
chart string
|
||||
}
|
||||
|
||||
func generateYaml(_ *logrus.Entry, path string, data interface{}) error {
|
||||
out, marshalErr := yaml.Marshal(data)
|
||||
if marshalErr != nil {
|
||||
return marshalErr
|
||||
}
|
||||
file, crateErr := os.Create(path)
|
||||
if crateErr != nil {
|
||||
return crateErr
|
||||
}
|
||||
defer file.Close()
|
||||
_, writeErr := file.Write(out)
|
||||
if writeErr != nil {
|
||||
return writeErr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func helmUpdateDependency(l *logrus.Entry, group, groupChartPath string) (string, error) {
|
||||
l.Infof("Running helm dependency update for group: %v", group)
|
||||
cmd := []string{"helm", "dependency", "update", groupChartPath}
|
||||
@ -138,10 +120,10 @@ func (c Squadron) Install(ors map[string]Override, basePath, outputDir, namespac
|
||||
groupChart.Dependencies = append(groupChart.Dependencies, s.Chart)
|
||||
}
|
||||
|
||||
if err := generateYaml(logger, path.Join(groupChartPath, chartFile), groupChart); err != nil {
|
||||
if err := GenerateYaml(path.Join(groupChartPath, chartFile), groupChart); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := generateYaml(logger, path.Join(groupChartPath, valuesFile), ors); err != nil {
|
||||
if err := GenerateYaml(path.Join(groupChartPath, valuesFile), ors); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
17
squadron.go
17
squadron.go
@ -518,3 +518,20 @@ func (c *Cmd) Run() (string, error) {
|
||||
|
||||
return combinedBuf.String(), nil
|
||||
}
|
||||
|
||||
func GenerateYaml(path string, data interface{}) error {
|
||||
out, marshalErr := yaml.Marshal(data)
|
||||
if marshalErr != nil {
|
||||
return marshalErr
|
||||
}
|
||||
file, crateErr := os.Create(path)
|
||||
if crateErr != nil {
|
||||
return crateErr
|
||||
}
|
||||
defer file.Close()
|
||||
_, writeErr := file.Write(out)
|
||||
if writeErr != nil {
|
||||
return writeErr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user