mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-17 23:05:50 +02:00
Add helmfile-fetch command to downloading and generating charts (#1734)
This commit is contained in:
@@ -291,6 +291,24 @@ func (a *App) Lint(c LintConfigProvider) error {
|
||||
}, SetFilter(true))
|
||||
}
|
||||
|
||||
func (a *App) Fetch(c FetchConfigProvider) error {
|
||||
return a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
||||
prepErr := run.withPreparedCharts("pull", state.ChartPrepareOptions{
|
||||
ForceDownload: true,
|
||||
SkipRepos: c.SkipDeps(),
|
||||
SkipDeps: c.SkipDeps(),
|
||||
OutputDir: c.OutputDir(),
|
||||
}, func() {
|
||||
})
|
||||
|
||||
if prepErr != nil {
|
||||
errs = append(errs, prepErr)
|
||||
}
|
||||
|
||||
return
|
||||
}, SetFilter(true))
|
||||
}
|
||||
|
||||
func (a *App) Sync(c SyncConfigProvider) error {
|
||||
return a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
||||
prepErr := run.withPreparedCharts("sync", state.ChartPrepareOptions{
|
||||
|
||||
@@ -131,6 +131,13 @@ type LintConfigProvider interface {
|
||||
concurrencyConfig
|
||||
}
|
||||
|
||||
type FetchConfigProvider interface {
|
||||
SkipDeps() bool
|
||||
OutputDir() string
|
||||
|
||||
concurrencyConfig
|
||||
}
|
||||
|
||||
type TemplateConfigProvider interface {
|
||||
Args() string
|
||||
|
||||
|
||||
+17
-9
@@ -2,13 +2,14 @@ package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/roboll/helmfile/pkg/argparser"
|
||||
"github.com/roboll/helmfile/pkg/helmexec"
|
||||
"github.com/roboll/helmfile/pkg/state"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/roboll/helmfile/pkg/argparser"
|
||||
"github.com/roboll/helmfile/pkg/helmexec"
|
||||
"github.com/roboll/helmfile/pkg/state"
|
||||
)
|
||||
|
||||
type Run struct {
|
||||
@@ -49,13 +50,20 @@ func (r *Run) withPreparedCharts(helmfileCommand string, opts state.ChartPrepare
|
||||
}
|
||||
|
||||
// Create tmp directory and bail immediately if it fails
|
||||
dir, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
return err
|
||||
var dir string
|
||||
if len(opts.OutputDir) == 0 {
|
||||
tempDir, err := ioutil.TempDir("", "helmfile*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
dir = tempDir
|
||||
} else {
|
||||
dir = opts.OutputDir
|
||||
fmt.Printf("Charts will be downloaded to: %s\n", dir)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
if _, err = r.state.TriggerGlobalPrepareEvent(helmfileCommand); err != nil {
|
||||
if _, err := r.state.TriggerGlobalPrepareEvent(helmfileCommand); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -82,7 +90,7 @@ func (r *Run) withPreparedCharts(helmfileCommand string, opts state.ChartPrepare
|
||||
|
||||
f()
|
||||
|
||||
_, err = r.state.TriggerGlobalCleanupEvent(helmfileCommand)
|
||||
_, err := r.state.TriggerGlobalCleanupEvent(helmfileCommand)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -896,6 +896,7 @@ type ChartPrepareOptions struct {
|
||||
SkipResolve bool
|
||||
Wait bool
|
||||
WaitForJobs bool
|
||||
OutputDir string
|
||||
}
|
||||
|
||||
type chartPrepareResult struct {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestGenerateID(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user