From 90968a7ae6467b5d924a056db47d4571db7072a6 Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Wed, 20 Nov 2024 11:33:08 +0300 Subject: [PATCH] fix: load with koanf (no complicated load yet) --- internal/config/command.go | 6 +++--- internal/config/config.go | 12 ++++++------ internal/config/hook.go | 14 +++++++------- internal/config/remote.go | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/internal/config/command.go b/internal/config/command.go index 5fe5085a..6693c435 100644 --- a/internal/config/command.go +++ b/internal/config/command.go @@ -21,17 +21,17 @@ type Command struct { Tags []string `json:"tags,omitempty" mapstructure:"tags" toml:"tags,omitempty" yaml:",omitempty"` Env map[string]string `json:"env,omitempty" mapstructure:"env" toml:"env,omitempty" yaml:",omitempty"` - FileTypes []string `json:"file_types,omitempty" mapstructure:"file_types" toml:"file_types,omitempty" yaml:"file_types,omitempty" koanf:"file_types"` + FileTypes []string `json:"file_types,omitempty" koanf:"file_types" mapstructure:"file_types" toml:"file_types,omitempty" yaml:"file_types,omitempty"` Glob string `json:"glob,omitempty" mapstructure:"glob" toml:"glob,omitempty" yaml:",omitempty"` Root string `json:"root,omitempty" mapstructure:"root" toml:"root,omitempty" yaml:",omitempty"` Exclude interface{} `json:"exclude,omitempty" mapstructure:"exclude" toml:"exclude,omitempty" yaml:",omitempty"` Priority int `json:"priority,omitempty" mapstructure:"priority" toml:"priority,omitempty" yaml:",omitempty"` - FailText string `json:"fail_text,omitempty" mapstructure:"fail_text" toml:"fail_text,omitempty" yaml:"fail_text,omitempty" koanf:"fail_text"` + FailText string `json:"fail_text,omitempty" koanf:"fail_text" mapstructure:"fail_text" toml:"fail_text,omitempty" yaml:"fail_text,omitempty"` Interactive bool `json:"interactive,omitempty" mapstructure:"interactive" toml:"interactive,omitempty" yaml:",omitempty"` UseStdin bool `json:"use_stdin,omitempty" mapstructure:"use_stdin" toml:"use_stdin,omitempty" yaml:",omitempty"` - StageFixed bool `json:"stage_fixed,omitempty" mapstructure:"stage_fixed" toml:"stage_fixed,omitempty" yaml:"stage_fixed,omitempty" koanf:"stage_fixed"` + StageFixed bool `json:"stage_fixed,omitempty" koanf:"stage_fixed" mapstructure:"stage_fixed" toml:"stage_fixed,omitempty" yaml:"stage_fixed,omitempty"` } type commandRunReplace struct { diff --git a/internal/config/config.go b/internal/config/config.go index 286cff6c..7aa1dc38 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -27,15 +27,15 @@ const ( ) type Config struct { - MinVersion string `mapstructure:"min_version,omitempty" koanf:"min_version"` - SourceDir string `mapstructure:"source_dir" koanf:"source_dir"` - SourceDirLocal string `mapstructure:"source_dir_local" koanf:"source_dir_local"` + MinVersion string `koanf:"min_version" mapstructure:"min_version,omitempty"` + SourceDir string `koanf:"source_dir" mapstructure:"source_dir"` + SourceDirLocal string `koanf:"source_dir_local" mapstructure:"source_dir_local"` Rc string `mapstructure:"rc,omitempty"` - SkipOutput interface{} `mapstructure:"skip_output,omitempty" koanf:"skip_output"` + SkipOutput interface{} `koanf:"skip_output" mapstructure:"skip_output,omitempty"` Output interface{} `mapstructure:"output,omitempty"` Extends []string `mapstructure:"extends,omitempty"` - NoTTY bool `mapstructure:"no_tty,omitempty" koanf:"no_tty"` - AssertLefthookInstalled bool `mapstructure:"assert_lefthook_installed,omitempty" koanf:"assert_lefthook_installed"` + NoTTY bool `koanf:"no_tty" mapstructure:"no_tty,omitempty"` + AssertLefthookInstalled bool `koanf:"assert_lefthook_installed" mapstructure:"assert_lefthook_installed,omitempty"` Colors interface{} `mapstructure:"colors,omitempty"` SkipLFS bool `mapstructure:"skip_lfs,omitempty"` diff --git a/internal/config/hook.go b/internal/config/hook.go index 319b1123..18f98046 100644 --- a/internal/config/hook.go +++ b/internal/config/hook.go @@ -22,13 +22,13 @@ type Hook struct { // Unmarshalling it manually, so omit auto unmarshalling Scripts map[string]*Script `json:"scripts,omitempty" mapstructure:"-" toml:"scripts,omitempty" yaml:",omitempty"` - Files string `json:"files,omitempty" mapstructure:"files" toml:"files,omitempty" yaml:",omitempty"` - Parallel bool `json:"parallel,omitempty" mapstructure:"parallel" toml:"parallel,omitempty" yaml:",omitempty"` - Piped bool `json:"piped,omitempty" mapstructure:"piped" toml:"piped,omitempty" yaml:",omitempty"` - Follow bool `json:"follow,omitempty" mapstructure:"follow" toml:"follow,omitempty" yaml:",omitempty"` - ExcludeTags []string `json:"exclude_tags,omitempty" mapstructure:"exclude_tags" toml:"exclude_tags,omitempty" yaml:"exclude_tags,omitempty" koanf:"exclude_tags"` - Skip interface{} `json:"skip,omitempty" mapstructure:"skip" toml:"skip,omitempty,inline" yaml:",omitempty"` - Only interface{} `json:"only,omitempty" mapstructure:"only" toml:"only,omitempty,inline" yaml:",omitempty"` + Files string `json:"files,omitempty" mapstructure:"files" toml:"files,omitempty" yaml:",omitempty"` + Parallel bool `json:"parallel,omitempty" mapstructure:"parallel" toml:"parallel,omitempty" yaml:",omitempty"` + Piped bool `json:"piped,omitempty" mapstructure:"piped" toml:"piped,omitempty" yaml:",omitempty"` + Follow bool `json:"follow,omitempty" mapstructure:"follow" toml:"follow,omitempty" yaml:",omitempty"` + ExcludeTags []string `json:"exclude_tags,omitempty" koanf:"exclude_tags" mapstructure:"exclude_tags" toml:"exclude_tags,omitempty" yaml:"exclude_tags,omitempty"` + Skip interface{} `json:"skip,omitempty" mapstructure:"skip" toml:"skip,omitempty,inline" yaml:",omitempty"` + Only interface{} `json:"only,omitempty" mapstructure:"only" toml:"only,omitempty,inline" yaml:",omitempty"` } func (h *Hook) Validate() error { diff --git a/internal/config/remote.go b/internal/config/remote.go index d7ea3591..15f1ca93 100644 --- a/internal/config/remote.go +++ b/internal/config/remote.go @@ -1,13 +1,13 @@ package config type Remote struct { - GitURL string `json:"git_url,omitempty" mapstructure:"git_url" toml:"git_url" yaml:"git_url" koanf:"git_url"` - Ref string `json:"ref,omitempty" mapstructure:"ref,omitempty" toml:"ref,omitempty" yaml:",omitempty"` + GitURL string `json:"git_url,omitempty" koanf:"git_url" mapstructure:"git_url" toml:"git_url" yaml:"git_url"` + Ref string `json:"ref,omitempty" mapstructure:"ref,omitempty" toml:"ref,omitempty" yaml:",omitempty"` // Deprecated - Config string `json:"config,omitempty" mapstructure:"config,omitempty" toml:"config,omitempty" yaml:",omitempty"` - Configs []string `json:"configs,omitempty" mapstructure:"configs,omitempty" toml:"configs,omitempty" yaml:",omitempty"` - Refetch bool `json:"refetch,omitempty" mapstructure:"refetch,omitempty" toml:"refetch,omitempty" yaml:",omitempty"` - RefetchFrequency string `json:"refetch_frequency,omitempty" mapstructure:"refetch_frequency,omitempty" toml:"refetch_frequency,omitempty" yaml:",omitempty" koanf:"refetch_frequency"` + Config string `json:"config,omitempty" mapstructure:"config,omitempty" toml:"config,omitempty" yaml:",omitempty"` + Configs []string `json:"configs,omitempty" mapstructure:"configs,omitempty" toml:"configs,omitempty" yaml:",omitempty"` + Refetch bool `json:"refetch,omitempty" mapstructure:"refetch,omitempty" toml:"refetch,omitempty" yaml:",omitempty"` + RefetchFrequency string `json:"refetch_frequency,omitempty" koanf:"refetch_frequency" mapstructure:"refetch_frequency,omitempty" toml:"refetch_frequency,omitempty" yaml:",omitempty"` } func (r *Remote) Configured() bool {