From 8808870d4dc51dc946d7822b6b2b64dac7b31f2b Mon Sep 17 00:00:00 2001 From: CreatureKing Date: Sun, 5 Nov 2023 11:43:51 -0500 Subject: [PATCH] fix: Always camel case never snake --- server/core/config/raw/autodiscover_test.go | 24 ++++++++++----------- server/core/config/raw/global_cfg.go | 4 ++-- server/core/config/raw/repo_cfg.go | 2 +- server/core/config/raw/repo_cfg_test.go | 10 ++++----- server/events/project_command_builder.go | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/server/core/config/raw/autodiscover_test.go b/server/core/config/raw/autodiscover_test.go index 417257ad64..1485367fe8 100644 --- a/server/core/config/raw/autodiscover_test.go +++ b/server/core/config/raw/autodiscover_test.go @@ -10,7 +10,7 @@ import ( ) func TestAutoDiscover_UnmarshalYAML(t *testing.T) { - auto_discover_enabled := valid.AutoDiscoverEnabledMode + autoDiscoverEnabled := valid.AutoDiscoverEnabledMode cases := []struct { description string input string @@ -29,7 +29,7 @@ func TestAutoDiscover_UnmarshalYAML(t *testing.T) { mode: enabled `, exp: raw.AutoDiscover{ - Mode: &auto_discover_enabled, + Mode: &autoDiscoverEnabled, }, }, } @@ -45,10 +45,10 @@ mode: enabled } func TestAutoDiscover_Validate(t *testing.T) { - auto_discover_auto := valid.AutoDiscoverAutoMode - auto_discover_enabled := valid.AutoDiscoverEnabledMode - auto_discover_disabled := valid.AutoDiscoverDisabledMode - random_string := valid.AutoDiscoverMode("random_string") + autoDiscoverAuto := valid.AutoDiscoverAutoMode + autoDiscoverEnabled := valid.AutoDiscoverEnabledMode + autoDiscoverDisabled := valid.AutoDiscoverDisabledMode + randomString := valid.AutoDiscoverMode("random_string") cases := []struct { description string input raw.AutoDiscover @@ -62,28 +62,28 @@ func TestAutoDiscover_Validate(t *testing.T) { { description: "mode set to auto", input: raw.AutoDiscover{ - Mode: &auto_discover_auto, + Mode: &autoDiscoverAuto, }, errContains: nil, }, { description: "mode set to disabled", input: raw.AutoDiscover{ - Mode: &auto_discover_disabled, + Mode: &autoDiscoverDisabled, }, errContains: nil, }, { description: "mode set to enabled", input: raw.AutoDiscover{ - Mode: &auto_discover_enabled, + Mode: &autoDiscoverEnabled, }, errContains: nil, }, { description: "mode set to random string", input: raw.AutoDiscover{ - Mode: &random_string, + Mode: &randomString, }, errContains: String("valid value"), }, @@ -100,7 +100,7 @@ func TestAutoDiscover_Validate(t *testing.T) { } func TestAutoDiscover_ToValid(t *testing.T) { - auto_discover_enabled := valid.AutoDiscoverEnabledMode + autoDiscoverEnabled := valid.AutoDiscoverEnabledMode cases := []struct { description string input raw.AutoDiscover @@ -116,7 +116,7 @@ func TestAutoDiscover_ToValid(t *testing.T) { { description: "value set", input: raw.AutoDiscover{ - Mode: &auto_discover_enabled, + Mode: &autoDiscoverEnabled, }, exp: &valid.AutoDiscover{ Mode: valid.AutoDiscoverEnabledMode, diff --git a/server/core/config/raw/global_cfg.go b/server/core/config/raw/global_cfg.go index c14b590afb..b795294239 100644 --- a/server/core/config/raw/global_cfg.go +++ b/server/core/config/raw/global_cfg.go @@ -213,7 +213,7 @@ func (r Repo) Validate() error { } autoDiscoverValid := func(value interface{}) error { - var autoDiscover *AutoDiscover = value.(*AutoDiscover) + autoDiscover := value.(*AutoDiscover) if autoDiscover != nil { return autoDiscover.Validate() } @@ -325,7 +325,7 @@ OuterGlobalImportReqs: mergedImportReqs = append(mergedImportReqs, globalReq) } - var autoDiscover *valid.AutoDiscover = nil + var autoDiscover *valid.AutoDiscover if r.AutoDiscover != nil { autoDiscover = r.AutoDiscover.ToValid() } diff --git a/server/core/config/raw/repo_cfg.go b/server/core/config/raw/repo_cfg.go index d11f32d996..f3a688725d 100644 --- a/server/core/config/raw/repo_cfg.go +++ b/server/core/config/raw/repo_cfg.go @@ -72,7 +72,7 @@ func (r RepoCfg) ToValid() valid.RepoCfg { abortOnExcecutionOrderFail = *r.AbortOnExcecutionOrderFail } - var autoDiscover *valid.AutoDiscover = nil + var autoDiscover *valid.AutoDiscover if r.AutoDiscover != nil { autoDiscover = r.AutoDiscover.ToValid() } diff --git a/server/core/config/raw/repo_cfg_test.go b/server/core/config/raw/repo_cfg_test.go index ac3fe53b0c..ff057548d0 100644 --- a/server/core/config/raw/repo_cfg_test.go +++ b/server/core/config/raw/repo_cfg_test.go @@ -11,7 +11,7 @@ import ( ) func TestConfig_UnmarshalYAML(t *testing.T) { - auto_discover_enabled := valid.AutoDiscoverEnabledMode + autoDiscoverEnabled := valid.AutoDiscoverEnabledMode cases := []struct { description string input string @@ -153,7 +153,7 @@ allowed_regexp_prefixes: - staging/`, exp: raw.RepoCfg{ Version: Int(3), - AutoDiscover: &raw.AutoDiscover{Mode: &auto_discover_enabled}, + AutoDiscover: &raw.AutoDiscover{Mode: &autoDiscoverEnabled}, Automerge: Bool(true), ParallelApply: Bool(true), ParallelPlan: Bool(false), @@ -236,7 +236,7 @@ func TestConfig_Validate(t *testing.T) { } func TestConfig_ToValid(t *testing.T) { - auto_discover_enabled := valid.AutoDiscoverEnabledMode + autoDiscoverEnabled := valid.AutoDiscoverEnabledMode cases := []struct { description string input raw.RepoCfg @@ -324,7 +324,7 @@ func TestConfig_ToValid(t *testing.T) { description: "autodiscover included", input: raw.RepoCfg{ Version: Int(2), - AutoDiscover: &raw.AutoDiscover{Mode: &auto_discover_enabled}, + AutoDiscover: &raw.AutoDiscover{Mode: &autoDiscoverEnabled}, }, exp: valid.RepoCfg{ Version: 2, @@ -371,7 +371,7 @@ func TestConfig_ToValid(t *testing.T) { Automerge: Bool(true), ParallelApply: Bool(true), AutoDiscover: &raw.AutoDiscover{ - Mode: &auto_discover_enabled, + Mode: &autoDiscoverEnabled, }, Workflows: map[string]raw.Workflow{ "myworkflow": { diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index f824508247..25f0e2c3e9 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -367,7 +367,7 @@ func (p *DefaultProjectCommandBuilder) buildAllCommandsByCfg(ctx *command.Contex if repoCfg.AutoDiscover != nil { defaultAutoDiscoverMode = repoCfg.AutoDiscover.Mode } - // If auto_discovery is enabled, we never want to skip cloning + // If auto discover is enabled, we never want to skip cloning if !repoCfg.AutoDiscoverEnabled(defaultAutoDiscoverMode) { if len(repoCfg.Projects) > 0 { matchingProjects, err := p.ProjectFinder.DetermineProjectsViaConfig(ctx.Log, modifiedFiles, repoCfg, "", nil)