Use cobra (#234)

switch to cobra

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2022-07-19 21:06:18 +09:00
committed by GitHub
parent 35453566df
commit 85ade797ab
44 changed files with 2144 additions and 831 deletions
+2 -2
View File
@@ -2059,7 +2059,7 @@ func (c context) wrapErrs(errs ...error) error {
return nil
}
func (a *App) ShowCacheDir(c ListConfigProvider) error {
func (a *App) ShowCacheDir(c CacheConfigProvider) error {
fmt.Printf("Cache directory: %s\n", remote.CacheDir())
if !directoryExistsAt(remote.CacheDir()) {
@@ -2076,7 +2076,7 @@ func (a *App) ShowCacheDir(c ListConfigProvider) error {
return nil
}
func (a *App) CleanCacheDir(c ListConfigProvider) error {
func (a *App) CleanCacheDir(c CacheConfigProvider) error {
if !directoryExistsAt(remote.CacheDir()) {
return nil
}
+2
View File
@@ -232,3 +232,5 @@ type interactive interface {
type ListConfigProvider interface {
Output() string
}
type CacheConfigProvider interface{}
+197
View File
@@ -0,0 +1,197 @@
package config
import "fmt"
// ApplyOptoons is the options for the apply command
type ApplyOptions struct {
// Set is a list of key value pairs to be merged into the command
Set []string
// Values is a list of value files to be merged into the command
Values []string
// Concurrency is the maximum number of concurrent helm processes to run
Concurrency int
// Validate is validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requires access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions
Validate bool
// Context is the number of lines of context to show around changes
Context int
// Output is the output format for the diff plugin
Output string
// DetailedExitcode is true if the exit code should be 2 instead of 0 if there were changes detected and the changes were synced successfully
DetailedExitcode bool
// Args is the arguments to pass to helm exec
Args string
// DEPRECATED: Use skip-cleanup instead
RetainValuesFiles bool
// SkipCleanup is true if the cleanup of temporary values files should be skipped
SkipCleanup bool
// SkipCRDs is true if the CRDs should be skipped
SkipCRDs bool
// SkipNeeds is true if the needs should be skipped
SkipNeeds bool
// IncludeNeeds is true if the needs should be included
IncludeNeeds bool
// IncludeTransitiveNeeds is true if the transitive needs should be included
IncludeTransitiveNeeds bool
// SkipDiffOnInstall is true if the diff should be skipped on install
SkipDiffOnInstall bool
// IncludeTests is true if the tests should be included
IncludeTests bool
// Suppress is true if the output should be suppressed
Suppress []string
// SuppressSecrets is true if the secrets should be suppressed
SuppressSecrets bool
// SuppressDiff is true if the diff should be suppressed
ShowSecrets bool
// SkipDeps is true if the running "helm repo update" and "helm dependency build" should be skipped
SuppressDiff bool
// ShowSecrets is true if the secrets should be shown
SkipDeps bool
// Wait is true if the helm command should wait for the release to be deployed
Wait bool
// WaitForJobs is true if the helm command should wait for the jobs to be completed
WaitForJobs bool
}
// NewApply creates a new Apply
func NewApplyOptions() *ApplyOptions {
return &ApplyOptions{}
}
// ApplyImpl is impl for applyOptions
type ApplyImpl struct {
*GlobalImpl
*ApplyOptions
}
// NewApplyImpl creates a new ApplyImpl
func NewApplyImpl(g *GlobalImpl, a *ApplyOptions) *ApplyImpl {
return &ApplyImpl{
GlobalImpl: g,
ApplyOptions: a,
}
}
// Set returns the set.
func (a *ApplyImpl) Set() []string {
return a.ApplyOptions.Set
}
// Args returns the args.
func (a *ApplyImpl) Args() string {
args := a.ApplyOptions.Args
enableHelmDebug := a.GlobalImpl.Debug
if enableHelmDebug {
args = fmt.Sprintf("%s %s", args, "--debug")
}
return args
}
// Concurrency returns the concurrency.
func (a *ApplyImpl) Concurrency() int {
return a.ApplyOptions.Concurrency
}
// Context returns the context.
func (a *ApplyImpl) Context() int {
return a.ApplyOptions.Context
}
// DetailedExitcode returns the detailed exitcode.
func (a *ApplyImpl) DetailedExitcode() bool {
return a.ApplyOptions.DetailedExitcode
}
// DiffOutput returns the diff output.
func (a *ApplyImpl) DiffOutput() string {
return a.ApplyOptions.Output
}
// IncludeNeeds returns the include needs.
func (a *ApplyImpl) IncludeNeeds() bool {
return a.ApplyOptions.IncludeNeeds || a.ApplyOptions.IncludeTransitiveNeeds
}
// IncludeTests returns the include tests.
func (a *ApplyImpl) IncludeTests() bool {
return a.ApplyOptions.IncludeTests
}
// IncludeTransitiveNeeds returns the include transitive needs.
func (a *ApplyImpl) IncludeTransitiveNeeds() bool {
return a.ApplyOptions.IncludeTransitiveNeeds
}
// RetainValuesFiles returns the retain values files.
func (a *ApplyImpl) RetainValuesFiles() bool {
return a.ApplyOptions.RetainValuesFiles
}
// ShowSecrets returns the show secrets.
func (a *ApplyImpl) ShowSecrets() bool {
return a.ApplyOptions.ShowSecrets
}
// SkipCRDs returns the skip crds.
func (a *ApplyImpl) SkipCRDs() bool {
return a.ApplyOptions.SkipCRDs
}
// SkipCleanup returns the skip cleanup.
func (a *ApplyImpl) SkipCleanup() bool {
return a.ApplyOptions.SkipCleanup
}
// SkipDeps returns the skip deps.
func (a *ApplyImpl) SkipDeps() bool {
return a.ApplyOptions.SkipDeps
}
// SkipDiffOnInstall returns the skip diff on install.
func (a *ApplyImpl) SkipDiffOnInstall() bool {
return a.ApplyOptions.SkipDiffOnInstall
}
// SkipNeeds returns the skip needs.
func (a *ApplyImpl) SkipNeeds() bool {
if !a.ApplyOptions.IncludeNeeds {
return a.ApplyOptions.SkipNeeds
}
return false
}
// Suppress returns the suppress.
func (a *ApplyImpl) Suppress() []string {
return a.ApplyOptions.Suppress
}
// SuppressDiff returns the suppress diff.
func (a *ApplyImpl) SuppressDiff() bool {
return a.ApplyOptions.SuppressDiff
}
// SuppressSecrets returns the suppress secrets.
func (a *ApplyImpl) SuppressSecrets() bool {
return a.ApplyOptions.SuppressSecrets
}
// Validate returns the validate.
func (a *ApplyImpl) Validate() bool {
return a.ApplyOptions.Validate
}
// Values returns the values.
func (a *ApplyImpl) Values() []string {
return a.ApplyOptions.Values
}
// Wait returns the wait.
func (a *ApplyImpl) Wait() bool {
return a.ApplyOptions.Wait
}
// WaitForJobs returns the wait for jobs.
func (a *ApplyImpl) WaitForJobs() bool {
return a.ApplyOptions.WaitForJobs
}
+36
View File
@@ -0,0 +1,36 @@
package config
// BuildOptions is the options for the build command
type BuildOptions struct {
// EmbedValues is true if the values should be embedded
EmbedValues bool
}
// NewBuildOptions creates a new Apply
func NewBuildOptions() *BuildOptions {
return &BuildOptions{}
}
// BuildImpl is impl for applyOptions
type BuildImpl struct {
*GlobalImpl
*BuildOptions
}
// NewBuildImpl creates a new BuildImpl
func NewBuildImpl(g *GlobalImpl, b *BuildOptions) *BuildImpl {
return &BuildImpl{
GlobalImpl: g,
BuildOptions: b,
}
}
// Args returns the args.
func (b *BuildImpl) Args() string {
return ""
}
// EmbedValues returns the embed values.
func (b *BuildImpl) EmbedValues() bool {
return b.BuildOptions.EmbedValues
}
+28
View File
@@ -0,0 +1,28 @@
package config
// CacheOptions is the options for the build command
type CacheOptions struct{}
// NewCacheOptions creates a new Apply
func NewCacheOptions() *CacheOptions {
return &CacheOptions{}
}
// CacheImpl is impl for applyOptions
type CacheImpl struct {
*GlobalImpl
*CacheOptions
}
// NewCacheImpl creates a new CacheImpl
func NewCacheImpl(g *GlobalImpl, b *CacheOptions) *CacheImpl {
return &CacheImpl{
GlobalImpl: g,
CacheOptions: b,
}
}
// Args returns the args.
func (b *CacheImpl) Args() string {
return ""
}
+52
View File
@@ -0,0 +1,52 @@
package config
// ChartsOptions is the options for the build command
type ChartsOptions struct {
// Args is the args to pass to helm exec
Args string
// Set is the additional values to be merged into the command
Set []string
// Values is the additional value files to be merged into the command
Values []string
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
}
// NewChartsOptions creates a new Apply
func NewChartsOptions() *ChartsOptions {
return &ChartsOptions{}
}
// ChartsImpl is impl for applyOptions
type ChartsImpl struct {
*GlobalImpl
*ChartsOptions
}
// NewChartsImpl creates a new ChartsImpl
func NewChartsImpl(g *GlobalImpl, b *ChartsOptions) *ChartsImpl {
return &ChartsImpl{
GlobalImpl: g,
ChartsOptions: b,
}
}
// Concurrency returns the concurrency
func (c *ChartsImpl) Concurrency() int {
return c.ChartsOptions.Concurrency
}
// Args returns the args
func (c *ChartsImpl) Args() string {
return c.ChartsOptions.Args
}
// IncludeTransitiveNeeds returns the includeTransitiveNeeds
func (c *ChartsImpl) IncludeTransitiveNeeds() bool {
return false
}
// Values returns the values
func (c *ChartsImpl) Values() []string {
return c.ChartsOptions.Values
}
+20
View File
@@ -51,6 +51,26 @@ func NewUrfaveCliConfigImpl(c *cli.Context) (ConfigImpl, error) {
return conf, nil
}
func NewUrfaveCliConfigImplIns(g *GlobalImpl) error {
optsSet := g.RawStateValuesSet()
if len(optsSet) > 0 {
set := map[string]interface{}{}
for i := range optsSet {
ops := strings.Split(optsSet[i], ",")
for j := range ops {
op := strings.SplitN(ops[j], "=", 2)
k := maputil.ParseKey(op[0])
v := op[1]
maputil.Set(set, k, v)
}
}
g.SetSet(set)
}
return nil
}
func (c ConfigImpl) Set() []string {
return c.c.StringSlice("set")
}
+52
View File
@@ -0,0 +1,52 @@
package config
// DeleteOptions is the options for the build command
type DeleteOptions struct {
// Args is the args to pass to helm exec
Args string
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
// Purge is the purge flag
Purge bool
// SkipDeps is the skip deps flag
SkipDeps bool
}
// NewDeleteOptions creates a new Apply
func NewDeleteOptions() *DeleteOptions {
return &DeleteOptions{}
}
// DeleteImpl is impl for applyOptions
type DeleteImpl struct {
*GlobalImpl
*DeleteOptions
}
// NewDeleteImpl creates a new DeleteImpl
func NewDeleteImpl(g *GlobalImpl, b *DeleteOptions) *DeleteImpl {
return &DeleteImpl{
GlobalImpl: g,
DeleteOptions: b,
}
}
// Concurrency returns the concurrency
func (c *DeleteImpl) Concurrency() int {
return c.DeleteOptions.Concurrency
}
// Args returns the args
func (c *DeleteImpl) Args() string {
return c.DeleteOptions.Args
}
// Purge returns the purge
func (c *DeleteImpl) Purge() bool {
return c.DeleteOptions.Purge
}
// SkipDeps returns the skip deps
func (c *DeleteImpl) SkipDeps() bool {
return c.DeleteOptions.SkipDeps
}
+43
View File
@@ -0,0 +1,43 @@
package config
// DepsOptions is the options for the build command
type DepsOptions struct {
// Args is the args to pass to helm exec
Args string
// SkipRepos is the skip repos flag
SkipRepos bool
}
// NewDepsOptions creates a new Apply
func NewDepsOptions() *DepsOptions {
return &DepsOptions{}
}
// DepsImpl is impl for applyOptions
type DepsImpl struct {
*GlobalImpl
*DepsOptions
}
// NewDepsImpl creates a new DepsImpl
func NewDepsImpl(g *GlobalImpl, b *DepsOptions) *DepsImpl {
return &DepsImpl{
GlobalImpl: g,
DepsOptions: b,
}
}
// Args returns the args
func (d *DepsImpl) Args() string {
return d.DepsOptions.Args
}
// SkipDeps returns the skip deps
func (d *DepsImpl) SkipRepos() bool {
return d.DepsOptions.SkipRepos
}
// IncludeTransitiveNeeds returns the includeTransitiveNeeds
func (d *DepsImpl) IncludeTransitiveNeeds() bool {
return false
}
+45
View File
@@ -0,0 +1,45 @@
package config
// DestroyOptions is the options for the build command
type DestroyOptions struct {
// Args is the args to pass to helm exec
Args string
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
}
// NewDestroyOptions creates a new Apply
func NewDestroyOptions() *DestroyOptions {
return &DestroyOptions{}
}
// DestroyImpl is impl for applyOptions
type DestroyImpl struct {
*GlobalImpl
*DestroyOptions
}
// NewDestroyImpl creates a new DestroyImpl
func NewDestroyImpl(g *GlobalImpl, b *DestroyOptions) *DestroyImpl {
return &DestroyImpl{
GlobalImpl: g,
DestroyOptions: b,
}
}
// Concurrency returns the concurrency
func (c *DestroyImpl) Concurrency() int {
return c.DestroyOptions.Concurrency
}
// Args returns the args
func (c *DestroyImpl) Args() string {
return c.DestroyOptions.Args
}
// SkipDeps returns the skip deps
func (c *DestroyImpl) SkipDeps() bool {
return c.DestroyOptions.SkipDeps
}
+157
View File
@@ -0,0 +1,157 @@
package config
// DiffOptions is the options for the build command
type DiffOptions struct {
// Args is the args to pass to helm template
Args string
// Set is the set flag
Set []string
// Values is the values flag
Values []string
// SkipDeps is the skip deps flag
SkipDeps bool
// DetailedExitcode is the detailed exit code
DetailedExitcode bool
// IncludeTests is the include tests flag
IncludeTests bool
// SkipNeeds is the include crds flag
SkipNeeds bool
// IncludeNeeds is the include needs flag
IncludeNeeds bool
// IncludeTransitiveNeeds is the include transitive needs flag
IncludeTransitiveNeeds bool
// SkipDiffOnInstall is the skip diff on install flag
SkipDiffOnInstall bool
// ShowSecrets is the show secrets flag
ShowSecrets bool
// Suppress is the suppress flag
Suppress []string
// SuppressSecrets is the suppress secrets flag
SuppressSecrets bool
// Concurrency is the concurrency flag
Concurrency int
// Validate is the validate flag
Validate bool
// Context is the context flag
Context int
// Output is output flag
Output string
}
// NewDiffOptions creates a new Apply
func NewDiffOptions() *DiffOptions {
return &DiffOptions{}
}
// DiffImpl is impl for applyOptions
type DiffImpl struct {
*GlobalImpl
*DiffOptions
}
// NewDiffImpl creates a new DiffImpl
func NewDiffImpl(g *GlobalImpl, t *DiffOptions) *DiffImpl {
return &DiffImpl{
GlobalImpl: g,
DiffOptions: t,
}
}
// Args returns the args
func (t *DiffImpl) Args() string {
return t.DiffOptions.Args
}
// Concurrency returns the concurrency
func (t *DiffImpl) Concurrency() int {
return t.DiffOptions.Concurrency
}
// IncludeNeeds returns the include needs
func (t *DiffImpl) IncludeNeeds() bool {
return t.DiffOptions.IncludeNeeds || t.DiffOptions.IncludeTransitiveNeeds
}
// IncludeTransitiveNeeds returns the include transitive needs
func (t *DiffImpl) IncludeTransitiveNeeds() bool {
return t.DiffOptions.IncludeTransitiveNeeds
}
// Set returns the Set
func (t *DiffImpl) Set() []string {
return t.DiffOptions.Set
}
// SkipDeps returns the skip deps
func (t *DiffImpl) SkipDeps() bool {
return t.DiffOptions.SkipDeps
}
// SkipNeeds returns the skip needs
func (t *DiffImpl) SkipNeeds() bool {
if !t.DiffOptions.IncludeNeeds {
return t.DiffOptions.SkipNeeds
}
return false
}
// Validate returns the validate
func (t *DiffImpl) Validate() bool {
return t.DiffOptions.Validate
}
// Values returns the values
func (t *DiffImpl) Values() []string {
return t.DiffOptions.Values
}
// Context returns the context
func (t *DiffImpl) Context() int {
return 0
}
// DetailedExitCode returns the detailed exit code
func (t *DiffImpl) DetailedExitcode() bool {
return t.DiffOptions.DetailedExitcode
}
// Output returns the output
func (t *DiffImpl) DiffOutput() string {
return ""
}
// IncludeTests returns the include tests
func (t *DiffImpl) IncludeTests() bool {
return t.DiffOptions.IncludeTests
}
// ShowSecrets returns the show secrets
func (t *DiffImpl) ShowSecrets() bool {
return t.DiffOptions.ShowSecrets
}
// ShowCRDs returns the show crds
func (t *DiffImpl) SkipCRDs() bool {
return false
}
// SkipDiffOnInstall returns the skip diff on install
func (t *DiffImpl) SkipDiffOnInstall() bool {
return t.DiffOptions.SkipDiffOnInstall
}
// Suppress returns the suppress
func (t *DiffImpl) Suppress() []string {
return t.DiffOptions.Suppress
}
// SuppressDiff returns the suppress diff
func (t *DiffImpl) SuppressDiff() bool {
return false
}
// SuppressSecrets returns the suppress secrets
func (t *DiffImpl) SuppressSecrets() bool {
return t.DiffOptions.SuppressSecrets
}
+50
View File
@@ -0,0 +1,50 @@
package config
// FetchOptions is the options for the build command
type FetchOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// OutputDir is the output directory
OutputDir string
}
// NewFetchOptions creates a new Apply
func NewFetchOptions() *FetchOptions {
return &FetchOptions{}
}
// FetchImpl is impl for applyOptions
type FetchImpl struct {
*GlobalImpl
*FetchOptions
}
// NewFetchImpl creates a new FetchImpl
func NewFetchImpl(g *GlobalImpl, b *FetchOptions) *FetchImpl {
return &FetchImpl{
GlobalImpl: g,
FetchOptions: b,
}
}
// Concurrency returns the concurrency
func (c *FetchImpl) Concurrency() int {
return c.FetchOptions.Concurrency
}
// SkipDeps returns the skip deps
func (c *FetchImpl) SkipDeps() bool {
return c.FetchOptions.SkipDeps
}
// Args returns the args
func (c *FetchImpl) Args() string {
return ""
}
// OutputDir returns the args
func (c *FetchImpl) OutputDir() string {
return c.FetchOptions.OutputDir
}
+180
View File
@@ -0,0 +1,180 @@
package config
import (
"errors"
"os"
"github.com/helmfile/helmfile/pkg/state"
"go.uber.org/zap"
"golang.org/x/term"
)
// GlobalOptions is the global configuration for the Helmfile CLI.
type GlobalOptions struct {
// helmBinary is the path to the Helm binary.
HelmBinary string
// File is the path to the Helmfile.
File string
// Environment is the name of the environment to use.
Environment string
// StateValuesSet is a list of state values to set on the command line.
StateValuesSet []string
// StateValuesFiles is a list of state values files to use.
StateValuesFile []string
// Quiet is true if the output should be quiet.
Quiet bool
// KubeContext is the name of the kubectl context to use.
KubeContext string
// Debug is true if the output should be verbose.
Debug bool
// Color is true if the output should be colorized.
Color bool
// NoColor is true if the output should not be colorized.
NoColor bool
// LogLevel is the log level to use.
LogLevel string
// Namespace is the namespace to use.
Namespace string
// Chart is the chart to use.
Chart string
// Selector is a list of selectors to use.
Selector []string
// AllowNoMatchingRelease is not exit with an error code if the provided selector has no matching releases.
AllowNoMatchingRelease bool
// Interactive is true if the user should be prompted for input.
Interactive bool
// logger is the logger to use.
logger *zap.SugaredLogger
}
// Logger returns the logger to use.
func (g *GlobalOptions) Logger() *zap.SugaredLogger {
return g.logger
}
// GetLogLevel returns the log level to use.
func (g *GlobalOptions) SetLogger(logger *zap.SugaredLogger) {
g.logger = logger
}
// GlobalImpl is the global configuration for the Helmfile CLI.
type GlobalImpl struct {
*GlobalOptions
set map[string]interface{}
}
// NewGlobalImpl creates a new GlobalImpl.
func NewGlobalImpl(opts *GlobalOptions) *GlobalImpl {
return &GlobalImpl{
GlobalOptions: opts,
set: make(map[string]interface{}),
}
}
// Setset sets the set
func (g *GlobalImpl) SetSet(set map[string]interface{}) {
g.set = set
}
// HelmBinary returns the path to the Helm binary.
func (g *GlobalImpl) HelmBinary() string {
return g.GlobalOptions.HelmBinary
}
// KubeContext returns the name of the kubectl context to use.
func (g *GlobalImpl) KubeContext() string {
return g.GlobalOptions.KubeContext
}
// Namespace returns the namespace to use.
func (g *GlobalImpl) Namespace() string {
return g.GlobalOptions.Namespace
}
// Chart returns the chart to use.
func (g *GlobalImpl) Chart() string {
return g.GlobalOptions.Chart
}
// FileOrDir returns the path to the Helmfile.
func (g *GlobalImpl) FileOrDir() string {
return g.GlobalOptions.File
}
// Selectors returns the selectors to use.
func (g *GlobalImpl) Selectors() []string {
return g.GlobalOptions.Selector
}
// StateValuesSet returns the set
func (g *GlobalImpl) StateValuesSet() map[string]interface{} {
return g.set
}
// StateValuesSet returns the set
func (g *GlobalImpl) RawStateValuesSet() []string {
return g.GlobalOptions.StateValuesSet
}
// StateValuesFiles returns the state values files
func (g *GlobalImpl) StateValuesFiles() []string {
return g.GlobalOptions.StateValuesFile
}
// Interactive return interactive mode
func (g *GlobalImpl) Interactive() bool {
return g.GlobalOptions.Interactive
}
// Logger returns the logger
func (g *GlobalImpl) Logger() *zap.SugaredLogger {
return g.GlobalOptions.logger
}
func (g *GlobalImpl) Color() bool {
if c := g.GlobalOptions.Color; c {
return c
}
if g.GlobalOptions.NoColor {
return false
}
// We replicate the helm-diff behavior in helmfile
// because when when helmfile calls helm-diff, helm-diff has no access to term and therefore
// we can't rely on helm-diff's ability to auto-detect term for color output.
// See https://github.com/roboll/helmfile/issues/2043
terminal := term.IsTerminal(int(os.Stdout.Fd()))
// https://github.com/databus23/helm-diff/issues/281
dumb := os.Getenv("TERM") == "dumb"
return terminal && !dumb
}
// NoColor returns the no color flag
func (g *GlobalImpl) NoColor() bool {
return g.GlobalOptions.NoColor
}
// Env returns the environment to use.
func (g *GlobalImpl) Env() string {
var env string
switch {
case g.GlobalOptions.Environment != "":
env = g.GlobalOptions.Environment
case os.Getenv("HELMFILE_ENVIRONMENT") != "":
env = os.Getenv("HELMFILE_ENVIRONMENT")
default:
env = state.DefaultEnv
}
return env
}
// ValidateConfig validates the global options.
func (g *GlobalImpl) ValidateConfig() error {
if g.NoColor() && g.Color() {
return errors.New("--color and --no-color cannot be specified at the same time")
}
return nil
}
+79
View File
@@ -0,0 +1,79 @@
package config
// LintOptions is the options for the build command
type LintOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// Args is the args to pass to helm lint
Args string
// Set is the set flags to pass to helm lint
Set []string
// Values is the values flags to pass to helm lint
Values []string
}
// NewLintOptions creates a new Apply
func NewLintOptions() *LintOptions {
return &LintOptions{}
}
// LintImpl is impl for applyOptions
type LintImpl struct {
*GlobalImpl
*LintOptions
}
// NewLintImpl creates a new LintImpl
func NewLintImpl(g *GlobalImpl, b *LintOptions) *LintImpl {
return &LintImpl{
GlobalImpl: g,
LintOptions: b,
}
}
// Concurrency returns the concurrency
func (c *LintImpl) Concurrency() int {
return c.LintOptions.Concurrency
}
// SkipDeps returns the skip deps
func (c *LintImpl) SkipDeps() bool {
return c.LintOptions.SkipDeps
}
// Args returns the args
func (c *LintImpl) Args() string {
return c.LintOptions.Args
}
// Set returns the Set
func (c *LintImpl) Set() []string {
return c.LintOptions.Set
}
// Values returns the Values
func (c *LintImpl) Values() []string {
return c.LintOptions.Values
}
// SkipCleanUp returns the skip clean up
func (c *LintImpl) SkipCleanup() bool {
return false
}
// SkipNeeds returns the skip needs
func (c *LintImpl) SkipNeeds() bool {
return false
}
// IncludeNeeds returns the include needs
func (c *LintImpl) IncludeNeeds() bool {
return false
}
// IncludeTransitiveNeeds returns the include transitive needs
func (c *LintImpl) IncludeTransitiveNeeds() bool {
return false
}
+38
View File
@@ -0,0 +1,38 @@
package config
// ListOptions is the options for the build command
type ListOptions struct {
// Output is the output format
Output string
// KeepTempDir is the keep temp dir flag
KeepTempDir bool
}
// NewListOptions creates a new Apply
func NewListOptions() *ListOptions {
return &ListOptions{}
}
// ListImpl is impl for applyOptions
type ListImpl struct {
*GlobalImpl
*ListOptions
}
// NewListImpl creates a new ListImpl
func NewListImpl(g *GlobalImpl, b *ListOptions) *ListImpl {
return &ListImpl{
GlobalImpl: g,
ListOptions: b,
}
}
// Args returns the args
func (c *ListImpl) Args() string {
return ""
}
// Output returns the output
func (c *ListImpl) Output() string {
return c.ListOptions.Output
}
+36
View File
@@ -0,0 +1,36 @@
package config
// ReposOptions is the options for the build command
type ReposOptions struct {
// Args is the args
Args string
}
// NewReposOptions creates a new Apply
func NewReposOptions() *ReposOptions {
return &ReposOptions{}
}
// ReposImpl is impl for applyOptions
type ReposImpl struct {
*GlobalImpl
*ReposOptions
}
// NewReposImpl creates a new ReposImpl
func NewReposImpl(g *GlobalImpl, b *ReposOptions) *ReposImpl {
return &ReposImpl{
GlobalImpl: g,
ReposOptions: b,
}
}
// Args returns the args
func (r *ReposImpl) Args() string {
return r.ReposOptions.Args
}
// IncludeTransitiveNeeds returns the include transitive needs
func (r *ReposImpl) IncludeTransitiveNeeds() bool {
return false
}
+43
View File
@@ -0,0 +1,43 @@
package config
// StatusOptions is the options for the build command
type StatusOptions struct {
// Args is the args
Args string
// Concurrency is the concurrent flag
Concurrency int
}
// NewStatusOptions creates a new Apply
func NewStatusOptions() *StatusOptions {
return &StatusOptions{}
}
// StatusImpl is impl for applyOptions
type StatusImpl struct {
*GlobalImpl
*StatusOptions
}
// NewStatusImpl creates a new StatusImpl
func NewStatusImpl(g *GlobalImpl, b *StatusOptions) *StatusImpl {
return &StatusImpl{
GlobalImpl: g,
StatusOptions: b,
}
}
// Args returns the args
func (s *StatusImpl) Args() string {
return s.StatusOptions.Args
}
// IncludeTransitiveNeeds returns the include transitive needs
func (s *StatusImpl) IncludeTransitiveNeeds() bool {
return false
}
// Concurrency returns the concurrency
func (s *StatusImpl) Concurrency() int {
return s.StatusOptions.Concurrency
}
+112
View File
@@ -0,0 +1,112 @@
package config
// SyncOptions is the options for the build command
type SyncOptions struct {
// Args is the args to pass to helm template
Args string
// Set is the set flag
Set []string
// Values is the values flag
Values []string
// Concurrency is the concurrency flag
Concurrency int
// Validate is the validate flag
Validate bool
// IncludeCRDs is the include crds flag
SkipNeeds bool
// IncludeNeeds is the include needs flag
IncludeNeeds bool
// IncludeTransitiveNeeds is the include transitive needs flag
IncludeTransitiveNeeds bool
// SkipDeps is the skip deps flag
SkipDeps bool
// SkipCrds is the skip crds flag
SkipCRDs bool
// Wait is the wait flag
Wait bool
// WaitForJobs is the wait for jobs flag
WaitForJobs bool
}
// NewSyncOptions creates a new Apply
func NewSyncOptions() *SyncOptions {
return &SyncOptions{}
}
// SyncImpl is impl for applyOptions
type SyncImpl struct {
*GlobalImpl
*SyncOptions
}
// NewSyncImpl creates a new SyncImpl
func NewSyncImpl(g *GlobalImpl, t *SyncOptions) *SyncImpl {
return &SyncImpl{
GlobalImpl: g,
SyncOptions: t,
}
}
// Args returns the args
func (t *SyncImpl) Args() string {
return t.SyncOptions.Args
}
// Concurrency returns the concurrency
func (t *SyncImpl) Concurrency() int {
return t.SyncOptions.Concurrency
}
// IncludeNeeds returns the include needs
func (t *SyncImpl) IncludeNeeds() bool {
return t.SyncOptions.IncludeNeeds || t.SyncOptions.IncludeTransitiveNeeds
}
// IncludeTransitiveNeeds returns the include transitive needs
func (t *SyncImpl) IncludeTransitiveNeeds() bool {
return t.SyncOptions.IncludeTransitiveNeeds
}
// Set returns the Set
func (t *SyncImpl) Set() []string {
return t.SyncOptions.Set
}
// SkipDeps returns the skip deps
func (t *SyncImpl) SkipDeps() bool {
return t.SyncOptions.SkipDeps
}
// SkipNeeds returns the skip needs
func (t *SyncImpl) SkipNeeds() bool {
if !t.SyncOptions.IncludeNeeds {
return t.SyncOptions.SkipNeeds
}
return false
}
// Validate returns the validate
func (t *SyncImpl) Validate() bool {
return t.SyncOptions.Validate
}
// Values returns the values
func (t *SyncImpl) Values() []string {
return t.SyncOptions.Values
}
// SkipCRDS returns the skip crds
func (t *SyncImpl) SkipCRDs() bool {
return t.SyncOptions.SkipCRDs
}
// Wait returns the wait
func (t *SyncImpl) Wait() bool {
return t.SyncOptions.Wait
}
// WaitForJobs returns the wait for jobs
func (t *SyncImpl) WaitForJobs() bool {
return t.SyncOptions.WaitForJobs
}
+132
View File
@@ -0,0 +1,132 @@
package config
import (
"fmt"
"os"
"strings"
)
// TemplateOptions is the options for the build command
type TemplateOptions struct {
// Args is the args to pass to helm template
Args string
// Set is the set flag
Set []string
// Values is the values flag
Values []string
// OutputDir is the output dir flag
OutputDir string
// OutputDirTemplate is the output dir template flag
OutputDirTemplate string
// Concurrency is the concurrency flag
Concurrency int
// Validate is the validate flag
Validate bool
// IncludeCRDs is the include crds flag
IncludeCRDs bool
// SkipTests is the skip tests flag
SkipTests bool
// SkipNeeds is the skip needs flag
SkipNeeds bool
// IncludeNeeds is the include needs flag
IncludeNeeds bool
// IncludeTransitiveNeeds is the include transitive needs flag
IncludeTransitiveNeeds bool
// SkipDeps is the skip deps flag
SkipDeps bool
// SkipCleanup is the skip cleanup flag
SkipCleanup bool
}
// NewTemplateOptions creates a new Apply
func NewTemplateOptions() *TemplateOptions {
return &TemplateOptions{}
}
// TemplateImpl is impl for applyOptions
type TemplateImpl struct {
*GlobalImpl
*TemplateOptions
}
// NewTemplateImpl creates a new TemplateImpl
func NewTemplateImpl(g *GlobalImpl, t *TemplateOptions) *TemplateImpl {
return &TemplateImpl{
GlobalImpl: g,
TemplateOptions: t,
}
}
// Args returns the args
func (t *TemplateImpl) Args() string {
return t.TemplateOptions.Args
}
// Concurrency returns the concurrency
func (t *TemplateImpl) Concurrency() int {
return t.TemplateOptions.Concurrency
}
// IncludeCRDs returns the include crds
func (t *TemplateImpl) IncludeCRDs() bool {
return t.TemplateOptions.IncludeCRDs
}
// IncludeNeeds returns the include needs
func (t *TemplateImpl) IncludeNeeds() bool {
return t.TemplateOptions.IncludeNeeds || t.TemplateOptions.IncludeTransitiveNeeds
}
// IncludeTransitiveNeeds returns the include transitive needs
func (t *TemplateImpl) IncludeTransitiveNeeds() bool {
return t.TemplateOptions.IncludeTransitiveNeeds
}
// OutputDir returns the output dir
func (t *TemplateImpl) OutputDir() string {
return strings.TrimRight(t.TemplateOptions.OutputDir, fmt.Sprintf("%c", os.PathSeparator))
}
// OutputDirTemplate returns the output dir template
func (t *TemplateImpl) OutputDirTemplate() string {
return t.TemplateOptions.OutputDirTemplate
}
// Set returns the Set
func (t *TemplateImpl) Set() []string {
return t.TemplateOptions.Set
}
// SkipCleanup returns the skip cleanup
func (t *TemplateImpl) SkipCleanup() bool {
return t.TemplateOptions.SkipCleanup
}
// SkipDeps returns the skip deps
func (t *TemplateImpl) SkipDeps() bool {
return t.TemplateOptions.SkipDeps
}
// SkipNeeds returns the skip needs
func (t *TemplateImpl) SkipNeeds() bool {
if !t.TemplateOptions.IncludeNeeds {
return t.TemplateOptions.SkipNeeds
}
return false
}
// SkipTests returns the skip tests
func (t *TemplateImpl) SkipTests() bool {
return t.TemplateOptions.SkipTests
}
// Validate returns the validate
func (t *TemplateImpl) Validate() bool {
return t.TemplateOptions.Validate
}
// Values returns the values
func (t *TemplateImpl) Values() []string {
return t.TemplateOptions.Values
}
+75
View File
@@ -0,0 +1,75 @@
package config
import (
"github.com/helmfile/helmfile/pkg/state"
"github.com/spf13/cobra"
)
// TestOptions is the options for the build command
type TestOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// Args is the args to pass to helm lint
Args string
// Cleanup is the cleanup flag
Cleanup bool
// Logs is the logs flagj
Logs bool
// Timeout is the timeout flag
Timeout int
}
// NewTestOptions creates a new Apply
func NewTestOptions() *TestOptions {
return &TestOptions{}
}
// TestImpl is impl for applyOptions
type TestImpl struct {
*GlobalImpl
*TestOptions
Cmd *cobra.Command
}
// NewTestImpl creates a new TestImpl
func NewTestImpl(g *GlobalImpl, t *TestOptions) *TestImpl {
return &TestImpl{
GlobalImpl: g,
TestOptions: t,
}
}
// Concurrency returns the concurrency
func (t *TestImpl) Concurrency() int {
return t.TestOptions.Concurrency
}
// SkipDeps returns the skip deps
func (t *TestImpl) SkipDeps() bool {
return t.TestOptions.SkipDeps
}
// Args returns the args
func (t *TestImpl) Args() string {
return t.TestOptions.Args
}
// Cleanup returns the cleanup
func (t *TestImpl) Cleanup() bool {
return t.TestOptions.Cleanup
}
// Logs returns the logs
func (t *TestImpl) Logs() bool {
return t.TestOptions.Logs
}
// Timeout returns the timeout
func (t *TestImpl) Timeout() int {
if !t.Cmd.Flags().Changed("timeout") {
return state.EmptyTimeout
}
return t.TestOptions.Timeout
}
+74
View File
@@ -0,0 +1,74 @@
package config
// WriteValuesOptions is the options for the build command
type WriteValuesOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// Set is the set flags to pass to helm write values
Set []string
// Values is the values flags to pass to helm write values
Values []string
// OutputFileTemplate is the output file template
OutputFileTemplate string
}
// NewWriteValuesOptions creates a new Apply
func NewWriteValuesOptions() *WriteValuesOptions {
return &WriteValuesOptions{}
}
// WriteValuesImpl is impl for applyOptions
type WriteValuesImpl struct {
*GlobalImpl
*WriteValuesOptions
}
// NewWriteValuesImpl creates a new WriteValuesImpl
func NewWriteValuesImpl(g *GlobalImpl, b *WriteValuesOptions) *WriteValuesImpl {
return &WriteValuesImpl{
GlobalImpl: g,
WriteValuesOptions: b,
}
}
// Concurrency returns the concurrency
func (c *WriteValuesImpl) Concurrency() int {
return c.WriteValuesOptions.Concurrency
}
// SkipDeps returns the skip deps
func (c *WriteValuesImpl) SkipDeps() bool {
return c.WriteValuesOptions.SkipDeps
}
// Set returns the Set
func (c *WriteValuesImpl) Set() []string {
return c.WriteValuesOptions.Set
}
// Values returns the Values
func (c *WriteValuesImpl) Values() []string {
return c.WriteValuesOptions.Values
}
// SkipCleanUp returns the skip clean up
func (c *WriteValuesImpl) SkipCleanup() bool {
return false
}
// IncludeTransitiveNeeds returns the include transitive needs
func (c *WriteValuesImpl) IncludeTransitiveNeeds() bool {
return false
}
// OutputFileTemplate returns the output file template
func (c *WriteValuesImpl) OutputFileTemplate() string {
return c.WriteValuesOptions.OutputFileTemplate
}
// Args returns the args
func (c *WriteValuesImpl) Args() string {
return ""
}