This commit is contained in:
Shane Starcher 2025-10-27 07:04:23 -05:00 committed by GitHub
commit b008221434
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 18 deletions

View File

@ -32,6 +32,7 @@ func NewBuildCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f := cmd.Flags()
f.BoolVar(&buildOptions.EmbedValues, "embed-values", false, "Read all the values files for every release and embed into the output helmfile.yaml")
f.BoolVar(&buildOptions.SkipCharts, "skip-charts", false, "don't prepare charts when building releases")
return cmd
}

View File

@ -521,11 +521,7 @@ func (a *App) PrintDAGState(c DAGConfigProvider) error {
func (a *App) PrintState(c StateConfigProvider) error {
return a.ForEachState(func(run *Run) (_ bool, errs []error) {
err := run.withPreparedCharts("build", state.ChartPrepareOptions{
SkipRepos: true,
SkipDeps: true,
Concurrency: 2,
}, func() {
printState := func() {
if c.EmbedValues() {
for i := range run.state.Releases {
r := run.state.Releases[i]
@ -562,13 +558,22 @@ func (a *App) PrintState(c StateConfigProvider) error {
fmt.Printf("---\n# Source: %s\n\n%+v", sourceFile, stateYaml)
errs = []error{}
})
}
if !c.SkipCharts() {
err := run.withPreparedCharts("build", state.ChartPrepareOptions{
SkipRepos: true,
SkipDeps: true,
Concurrency: 2,
}, printState)
if err != nil {
errs = append(errs, err)
}
} else {
printState()
}
return
return false, errs
}, false, SetFilter(true))
}
@ -592,20 +597,22 @@ func (a *App) ListReleases(c ListConfigProvider) error {
var stateReleases []*HelmRelease
var err error
if !c.SkipCharts() {
err = run.withPreparedCharts("list", state.ChartPrepareOptions{
SkipRepos: true,
SkipDeps: true,
Concurrency: 2,
}, func() {
listReleases := func() {
rel, err := a.list(run)
if err != nil {
panic(err)
}
stateReleases = rel
})
}
if !c.SkipCharts() {
err = run.withPreparedCharts("list", state.ChartPrepareOptions{
SkipRepos: true,
SkipDeps: true,
Concurrency: 2,
}, listReleases)
} else {
stateReleases, err = a.list(run)
listReleases()
}
if err != nil {

View File

@ -264,6 +264,7 @@ type StatusesConfigProvider interface {
type StateConfigProvider interface {
EmbedValues() bool
SkipCharts() bool
}
type DAGConfigProvider any

View File

@ -4,6 +4,8 @@ package config
type BuildOptions struct {
// EmbedValues is true if the values should be embedded
EmbedValues bool
// SkipCharts makes Build skip `withPreparedCharts`
SkipCharts bool
}
// NewBuildOptions creates a new Apply
@ -29,3 +31,8 @@ func NewBuildImpl(g *GlobalImpl, b *BuildOptions) *BuildImpl {
func (b *BuildImpl) EmbedValues() bool {
return b.BuildOptions.EmbedValues
}
// SkipCharts returns skipCharts flag
func (b *BuildImpl) SkipCharts() bool {
return b.BuildOptions.SkipCharts
}