Integrate include-crd flag for diff and depending commands
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
59dd75a019
commit
1c59d0a539
|
|
@ -1618,6 +1618,8 @@ func (a *App) diff(r *Run, c DiffConfigProvider) (*string, bool, bool, []error)
|
||||||
Output: c.DiffOutput(),
|
Output: c.DiffOutput(),
|
||||||
Color: c.Color(),
|
Color: c.Color(),
|
||||||
NoColor: c.NoColor(),
|
NoColor: c.NoColor(),
|
||||||
|
SkipCRDs: c.SkipCRDs(),
|
||||||
|
IncludeCRDs: c.ShouldIncludeCRDs(),
|
||||||
Set: c.Set(),
|
Set: c.Set(),
|
||||||
DiffArgs: c.DiffArgs(),
|
DiffArgs: c.DiffArgs(),
|
||||||
SkipDiffOnInstall: c.SkipDiffOnInstall(),
|
SkipDiffOnInstall: c.SkipDiffOnInstall(),
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,26 @@
|
||||||
package app
|
package app
|
||||||
|
|
||||||
const (
|
import "github.com/helmfile/helmfile/pkg/version"
|
||||||
HelmRequiredVersion = "v3.16.4"
|
|
||||||
HelmRecommendedVersion = "v3.17.3"
|
|
||||||
HelmDiffRecommendedVersion = "v3.11.0"
|
|
||||||
HelmSecretsRecommendedVersion = "v4.6.3"
|
|
||||||
HelmGitRecommendedVersion = "v1.3.0"
|
|
||||||
HelmS3RecommendedVersion = "v0.16.3"
|
|
||||||
HelmInstallCommand = "https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3"
|
|
||||||
)
|
|
||||||
|
|
||||||
var helmPlugins = []helmRecommendedPlugin{
|
var helmPlugins = []helmRecommendedPlugin{
|
||||||
{
|
{
|
||||||
name: "diff",
|
name: "diff",
|
||||||
version: HelmDiffRecommendedVersion,
|
version: version.HelmDiffRecommendedVersion,
|
||||||
repo: "https://github.com/databus23/helm-diff",
|
repo: "https://github.com/databus23/helm-diff",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secrets",
|
name: "secrets",
|
||||||
version: HelmSecretsRecommendedVersion,
|
version: version.HelmSecretsRecommendedVersion,
|
||||||
repo: "https://github.com/jkroepke/helm-secrets",
|
repo: "https://github.com/jkroepke/helm-secrets",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "s3",
|
name: "s3",
|
||||||
version: HelmS3RecommendedVersion,
|
version: version.HelmS3RecommendedVersion,
|
||||||
repo: "https://github.com/hypnoglow/helm-s3.git",
|
repo: "https://github.com/hypnoglow/helm-s3.git",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "helm-git",
|
name: "helm-git",
|
||||||
version: HelmGitRecommendedVersion,
|
version: version.HelmGitRecommendedVersion,
|
||||||
repo: "https://github.com/aslafy-z/helm-git.git",
|
repo: "https://github.com/aslafy-z/helm-git.git",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,31 @@ func (st *HelmState) appendShowOnlyFlags(flags []string, showOnly []string) []st
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appendCRDFlags appends the appropriate CRD-related flag to the command line flags
|
||||||
|
// based on the provided boolean parameters.
|
||||||
|
//
|
||||||
|
// If skipCRDs is true, it appends "--skip-crds" to the flags.
|
||||||
|
// Otherwise, if includeCRDs is true, it appends "--include-crds" to the flags.
|
||||||
|
// If neither condition is met, it returns the flags unchanged.
|
||||||
|
//
|
||||||
|
// This function ensures that skipCRDs takes precedence over includeCRDs when both are true.
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// - flags: The existing slice of command line flags
|
||||||
|
// - skipCRDs: Whether to skip CRDs installation/processing
|
||||||
|
// - includeCRDs: Whether to include CRDs installation/processing
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// - The updated slice of command line flags
|
||||||
|
func (st *HelmState) appendCRDFlags(flags []string, skipCRDs, includeCRDs bool) []string {
|
||||||
|
if skipCRDs {
|
||||||
|
return append(flags, "--skip-crds")
|
||||||
|
} else if includeCRDs {
|
||||||
|
return append(flags, "--include-crds")
|
||||||
|
}
|
||||||
|
return flags
|
||||||
|
}
|
||||||
|
|
||||||
type Chartify struct {
|
type Chartify struct {
|
||||||
Opts *chartify.ChartifyOpts
|
Opts *chartify.ChartifyOpts
|
||||||
Clean func()
|
Clean func()
|
||||||
|
|
|
||||||
|
|
@ -702,9 +702,7 @@ func (st *HelmState) prepareSyncReleases(helm helmexec.Interface, additionalValu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.SkipCRDs {
|
flags = st.appendCRDFlags(flags, opts.SkipCRDs, opts.IncludeCRDs)
|
||||||
flags = append(flags, "--skip-crds")
|
|
||||||
}
|
|
||||||
|
|
||||||
flags = st.appendValuesControlModeFlag(flags, opts.ReuseValues, opts.ResetValues)
|
flags = st.appendValuesControlModeFlag(flags, opts.ReuseValues, opts.ResetValues)
|
||||||
|
|
||||||
|
|
@ -794,6 +792,7 @@ type SyncOpts struct {
|
||||||
Set []string
|
Set []string
|
||||||
SkipCleanup bool
|
SkipCleanup bool
|
||||||
SkipCRDs bool
|
SkipCRDs bool
|
||||||
|
IncludeCRDs bool
|
||||||
Wait bool
|
Wait bool
|
||||||
WaitRetries int
|
WaitRetries int
|
||||||
WaitForJobs bool
|
WaitForJobs bool
|
||||||
|
|
@ -1497,6 +1496,7 @@ type TemplateOpts struct {
|
||||||
Set []string
|
Set []string
|
||||||
SkipCleanup bool
|
SkipCleanup bool
|
||||||
OutputDirTemplate string
|
OutputDirTemplate string
|
||||||
|
SkipCRDs bool
|
||||||
IncludeCRDs bool
|
IncludeCRDs bool
|
||||||
NoHooks bool
|
NoHooks bool
|
||||||
SkipTests bool
|
SkipTests bool
|
||||||
|
|
@ -1579,9 +1579,7 @@ func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string,
|
||||||
flags = append(flags, "--validate")
|
flags = append(flags, "--validate")
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.IncludeCRDs {
|
flags = st.appendCRDFlags(flags, opts.SkipCRDs, opts.IncludeCRDs)
|
||||||
flags = append(flags, "--include-crds")
|
|
||||||
}
|
|
||||||
|
|
||||||
if opts.NoHooks {
|
if opts.NoHooks {
|
||||||
flags = append(flags, "--no-hooks")
|
flags = append(flags, "--no-hooks")
|
||||||
|
|
@ -1854,10 +1852,7 @@ func (st *HelmState) commonDiffFlags(detailedExitCode bool, stripTrailingCR bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// internally we only care about include-crds since skip-crds is misleading and used only in command interface
|
flags = st.appendCRDFlags(flags, opt.SkipCRDs, opt.IncludeCRDs)
|
||||||
if opt.IncludeCRDs {
|
|
||||||
flags = append(flags, "--include-crds")
|
|
||||||
}
|
|
||||||
|
|
||||||
flags = st.appendExtraDiffFlags(flags, opt)
|
flags = st.appendExtraDiffFlags(flags, opt)
|
||||||
|
|
||||||
|
|
@ -2036,6 +2031,7 @@ type DiffOpts struct {
|
||||||
// If this is true, Color has no effect.
|
// If this is true, Color has no effect.
|
||||||
NoColor bool
|
NoColor bool
|
||||||
Set []string
|
Set []string
|
||||||
|
SkipCRDs bool
|
||||||
IncludeCRDs bool
|
IncludeCRDs bool
|
||||||
SkipCleanup bool
|
SkipCleanup bool
|
||||||
SkipDiffOnInstall bool
|
SkipDiffOnInstall bool
|
||||||
|
|
@ -2752,6 +2748,17 @@ func (st *HelmState) timeoutFlags(release *ReleaseSpec) []string {
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flagsForUpgrade returns the flags for the helm upgrade command for the given release.
|
||||||
|
// It considers both global options and release-specific settings to determine the appropriate flags.
|
||||||
|
// The returned flags include settings for CRDs, values, wait conditions, hooks, timeouts, and other upgrade-specific options.
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// - release: The release specification containing release-specific settings
|
||||||
|
// - workerIndex: The index of the worker processing this release (for concurrent operations)
|
||||||
|
// - opt: Options containing global settings for the upgrade operation
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// - A string slice containing all flags to be passed to the helm upgrade command
|
||||||
func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSpec, workerIndex int, opt *SyncOpts) ([]string, []string, error) {
|
func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSpec, workerIndex int, opt *SyncOpts) ([]string, []string, error) {
|
||||||
var flags []string
|
var flags []string
|
||||||
flags = st.appendChartVersionFlags(flags, release)
|
flags = st.appendChartVersionFlags(flags, release)
|
||||||
|
|
@ -2845,6 +2852,17 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp
|
||||||
return append(flags, common...), clean, nil
|
return append(flags, common...), clean, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flagsForTemplate returns the flags for the helm template command for the given release.
|
||||||
|
// It considers both global options and release-specific settings to determine the appropriate flags.
|
||||||
|
// The returned flags include settings for CRDs, values, validation, output formatting, and other template-specific options.
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// - release: The release specification containing release-specific settings
|
||||||
|
// - workerIndex: The index of the worker processing this release (for concurrent operations)
|
||||||
|
// - opt: Options containing global settings for the template operation
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// - A string slice containing all flags to be passed to the helm template command
|
||||||
func (st *HelmState) flagsForTemplate(helm helmexec.Interface, release *ReleaseSpec, workerIndex int, opt *TemplateOpts) ([]string, []string, error) {
|
func (st *HelmState) flagsForTemplate(helm helmexec.Interface, release *ReleaseSpec, workerIndex int, opt *TemplateOpts) ([]string, []string, error) {
|
||||||
var flags []string
|
var flags []string
|
||||||
flags = st.appendChartVersionFlags(flags, release)
|
flags = st.appendChartVersionFlags(flags, release)
|
||||||
|
|
@ -2876,6 +2894,17 @@ func (st *HelmState) flagsForTemplate(helm helmexec.Interface, release *ReleaseS
|
||||||
return append(flags, common...), files, nil
|
return append(flags, common...), files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flagsForDiff returns the flags for the helm diff command for the given release
|
||||||
|
// It considers both global options and release-specific settings to determine the appropriate flags.
|
||||||
|
// The returned flags include settings for CRDs, values, validation, hooks, and other diff-specific options.
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// - release: The release specification containing release-specific settings
|
||||||
|
// - workerIndex: The index of the worker processing this release (for concurrent operations)
|
||||||
|
// - opt: Options containing global settings for the diff operation
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// - A string slice containing all flags to be passed to the helm diff command
|
||||||
func (st *HelmState) flagsForDiff(helm helmexec.Interface, release *ReleaseSpec, disableValidation bool, workerIndex int, opt *DiffOpts) ([]string, []string, error) {
|
func (st *HelmState) flagsForDiff(helm helmexec.Interface, release *ReleaseSpec, disableValidation bool, workerIndex int, opt *DiffOpts) ([]string, []string, error) {
|
||||||
settings := cli.New()
|
settings := cli.New()
|
||||||
var flags []string
|
var flags []string
|
||||||
|
|
@ -3077,6 +3106,17 @@ func (st *HelmState) isDevelopment(release *ReleaseSpec) bool {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flagsForLint returns the flags for the helm lint command for the given release.
|
||||||
|
// It considers both global options and release-specific settings to determine the appropriate flags.
|
||||||
|
// The returned flags include settings for values files, set values, and other lint-specific options.
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// - release: The release specification containing release-specific settings
|
||||||
|
// - workerIndex: The index of the worker processing this release (for concurrent operations)
|
||||||
|
// - opt: Options containing global settings for the lint operation
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// - A string slice containing all flags to be passed to the helm lint command
|
||||||
func (st *HelmState) flagsForLint(helm helmexec.Interface, release *ReleaseSpec, workerIndex int) ([]string, []string, error) {
|
func (st *HelmState) flagsForLint(helm helmexec.Interface, release *ReleaseSpec, workerIndex int) ([]string, []string, error) {
|
||||||
flags, files, err := st.namespaceAndValuesFlags(helm, release, workerIndex)
|
flags, files, err := st.namespaceAndValuesFlags(helm, release, workerIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue