Skip to content
Snippets Groups Projects

Few updates from downstream

Merged steeve.chailloux requested to merge topic/default/from-scl into branch/default
1 file
+ 25
6
Compare changes
  • Side-by-side
  • Inline
+ 37
10
@@ -8,6 +8,7 @@
"os"
"path/filepath"
"strings"
"sync"
"github.com/go-cmd/cmd"
"gopkg.in/yaml.v3"
@@ -41,6 +42,9 @@
return fmt.Errorf("cannot prepare variables: %w", err)
}
var outputDir string
if err := r.config.HelmDependencyBuild(); err != nil {
return err
}
if r.config.Output == "" {
w := bytes.NewBuffer([]byte{})
if err := hydrateString(r.config.Namespace, w, variables); err != nil {
@@ -104,7 +108,7 @@
}
}()
}
if err := hydrate(inFilePath, outFile, variables); err != nil {
if err := hydrate(inFilePath, outFile, variables, r.config.WithoutHydrate); err != nil {
return fmt.Errorf("cannot hydrate: %s - %w", outFilePath, err)
}
}
@@ -208,7 +212,7 @@
"build": RelInputFilePath,
}
if err := hydrate(backupFile, outFile, variables); err != nil {
if err := hydrate(backupFile, outFile, variables, r.config.WithoutHydrate); err != nil {
return nil, fmt.Errorf("cannot hydrate: %s - %w", fPath, err)
}
lastKustomizeFolder = filepath.Join(layer, "kustomize")
@@ -319,8 +323,28 @@
func (r *Runner) runCommands(tmpDir string, cmds map[string]*cmd.Cmd) ([]string, error) {
var compiled []string
for name, cmd := range cmds {
f, err := r.runCommand(tmpDir, name, cmd)
if err != nil {
return nil, err
var wg sync.WaitGroup
errors := make(chan error, len(cmds))
results := make(chan string, len(cmds))
for name, command := range cmds {
wg.Add(1)
go func(name string, c *cmd.Cmd) {
defer wg.Done()
f, err := r.runCommand(tmpDir, name, c)
if err != nil {
errors <- err
return
}
results <- f.Name()
}(name, command)
}
wg.Wait()
select {
case err := <-errors:
// return only the first error if any
return nil, err
default:
close(results)
for res := range results {
compiled = append(compiled, res)
}
@@ -326,3 +350,3 @@
}
compiled = append(compiled, f.Name())
return compiled, nil
}
@@ -328,5 +352,4 @@
}
return compiled, nil
}
func (r *Runner) runYtt(tmpDir string, compiled []string) (*os.File, error) {
@@ -400,5 +423,6 @@
if !ok {
namespace = ""
}
name, ok := metadata["name"]
var name interface{}
name, ok = metadata["name"]
if !ok {
@@ -404,5 +428,8 @@
if !ok {
return nil, fmt.Errorf("fail to type get metadata.name from: %+v", resource)
name, ok = metadata["generateName"]
if !ok {
return nil, fmt.Errorf("fail to type get metadata.name nor metadata.generateName from: %+v", resource)
}
}
filename := ""
if namespace != "" {
Loading