Fix destory, delete, and test to work with chartify on local chart with dependencies that are not yet downloaded (#1801)

Fixes #1800
This commit is contained in:
Yusuke Kuoka 2021-04-24 20:50:16 +09:00 committed by GitHub
parent ce6a621414
commit 5a3bd7d649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 6 deletions

12
main.go
View File

@ -554,6 +554,10 @@ func main() {
Name: "purge", Name: "purge",
Usage: "purge releases i.e. free release names and histories", Usage: "purge releases i.e. free release names and histories",
}, },
cli.BoolFlag{
Name: "skip-deps",
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
}, },
Action: action(func(a *app.App, c configImpl) error { Action: action(func(a *app.App, c configImpl) error {
return a.Delete(c) return a.Delete(c)
@ -573,6 +577,10 @@ func main() {
Value: "", Value: "",
Usage: "pass args to helm exec", Usage: "pass args to helm exec",
}, },
cli.BoolFlag{
Name: "skip-deps",
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
}, },
Action: action(func(a *app.App, c configImpl) error { Action: action(func(a *app.App, c configImpl) error {
return a.Destroy(c) return a.Destroy(c)
@ -605,6 +613,10 @@ func main() {
Value: 0, Value: 0,
Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", Usage: "maximum number of concurrent helm processes to run, 0 is unlimited",
}, },
cli.BoolFlag{
Name: "skip-deps",
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
}, },
Action: action(func(a *app.App, c configImpl) error { Action: action(func(a *app.App, c configImpl) error {
return a.Test(c) return a.Test(c)

View File

@ -396,8 +396,8 @@ func (a *App) Status(c StatusesConfigProvider) error {
func (a *App) Delete(c DeleteConfigProvider) error { func (a *App) Delete(c DeleteConfigProvider) error {
return a.ForEachState(func(run *Run) (ok bool, errs []error) { return a.ForEachState(func(run *Run) (ok bool, errs []error) {
err := run.withPreparedCharts("delete", state.ChartPrepareOptions{ err := run.withPreparedCharts("delete", state.ChartPrepareOptions{
SkipRepos: true, SkipRepos: c.SkipDeps(),
SkipDeps: true, SkipDeps: c.SkipDeps(),
}, func() { }, func() {
ok, errs = a.delete(run, c.Purge(), c) ok, errs = a.delete(run, c.Purge(), c)
}) })
@ -413,8 +413,8 @@ func (a *App) Delete(c DeleteConfigProvider) error {
func (a *App) Destroy(c DestroyConfigProvider) error { func (a *App) Destroy(c DestroyConfigProvider) error {
return a.ForEachState(func(run *Run) (ok bool, errs []error) { return a.ForEachState(func(run *Run) (ok bool, errs []error) {
err := run.withPreparedCharts("destroy", state.ChartPrepareOptions{ err := run.withPreparedCharts("destroy", state.ChartPrepareOptions{
SkipRepos: true, SkipRepos: c.SkipDeps(),
SkipDeps: true, SkipDeps: c.SkipDeps(),
}, func() { }, func() {
ok, errs = a.delete(run, true, c) ok, errs = a.delete(run, true, c)
}) })
@ -436,8 +436,8 @@ func (a *App) Test(c TestConfigProvider) error {
} }
err := run.withPreparedCharts("test", state.ChartPrepareOptions{ err := run.withPreparedCharts("test", state.ChartPrepareOptions{
SkipRepos: true, SkipRepos: c.SkipDeps(),
SkipDeps: true, SkipDeps: c.SkipDeps(),
}, func() { }, func() {
errs = a.test(run, c) errs = a.test(run, c)
}) })

View File

@ -114,6 +114,7 @@ type DeleteConfigProvider interface {
Args() string Args() string
Purge() bool Purge() bool
SkipDeps() bool
interactive interactive
loggingConfig loggingConfig
@ -123,6 +124,8 @@ type DeleteConfigProvider interface {
type DestroyConfigProvider interface { type DestroyConfigProvider interface {
Args() string Args() string
SkipDeps() bool
interactive interactive
loggingConfig loggingConfig
concurrencyConfig concurrencyConfig
@ -131,6 +134,7 @@ type DestroyConfigProvider interface {
type TestConfigProvider interface { type TestConfigProvider interface {
Args() string Args() string
SkipDeps() bool
Timeout() int Timeout() int
Cleanup() bool Cleanup() bool
Logs() bool Logs() bool

View File

@ -26,6 +26,7 @@ type destroyConfig struct {
args string args string
concurrency int concurrency int
interactive bool interactive bool
skipDeps bool
logger *zap.SugaredLogger logger *zap.SugaredLogger
} }
@ -45,6 +46,10 @@ func (d destroyConfig) Concurrency() int {
return d.concurrency return d.concurrency
} }
func (d destroyConfig) SkipDeps() bool {
return d.skipDeps
}
func TestDestroy(t *testing.T) { func TestDestroy(t *testing.T) {
type testcase struct { type testcase struct {
helm3 bool helm3 bool