helmfile/pkg/config
Hubertbits 912971c923 pkg/config: Split impl from options and integrate flag handler including tests
Signed-off-by: yxxhero <aiopsclub@163.com>
2025-04-17 07:30:37 +08:00
..
README.md pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
apply.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
apply_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
apply_test.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
build.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
build_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
cache.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
cache_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
config.go Use a regex to match --state-values-set-string arguments (#1902) 2025-02-04 07:59:31 +08:00
deps.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
deps_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
destroy.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
destroy_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
diff.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
diff_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
diff_test.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
fetch.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
fetch_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
flag_utils.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
global.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
global_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
global_test.go add support for HELMFILE_FILE_PATH envvar to set -f (#1255) 2024-01-03 21:37:49 +08:00
init.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
init_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
linit_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
lint.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
list.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
list_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
options.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
options_test.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
repos.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
repos_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
show-dag.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
show-dag_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
status.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
status_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
sync.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
sync_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
sync_test.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
template.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
template_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
template_test.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
test.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
test_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
write-values.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00
write-values_impl.go pkg/config: Split impl from options and integrate flag handler including tests 2025-04-17 07:30:37 +08:00

README.md

Config Package

Overview

The pkg/config package contains configuration options for various Helmfile commands. These options control the behavior of commands like apply, diff, template, sync, and others.

File Structure

pkg/config/
├── options.go            # Base options interfaces and common functionality
├── options_test.go       # Tests for base options
├── global.go             # Global options shared across all commands
├── global_impl.go        # Implementation of global options
├── apply.go              # ApplyOptions implementation for 'apply' command
├── apply_impl.go         # Implementation of ApplyOptions
├── apply_test.go         # Tests for ApplyOptions
├── build.go              # BuildOptions implementation for 'build' command
├── build_impl.go         # Implementation of BuildOptions
├── cache.go              # CacheOptions implementation for 'cache' command
├── cache_impl.go         # Implementation of CacheOptions
├── deps.go               # DepsOptions implementation for 'deps' command
├── deps_impl.go          # Implementation of DepsOptions
├── destroy.go            # DestroyOptions implementation for 'destroy' command
├── destroy_impl.go       # Implementation of DestroyOptions
├── destroy_test.go       # Tests for DestroyOptions
├── diff.go               # DiffOptions implementation for 'diff' command
├── diff_impl.go          # Implementation of DiffOptions
├── diff_test.go          # Tests for DiffOptions
├── fetch.go              # FetchOptions implementation for 'fetch' command
├── fetch_impl.go         # Implementation of FetchOptions
├── fetch_test.go         # Tests for FetchOptions
├── init.go               # InitOptions implementation for 'init' command
├── init_impl.go          # Implementation of InitOptions
├── lint.go               # LintOptions implementation for 'lint' command
├── linit_impl.go         # Implementation of LintOptions
├── lint_test.go          # Tests for LintOptions
├── list.go               # ListOptions implementation for 'list' command
├── list_impl.go          # Implementation of ListOptions
├── list_test.go          # Tests for ListOptions
├── repos.go              # ReposOptions implementation for 'repos' command
├── repos_impl.go         # Implementation of ReposOptions
├── show-dag.go           # ShowDAGOptions implementation for 'show-dag' command
├── show-dag_impl.go      # Implementation of ShowDAGOptions
├── status.go             # StatusOptions implementation for 'status' command
├── status_impl.go        # Implementation of StatusOptions
├── status_test.go        # Tests for StatusOptions
├── sync.go               # SyncOptions implementation for 'sync' command
├── sync_impl.go          # Implementation of SyncOptions
├── sync_test.go          # Tests for SyncOptions
├── template.go           # TemplateOptions implementation for 'template' command
├── template_impl.go      # Implementation of TemplateOptions
├── template_test.go      # Tests for TemplateOptions
├── test.go               # TestOptions implementation for 'test' command
├── test_impl.go          # Implementation of TestOptions
├── write-values.go       # WriteValuesOptions implementation for 'write-values' command
├── write-values_impl.go  # Implementation of WriteValuesOptions
└── common/               # Common option types shared across commands
    ├── bool_flag.go      # Boolean flag implementation
    ├── string_flag.go    # String flag implementation
    └── array_flag.go     # String array flag implementation

Components

  • Options Interfaces: Base interfaces that define common option behaviors
  • Global Options: Configuration options shared across all commands
  • Command-specific Options: Implementations for each command (e.g., ApplyOptions, DiffOptions)
  • Implementation Classes: Classes that combine global options with command-specific options
  • Flag Handling: Each options struct implements the FlagHandler interface from the pkg/flags package
  • Common Flag Types: Reusable flag implementations in the common subpackage

Key Features

  • Command Configuration: Each command has its own options type that controls its behavior
  • Flag Handling: Options implement the FlagHandler interface to receive flag values
  • Default Values: Options provide sensible defaults that can be overridden
  • Validation: Some options include validation logic to ensure valid configurations
  • Implementation Pattern: Each command has both an options struct and an implementation struct that combines global and command-specific options

Usage

Options objects are typically created by factory methods and populated with values from command-line flags. They are then passed to command implementations to control their behavior.

Example:

// Create options
opts := config.NewApplyOptions()

// Handle flags
handled := opts.HandleFlag("include-crds", &includeCRDs, true)
if !handled {
    // Flag wasn't recognized
}

// Create implementation with global options
globalOpts := config.NewGlobalImpl(&config.GlobalOptions{})
impl := config.NewApplyImpl(globalOpts, opts)

// Use in command
cmd.Execute(impl)

Testing

All option implementations should have comprehensive tests in this package. Tests should verify:

  1. Default values are set correctly
  2. Flags are handled properly
  3. The boolean return value from HandleFlag correctly indicates whether a flag was recognized
  4. Option validation works as expected
  • pkg/flags: Provides flag registration and handling functionality
  • pkg/factory: Creates properly configured options for commands
  • pkg/app: Uses options to control command execution