diff --git a/cmd/server.go b/cmd/server.go index 8081eb9e06..bf8537265b 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -24,8 +24,8 @@ import ( homedir "github.com/mitchellh/go-homedir" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" "github.com/spf13/cobra" "github.com/spf13/viper" diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index f81271fa2d..bbc8a99a45 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -18,6 +18,8 @@ import ( . "github.com/petergtz/pegomock" "github.com/runatlantis/atlantis/server" events_controllers "github.com/runatlantis/atlantis/server/controllers/events" + "github.com/runatlantis/atlantis/server/core/config" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/db" "github.com/runatlantis/atlantis/server/core/locking" "github.com/runatlantis/atlantis/server/core/runtime" @@ -32,8 +34,6 @@ import ( "github.com/runatlantis/atlantis/server/events/vcs" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" "github.com/runatlantis/atlantis/server/events/webhooks" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/events/yaml/valid" handlermocks "github.com/runatlantis/atlantis/server/handlers/mocks" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" @@ -868,7 +868,7 @@ func setupE2E(t *testing.T, repoDir string) (events_controllers.VCSEventsControl defaultTFVersion := terraformClient.DefaultVersion() locker := events.NewDefaultWorkingDirLocker() - parser := &yaml.ParserValidator{} + parser := &config.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: true, diff --git a/server/events/yaml/parser_validator.go b/server/core/config/parser_validator.go similarity index 98% rename from server/events/yaml/parser_validator.go rename to server/core/config/parser_validator.go index 00f4592f36..b5989baa95 100644 --- a/server/events/yaml/parser_validator.go +++ b/server/core/config/parser_validator.go @@ -1,4 +1,4 @@ -package yaml +package config import ( "encoding/json" @@ -10,8 +10,8 @@ import ( shlex "github.com/flynn-archive/go-shlex" validation "github.com/go-ozzo/ozzo-validation" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/parser_validator_test.go b/server/core/config/parser_validator_test.go similarity index 98% rename from server/events/yaml/parser_validator_test.go rename to server/core/config/parser_validator_test.go index 876317a715..9fa0912fb0 100644 --- a/server/events/yaml/parser_validator_test.go +++ b/server/core/config/parser_validator_test.go @@ -1,4 +1,4 @@ -package yaml_test +package config_test import ( "fmt" @@ -9,8 +9,8 @@ import ( "testing" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" ) @@ -24,7 +24,7 @@ var globalCfgArgs = valid.GlobalCfgArgs{ var globalCfg = valid.NewGlobalCfgFromArgs(globalCfgArgs) func TestHasRepoCfg_DirDoesNotExist(t *testing.T) { - r := yaml.ParserValidator{} + r := config.ParserValidator{} exists, err := r.HasRepoCfg("/not/exist") Ok(t, err) Equals(t, false, exists) @@ -33,7 +33,7 @@ func TestHasRepoCfg_DirDoesNotExist(t *testing.T) { func TestHasRepoCfg_FileDoesNotExist(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() - r := yaml.ParserValidator{} + r := config.ParserValidator{} exists, err := r.HasRepoCfg(tmpDir) Ok(t, err) Equals(t, false, exists) @@ -45,13 +45,13 @@ func TestHasRepoCfg_InvalidFileExtension(t *testing.T) { _, err := os.Create(filepath.Join(tmpDir, "atlantis.yml")) Ok(t, err) - r := yaml.ParserValidator{} + r := config.ParserValidator{} _, err = r.HasRepoCfg(tmpDir) ErrContains(t, "found \"atlantis.yml\" as config file; rename using the .yaml extension - \"atlantis.yaml\"", err) } func TestParseRepoCfg_DirDoesNotExist(t *testing.T) { - r := yaml.ParserValidator{} + r := config.ParserValidator{} _, err := r.ParseRepoCfg("/not/exist", globalCfg, "") Assert(t, os.IsNotExist(err), "exp not exist err") } @@ -59,7 +59,7 @@ func TestParseRepoCfg_DirDoesNotExist(t *testing.T) { func TestParseRepoCfg_FileDoesNotExist(t *testing.T) { tmpDir, cleanup := TempDir(t) defer cleanup() - r := yaml.ParserValidator{} + r := config.ParserValidator{} _, err := r.ParseRepoCfg(tmpDir, globalCfg, "") Assert(t, os.IsNotExist(err), "exp not exist err") } @@ -70,7 +70,7 @@ func TestParseRepoCfg_BadPermissions(t *testing.T) { err := os.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), nil, 0000) Ok(t, err) - r := yaml.ParserValidator{} + r := config.ParserValidator{} _, err = r.ParseRepoCfg(tmpDir, globalCfg, "") ErrContains(t, "unable to read atlantis.yaml file: ", err) } @@ -104,7 +104,7 @@ func TestParseCfgs_InvalidYAML(t *testing.T) { confPath := filepath.Join(tmpDir, "atlantis.yaml") err := os.WriteFile(confPath, []byte(c.input), 0600) Ok(t, err) - r := yaml.ParserValidator{} + r := config.ParserValidator{} _, err = r.ParseRepoCfg(tmpDir, globalCfg, "") ErrContains(t, c.expErr, err) globalCfgArgs := valid.GlobalCfgArgs{ @@ -1070,7 +1070,7 @@ workflows: err := os.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), []byte(c.input), 0600) Ok(t, err) - r := yaml.ParserValidator{} + r := config.ParserValidator{} act, err := r.ParseRepoCfg(tmpDir, globalCfg, "") if c.expErr != "" { ErrEquals(t, c.expErr, err) @@ -1098,7 +1098,7 @@ workflows: err := os.WriteFile(filepath.Join(tmpDir, "atlantis.yaml"), []byte(repoCfg), 0600) Ok(t, err) - r := yaml.ParserValidator{} + r := config.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, MergeableReq: false, @@ -1111,7 +1111,7 @@ workflows: } func TestParseGlobalCfg_NotExist(t *testing.T) { - r := yaml.ParserValidator{} + r := config.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, MergeableReq: false, @@ -1481,7 +1481,7 @@ workflows: for name, c := range cases { t.Run(name, func(t *testing.T) { - r := yaml.ParserValidator{} + r := config.ParserValidator{} tmp, cleanup := TempDir(t) defer cleanup() path := filepath.Join(tmp, "conf.yaml") @@ -1682,7 +1682,7 @@ func TestParserValidator_ParseGlobalCfgJSON(t *testing.T) { } for name, c := range cases { t.Run(name, func(t *testing.T) { - pv := &yaml.ParserValidator{} + pv := &config.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, MergeableReq: false, @@ -1749,7 +1749,7 @@ func TestParseRepoCfg_V2ShellParsing(t *testing.T) { Ok(t, os.WriteFile(v2Path, []byte("version: 2\n"+cfg), 0600)) Ok(t, os.WriteFile(v3Path, []byte("version: 3\n"+cfg), 0600)) - p := &yaml.ParserValidator{} + p := &config.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: true, MergeableReq: false, diff --git a/server/events/yaml/raw/autoplan.go b/server/core/config/raw/autoplan.go similarity index 93% rename from server/events/yaml/raw/autoplan.go rename to server/core/config/raw/autoplan.go index 33f0b1fa1a..d6099fcd29 100644 --- a/server/events/yaml/raw/autoplan.go +++ b/server/core/config/raw/autoplan.go @@ -1,7 +1,7 @@ package raw import ( - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) // DefaultAutoPlanWhenModified is the default element in the when_modified diff --git a/server/events/yaml/raw/autoplan_test.go b/server/core/config/raw/autoplan_test.go similarity index 95% rename from server/events/yaml/raw/autoplan_test.go rename to server/core/config/raw/autoplan_test.go index 66744340df..7342c8eb3e 100644 --- a/server/events/yaml/raw/autoplan_test.go +++ b/server/core/config/raw/autoplan_test.go @@ -3,8 +3,8 @@ package raw_test import ( "testing" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/global_cfg.go b/server/core/config/raw/global_cfg.go similarity index 99% rename from server/events/yaml/raw/global_cfg.go rename to server/core/config/raw/global_cfg.go index 28c9d63ff0..a1d27fe74c 100644 --- a/server/events/yaml/raw/global_cfg.go +++ b/server/core/config/raw/global_cfg.go @@ -7,7 +7,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) // GlobalCfg is the raw schema for server-side repo config. diff --git a/server/events/yaml/raw/policies.go b/server/core/config/raw/policies.go similarity index 97% rename from server/events/yaml/raw/policies.go rename to server/core/config/raw/policies.go index 2506cd66a6..33fb78ee18 100644 --- a/server/events/yaml/raw/policies.go +++ b/server/core/config/raw/policies.go @@ -3,7 +3,7 @@ package raw import ( validation "github.com/go-ozzo/ozzo-validation" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) // PolicySets is the raw schema for repo-level atlantis.yaml config. diff --git a/server/events/yaml/raw/policies_test.go b/server/core/config/raw/policies_test.go similarity index 97% rename from server/events/yaml/raw/policies_test.go rename to server/core/config/raw/policies_test.go index 0fe3c2c161..53b599d1b2 100644 --- a/server/events/yaml/raw/policies_test.go +++ b/server/core/config/raw/policies_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/project.go b/server/core/config/raw/project.go similarity index 98% rename from server/events/yaml/raw/project.go rename to server/core/config/raw/project.go index 4fe32bacb3..e4b849818c 100644 --- a/server/events/yaml/raw/project.go +++ b/server/core/config/raw/project.go @@ -9,7 +9,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation" version "github.com/hashicorp/go-version" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) const ( diff --git a/server/events/yaml/raw/project_test.go b/server/core/config/raw/project_test.go similarity index 98% rename from server/events/yaml/raw/project_test.go rename to server/core/config/raw/project_test.go index fce646a20c..ea296839b8 100644 --- a/server/events/yaml/raw/project_test.go +++ b/server/core/config/raw/project_test.go @@ -5,8 +5,8 @@ import ( validation "github.com/go-ozzo/ozzo-validation" version "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/raw.go b/server/core/config/raw/raw.go similarity index 100% rename from server/events/yaml/raw/raw.go rename to server/core/config/raw/raw.go diff --git a/server/events/yaml/raw/raw_test.go b/server/core/config/raw/raw_test.go similarity index 100% rename from server/events/yaml/raw/raw_test.go rename to server/core/config/raw/raw_test.go diff --git a/server/events/yaml/raw/repo_cfg.go b/server/core/config/raw/repo_cfg.go similarity index 98% rename from server/events/yaml/raw/repo_cfg.go rename to server/core/config/raw/repo_cfg.go index 444175f6da..ef91fc96e4 100644 --- a/server/events/yaml/raw/repo_cfg.go +++ b/server/core/config/raw/repo_cfg.go @@ -4,7 +4,7 @@ import ( "errors" validation "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) // DefaultAutomerge is the default setting for automerge. diff --git a/server/events/yaml/raw/repo_cfg_test.go b/server/core/config/raw/repo_cfg_test.go similarity index 98% rename from server/events/yaml/raw/repo_cfg_test.go rename to server/core/config/raw/repo_cfg_test.go index aa2deb8c95..d5493fcc25 100644 --- a/server/events/yaml/raw/repo_cfg_test.go +++ b/server/core/config/raw/repo_cfg_test.go @@ -4,8 +4,8 @@ import ( "testing" validation "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/stage.go b/server/core/config/raw/stage.go similarity index 88% rename from server/events/yaml/raw/stage.go rename to server/core/config/raw/stage.go index 38772bfabd..d361a78313 100644 --- a/server/events/yaml/raw/stage.go +++ b/server/core/config/raw/stage.go @@ -2,7 +2,7 @@ package raw import ( validation "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) type Stage struct { diff --git a/server/events/yaml/raw/stage_test.go b/server/core/config/raw/stage_test.go similarity index 93% rename from server/events/yaml/raw/stage_test.go rename to server/core/config/raw/stage_test.go index 18c49c0bc3..4974a74519 100644 --- a/server/events/yaml/raw/stage_test.go +++ b/server/core/config/raw/stage_test.go @@ -4,8 +4,8 @@ import ( "testing" validation "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/step.go b/server/core/config/raw/step.go similarity index 99% rename from server/events/yaml/raw/step.go rename to server/core/config/raw/step.go index de15cd40a0..8d3d0b90be 100644 --- a/server/events/yaml/raw/step.go +++ b/server/core/config/raw/step.go @@ -8,7 +8,7 @@ import ( "strings" validation "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) const ( diff --git a/server/events/yaml/raw/step_test.go b/server/core/config/raw/step_test.go similarity index 98% rename from server/events/yaml/raw/step_test.go rename to server/core/config/raw/step_test.go index 94737ef002..b45cfd90d9 100644 --- a/server/events/yaml/raw/step_test.go +++ b/server/core/config/raw/step_test.go @@ -3,8 +3,8 @@ package raw_test import ( "testing" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/workflow.go b/server/core/config/raw/workflow.go similarity index 94% rename from server/events/yaml/raw/workflow.go rename to server/core/config/raw/workflow.go index 7429453298..59050dce2b 100644 --- a/server/events/yaml/raw/workflow.go +++ b/server/core/config/raw/workflow.go @@ -2,7 +2,7 @@ package raw import ( validation "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) type Workflow struct { diff --git a/server/events/yaml/raw/workflow_step.go b/server/core/config/raw/workflow_step.go similarity index 97% rename from server/events/yaml/raw/workflow_step.go rename to server/core/config/raw/workflow_step.go index 848234a848..5e89405c63 100644 --- a/server/events/yaml/raw/workflow_step.go +++ b/server/core/config/raw/workflow_step.go @@ -8,7 +8,7 @@ import ( "strings" validation "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) // WorkflowHook represents a single action/command to perform. In YAML, diff --git a/server/events/yaml/raw/workflow_step_test.go b/server/core/config/raw/workflow_step_test.go similarity index 95% rename from server/events/yaml/raw/workflow_step_test.go rename to server/core/config/raw/workflow_step_test.go index 9d69ed1df4..291e032f08 100644 --- a/server/events/yaml/raw/workflow_step_test.go +++ b/server/core/config/raw/workflow_step_test.go @@ -3,8 +3,8 @@ package raw_test import ( "testing" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/workflow_test.go b/server/core/config/raw/workflow_test.go similarity index 96% rename from server/events/yaml/raw/workflow_test.go rename to server/core/config/raw/workflow_test.go index 5b200540e7..8ff25e1a24 100644 --- a/server/events/yaml/raw/workflow_test.go +++ b/server/core/config/raw/workflow_test.go @@ -4,8 +4,8 @@ import ( "testing" validation "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" yaml "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/valid/global_cfg.go b/server/core/config/valid/global_cfg.go similarity index 100% rename from server/events/yaml/valid/global_cfg.go rename to server/core/config/valid/global_cfg.go diff --git a/server/events/yaml/valid/global_cfg_test.go b/server/core/config/valid/global_cfg_test.go similarity index 98% rename from server/events/yaml/valid/global_cfg_test.go rename to server/core/config/valid/global_cfg_test.go index d1570ac2ed..e6a86f6a3a 100644 --- a/server/events/yaml/valid/global_cfg_test.go +++ b/server/core/config/valid/global_cfg_test.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/go-version" "github.com/mohae/deepcopy" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) @@ -669,7 +669,7 @@ policies: ApprovedReq: false, UnDivergedReq: false, } - global, err = (&yaml.ParserValidator{}).ParseGlobalCfg(path, valid.NewGlobalCfgFromArgs(globalCfgArgs)) + global, err = (&config.ParserValidator{}).ParseGlobalCfg(path, valid.NewGlobalCfgFromArgs(globalCfgArgs)) Ok(t, err) } else { globalCfgArgs := valid.GlobalCfgArgs{ @@ -841,7 +841,7 @@ repos: UnDivergedReq: false, } - global, err = (&yaml.ParserValidator{}).ParseGlobalCfg(path, valid.NewGlobalCfgFromArgs(globalCfgArgs)) + global, err = (&config.ParserValidator{}).ParseGlobalCfg(path, valid.NewGlobalCfgFromArgs(globalCfgArgs)) Ok(t, err) } else { globalCfgArgs := valid.GlobalCfgArgs{ diff --git a/server/events/yaml/valid/policies.go b/server/core/config/valid/policies.go similarity index 100% rename from server/events/yaml/valid/policies.go rename to server/core/config/valid/policies.go diff --git a/server/events/yaml/valid/repo_cfg.go b/server/core/config/valid/repo_cfg.go similarity index 100% rename from server/events/yaml/valid/repo_cfg.go rename to server/core/config/valid/repo_cfg.go diff --git a/server/events/yaml/valid/repo_cfg_test.go b/server/core/config/valid/repo_cfg_test.go similarity index 99% rename from server/events/yaml/valid/repo_cfg_test.go rename to server/core/config/valid/repo_cfg_test.go index 56fb9c75df..431c8f2a3a 100644 --- a/server/events/yaml/valid/repo_cfg_test.go +++ b/server/core/config/valid/repo_cfg_test.go @@ -5,7 +5,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation" version "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" . "github.com/runatlantis/atlantis/testing" ) diff --git a/server/events/yaml/valid/valid.go b/server/core/config/valid/valid.go similarity index 100% rename from server/events/yaml/valid/valid.go rename to server/core/config/valid/valid.go diff --git a/server/core/runtime/policy/conftest_client.go b/server/core/runtime/policy/conftest_client.go index 620361f3c7..aa3d83ea49 100644 --- a/server/core/runtime/policy/conftest_client.go +++ b/server/core/runtime/policy/conftest_client.go @@ -9,11 +9,11 @@ import ( version "github.com/hashicorp/go-version" "github.com/pkg/errors" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/runtime/cache" runtime_models "github.com/runatlantis/atlantis/server/core/runtime/models" "github.com/runatlantis/atlantis/server/core/terraform" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" ) diff --git a/server/core/runtime/policy/conftest_client_test.go b/server/core/runtime/policy/conftest_client_test.go index 85ad66755f..c08a7360f6 100644 --- a/server/core/runtime/policy/conftest_client_test.go +++ b/server/core/runtime/policy/conftest_client_test.go @@ -10,12 +10,12 @@ import ( "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/runtime/cache/mocks" models_mocks "github.com/runatlantis/atlantis/server/core/runtime/models/mocks" conftest_mocks "github.com/runatlantis/atlantis/server/core/runtime/policy/mocks" terraform_mocks "github.com/runatlantis/atlantis/server/core/terraform/mocks" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) diff --git a/server/core/runtime/policy/mocks/matchers/valid_policyset.go b/server/core/runtime/policy/mocks/matchers/valid_policyset.go index c8eaab2cfa..4b2d633e0c 100644 --- a/server/core/runtime/policy/mocks/matchers/valid_policyset.go +++ b/server/core/runtime/policy/mocks/matchers/valid_policyset.go @@ -5,7 +5,7 @@ import ( "github.com/petergtz/pegomock" "reflect" - valid "github.com/runatlantis/atlantis/server/events/yaml/valid" + valid "github.com/runatlantis/atlantis/server/core/config/valid" ) func AnyValidPolicySet() valid.PolicySet { diff --git a/server/core/runtime/policy/mocks/mock_conftest_client.go b/server/core/runtime/policy/mocks/mock_conftest_client.go index 19cc3a9915..7b461634c4 100644 --- a/server/core/runtime/policy/mocks/mock_conftest_client.go +++ b/server/core/runtime/policy/mocks/mock_conftest_client.go @@ -5,7 +5,7 @@ package mocks import ( pegomock "github.com/petergtz/pegomock" - valid "github.com/runatlantis/atlantis/server/events/yaml/valid" + valid "github.com/runatlantis/atlantis/server/core/config/valid" "reflect" "time" ) diff --git a/server/core/runtime/policy_check_step_runner_test.go b/server/core/runtime/policy_check_step_runner_test.go index 0e255ac358..daea0bcc03 100644 --- a/server/core/runtime/policy_check_step_runner_test.go +++ b/server/core/runtime/policy_check_step_runner_test.go @@ -6,9 +6,9 @@ import ( "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/runtime/mocks" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) diff --git a/server/events/apply_requirement_handler.go b/server/events/apply_requirement_handler.go index 8ca844a88d..5d8fa93af0 100644 --- a/server/events/apply_requirement_handler.go +++ b/server/events/apply_requirement_handler.go @@ -1,9 +1,9 @@ package events import ( + "github.com/runatlantis/atlantis/server/core/config/raw" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) //go:generate pegomock generate -m --package mocks -o mocks/mock_apply_handler.go ApplyRequirement diff --git a/server/events/command_runner.go b/server/events/command_runner.go index 13fd5c4ed2..4e1738274b 100644 --- a/server/events/command_runner.go +++ b/server/events/command_runner.go @@ -20,9 +20,9 @@ import ( "github.com/google/go-github/v31/github" "github.com/mcdafydd/go-azuredevops/azuredevops" "github.com/pkg/errors" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/recovery" gitlab "github.com/xanzy/go-gitlab" diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index 637b9155b4..bc8b6d9b77 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -20,9 +20,9 @@ import ( "strings" "testing" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/db" "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" "github.com/google/go-github/v31/github" diff --git a/server/events/comment_parser.go b/server/events/comment_parser.go index 79f13e89dc..e8996a71cd 100644 --- a/server/events/comment_parser.go +++ b/server/events/comment_parser.go @@ -24,8 +24,8 @@ import ( "text/template" "github.com/flynn-archive/go-shlex" + "github.com/runatlantis/atlantis/server/core/config" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml" "github.com/spf13/pflag" ) @@ -189,7 +189,7 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen flagSet.SetOutput(io.Discard) flagSet.StringVarP(&workspace, workspaceFlagLong, workspaceFlagShort, "", "Switch to this Terraform workspace before planning.") flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Which directory to run plan in relative to root of repo, ex. 'child/dir'.") - flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Which project to run plan for. Refers to the name of the project configured in %s. Cannot be used at same time as workspace or dir flags.", yaml.AtlantisYAMLFilename)) + flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Which project to run plan for. Refers to the name of the project configured in %s. Cannot be used at same time as workspace or dir flags.", config.AtlantisYAMLFilename)) flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.") case models.ApplyCommand.String(): name = models.ApplyCommand @@ -197,7 +197,7 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen flagSet.SetOutput(io.Discard) flagSet.StringVarP(&workspace, workspaceFlagLong, workspaceFlagShort, "", "Apply the plan for this Terraform workspace.") flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Apply the plan for this directory, relative to root of repo, ex. 'child/dir'.") - flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Apply the plan for this project. Refers to the name of the project configured in %s. Cannot be used at same time as workspace or dir flags.", yaml.AtlantisYAMLFilename)) + flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Apply the plan for this project. Refers to the name of the project configured in %s. Cannot be used at same time as workspace or dir flags.", config.AtlantisYAMLFilename)) flagSet.BoolVarP(&autoMergeDisabled, autoMergeDisabledFlagLong, autoMergeDisabledFlagShort, false, "Disable automerge after apply.") flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.") case models.ApprovePoliciesCommand.String(): @@ -214,7 +214,7 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen flagSet = pflag.NewFlagSet(models.VersionCommand.String(), pflag.ContinueOnError) flagSet.StringVarP(&workspace, workspaceFlagLong, workspaceFlagShort, "", "Switch to this Terraform workspace before running version.") flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Which directory to run version in relative to root of repo, ex. 'child/dir'.") - flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Print the version for this project. Refers to the name of the project configured in %s.", yaml.AtlantisYAMLFilename)) + flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Print the version for this project. Refers to the name of the project configured in %s.", config.AtlantisYAMLFilename)) flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.") default: return CommentParseResult{CommentResponse: fmt.Sprintf("Error: unknown command %q – this is a bug", command)} diff --git a/server/events/models/fixtures/fixtures.go b/server/events/models/fixtures/fixtures.go index 420c2e7705..60713d6e61 100644 --- a/server/events/models/fixtures/fixtures.go +++ b/server/events/models/fixtures/fixtures.go @@ -15,9 +15,8 @@ package fixtures import ( "fmt" - + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) var Pull = models.PullRequest{ diff --git a/server/events/models/models.go b/server/events/models/models.go index 1afac77e00..50a77e963b 100644 --- a/server/events/models/models.go +++ b/server/events/models/models.go @@ -28,7 +28,7 @@ import ( "github.com/runatlantis/atlantis/server/logging" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" ) const ( diff --git a/server/events/post_workflow_hooks_command_runner.go b/server/events/post_workflow_hooks_command_runner.go index 56666de3e6..00e0348f91 100644 --- a/server/events/post_workflow_hooks_command_runner.go +++ b/server/events/post_workflow_hooks_command_runner.go @@ -1,10 +1,10 @@ package events import ( + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/runtime" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_post_workflows_hooks_command_runner.go PostWorkflowHooksCommandRunner diff --git a/server/events/post_workflow_hooks_command_runner_test.go b/server/events/post_workflow_hooks_command_runner_test.go index 9c615bc2da..68e0875da9 100644 --- a/server/events/post_workflow_hooks_command_runner_test.go +++ b/server/events/post_workflow_hooks_command_runner_test.go @@ -7,12 +7,12 @@ import ( runtime_mocks "github.com/runatlantis/atlantis/server/core/runtime/mocks" . "github.com/petergtz/pegomock" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/models/fixtures" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) diff --git a/server/events/pre_workflow_hooks_command_runner.go b/server/events/pre_workflow_hooks_command_runner.go index 44da8a88de..7ee2a4f06a 100644 --- a/server/events/pre_workflow_hooks_command_runner.go +++ b/server/events/pre_workflow_hooks_command_runner.go @@ -1,10 +1,10 @@ package events import ( + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/runtime" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_pre_workflows_hooks_command_runner.go PreWorkflowHooksCommandRunner diff --git a/server/events/pre_workflow_hooks_command_runner_test.go b/server/events/pre_workflow_hooks_command_runner_test.go index f027a03b84..d94b010ab0 100644 --- a/server/events/pre_workflow_hooks_command_runner_test.go +++ b/server/events/pre_workflow_hooks_command_runner_test.go @@ -5,13 +5,13 @@ import ( "testing" . "github.com/petergtz/pegomock" + "github.com/runatlantis/atlantis/server/core/config/valid" runtime_mocks "github.com/runatlantis/atlantis/server/core/runtime/mocks" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/models/fixtures" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index 03f744162f..f256d64c50 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -4,12 +4,12 @@ import ( "fmt" "os" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/pkg/errors" + "github.com/runatlantis/atlantis/server/core/config" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/yaml" ) const ( @@ -31,7 +31,7 @@ const ( func NewProjectCommandBuilder( policyChecksSupported bool, - parserValidator *yaml.ParserValidator, + parserValidator *config.ParserValidator, projectFinder ProjectFinder, vcsClient vcs.Client, workingDir WorkingDir, @@ -106,7 +106,7 @@ type ProjectCommandBuilder interface { // This class combines the data from the comment and any atlantis.yaml file or // Atlantis server config and then generates a set of contexts. type DefaultProjectCommandBuilder struct { - ParserValidator *yaml.ParserValidator + ParserValidator *config.ParserValidator ProjectFinder ProjectFinder VCSClient vcs.Client WorkingDir WorkingDir @@ -180,15 +180,15 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext, if p.SkipCloneNoChanges && p.VCSClient.SupportsSingleFileDownload(ctx.Pull.BaseRepo) { hasRepoCfg, repoCfgData, err := p.VCSClient.DownloadRepoConfigFile(ctx.Pull) if err != nil { - return nil, errors.Wrapf(err, "downloading %s", yaml.AtlantisYAMLFilename) + return nil, errors.Wrapf(err, "downloading %s", config.AtlantisYAMLFilename) } if hasRepoCfg { repoCfg, err := p.ParserValidator.ParseRepoCfgData(repoCfgData, p.GlobalCfg, ctx.Pull.BaseRepo.ID()) if err != nil { - return nil, errors.Wrapf(err, "parsing %s", yaml.AtlantisYAMLFilename) + return nil, errors.Wrapf(err, "parsing %s", config.AtlantisYAMLFilename) } - ctx.Log.Info("successfully parsed remote %s file", yaml.AtlantisYAMLFilename) + ctx.Log.Info("successfully parsed remote %s file", config.AtlantisYAMLFilename) matchingProjects, err := p.ProjectFinder.DetermineProjectsViaConfig(ctx.Log, modifiedFiles, repoCfg, "") if err != nil { return nil, err @@ -223,7 +223,7 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext, // Parse config file if it exists. hasRepoCfg, err := p.ParserValidator.HasRepoCfg(repoDir) if err != nil { - return nil, errors.Wrapf(err, "looking for %s file in %q", yaml.AtlantisYAMLFilename, repoDir) + return nil, errors.Wrapf(err, "looking for %s file in %q", config.AtlantisYAMLFilename, repoDir) } var projCtxs []models.ProjectCommandContext @@ -233,9 +233,9 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext, // should be planed. repoCfg, err := p.ParserValidator.ParseRepoCfg(repoDir, p.GlobalCfg, ctx.Pull.BaseRepo.ID()) if err != nil { - return nil, errors.Wrapf(err, "parsing %s", yaml.AtlantisYAMLFilename) + return nil, errors.Wrapf(err, "parsing %s", config.AtlantisYAMLFilename) } - ctx.Log.Info("successfully parsed %s file", yaml.AtlantisYAMLFilename) + ctx.Log.Info("successfully parsed %s file", config.AtlantisYAMLFilename) matchingProjects, err := p.ProjectFinder.DetermineProjectsViaConfig(ctx.Log, modifiedFiles, repoCfg, repoDir) if err != nil { return nil, err @@ -263,7 +263,7 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext, } else { // If there is no config file, then we'll plan each project that // our algorithm determines was modified. - ctx.Log.Info("found no %s file", yaml.AtlantisYAMLFilename) + ctx.Log.Info("found no %s file", config.AtlantisYAMLFilename) modifiedProjects := p.ProjectFinder.DetermineProjects(ctx.Log, modifiedFiles, ctx.Pull.BaseRepo.FullName, repoDir, p.AutoplanFileList) if err != nil { return nil, errors.Wrapf(err, "finding modified projects: %s", modifiedFiles) @@ -343,12 +343,12 @@ func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *CommandConte func (p *DefaultProjectCommandBuilder) getCfg(ctx *CommandContext, projectName string, dir string, workspace string, repoDir string) (projectsCfg []valid.Project, repoCfg *valid.RepoCfg, err error) { hasConfigFile, err := p.ParserValidator.HasRepoCfg(repoDir) if err != nil { - err = errors.Wrapf(err, "looking for %s file in %q", yaml.AtlantisYAMLFilename, repoDir) + err = errors.Wrapf(err, "looking for %s file in %q", config.AtlantisYAMLFilename, repoDir) return } if !hasConfigFile { if projectName != "" { - err = fmt.Errorf("cannot specify a project name unless an %s file exists to configure projects", yaml.AtlantisYAMLFilename) + err = fmt.Errorf("cannot specify a project name unless an %s file exists to configure projects", config.AtlantisYAMLFilename) return } return @@ -372,7 +372,7 @@ func (p *DefaultProjectCommandBuilder) getCfg(ctx *CommandContext, projectName s } } if len(projectsCfg) == 0 { - err = fmt.Errorf("no project with name %q is defined in %s", projectName, yaml.AtlantisYAMLFilename) + err = fmt.Errorf("no project with name %q is defined in %s", projectName, config.AtlantisYAMLFilename) return } return @@ -383,7 +383,7 @@ func (p *DefaultProjectCommandBuilder) getCfg(ctx *CommandContext, projectName s return } if len(projCfgs) > 1 { - err = fmt.Errorf("must specify project name: more than one project defined in %s matched dir: %q workspace: %q", yaml.AtlantisYAMLFilename, dir, workspace) + err = fmt.Errorf("must specify project name: more than one project defined in %s matched dir: %q workspace: %q", config.AtlantisYAMLFilename, dir, workspace) return } projectsCfg = projCfgs diff --git a/server/events/project_command_builder_internal_test.go b/server/events/project_command_builder_internal_test.go index e0aa8502d6..9ddc5c23d3 100644 --- a/server/events/project_command_builder_internal_test.go +++ b/server/events/project_command_builder_internal_test.go @@ -7,11 +7,11 @@ import ( version "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" + "github.com/runatlantis/atlantis/server/core/config" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events/matchers" "github.com/runatlantis/atlantis/server/events/models" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" logging_matchers "github.com/runatlantis/atlantis/server/logging/mocks/matchers" . "github.com/runatlantis/atlantis/testing" @@ -588,7 +588,7 @@ projects: // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") Ok(t, os.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) - parser := &yaml.ParserValidator{} + parser := &config.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, MergeableReq: false, @@ -785,7 +785,7 @@ projects: // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") Ok(t, os.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) - parser := &yaml.ParserValidator{} + parser := &config.ParserValidator{} globalCfg, err := parser.ParseGlobalCfg(globalCfgPath, valid.NewGlobalCfg(false, false, false)) Ok(t, err) @@ -997,7 +997,7 @@ workflows: // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") Ok(t, os.WriteFile(globalCfgPath, []byte(c.globalCfg), 0600)) - parser := &yaml.ParserValidator{} + parser := &config.ParserValidator{} globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, MergeableReq: false, diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go index 605c865b58..59aaf869d2 100644 --- a/server/events/project_command_builder_test.go +++ b/server/events/project_command_builder_test.go @@ -8,13 +8,13 @@ import ( "testing" . "github.com/petergtz/pegomock" + "github.com/runatlantis/atlantis/server/core/config" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/matchers" "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/models" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) @@ -132,7 +132,7 @@ projects: vcsClient := vcsmocks.NewMockClient() When(vcsClient.GetModifiedFiles(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) if c.AtlantisYAML != "" { - err := os.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) + err := os.WriteFile(filepath.Join(tmpDir, config.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) Ok(t, err) } @@ -145,7 +145,7 @@ projects: builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, vcsClient, workingDir, @@ -396,7 +396,7 @@ projects: vcsClient := vcsmocks.NewMockClient() When(vcsClient.GetModifiedFiles(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) if c.AtlantisYAML != "" { - err := os.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) + err := os.WriteFile(filepath.Join(tmpDir, config.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) Ok(t, err) } @@ -409,7 +409,7 @@ projects: builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, vcsClient, workingDir, @@ -547,7 +547,7 @@ projects: vcsClient := vcsmocks.NewMockClient() When(vcsClient.GetModifiedFiles(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) if c.AtlantisYAML != "" { - err := os.WriteFile(filepath.Join(tmpDir, yaml.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) + err := os.WriteFile(filepath.Join(tmpDir, config.AtlantisYAMLFilename), []byte(c.AtlantisYAML), 0600) Ok(t, err) } @@ -560,7 +560,7 @@ projects: builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, vcsClient, workingDir, @@ -647,7 +647,7 @@ func TestDefaultProjectCommandBuilder_BuildMultiApply(t *testing.T) { builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, nil, workingDir, @@ -705,7 +705,7 @@ projects: - dir: . workspace: staging ` - err := os.WriteFile(filepath.Join(repoDir, yaml.AtlantisYAMLFilename), []byte(yamlCfg), 0600) + err := os.WriteFile(filepath.Join(repoDir, config.AtlantisYAMLFilename), []byte(yamlCfg), 0600) Ok(t, err) When(workingDir.Clone( @@ -727,7 +727,7 @@ projects: builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, nil, workingDir, @@ -802,7 +802,7 @@ func TestDefaultProjectCommandBuilder_EscapeArgs(t *testing.T) { builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, vcsClient, workingDir, @@ -899,7 +899,7 @@ projects: "project1": map[string]interface{}{ "main.tf": fmt.Sprintf(baseVersionConfig, exactSymbols[0]), }, - yaml.AtlantisYAMLFilename: atlantisYamlContent, + config.AtlantisYAMLFilename: atlantisYamlContent, }, ModifiedFiles: []string{"project1/main.tf", "project2/main.tf"}, Exp: map[string][]int{ @@ -912,7 +912,7 @@ projects: "project1": map[string]interface{}{ "main.tf": nil, }, - yaml.AtlantisYAMLFilename: atlantisYamlContent, + config.AtlantisYAMLFilename: atlantisYamlContent, }, ModifiedFiles: []string{"project1/main.tf"}, Exp: map[string][]int{ @@ -981,7 +981,7 @@ projects: builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, vcsClient, workingDir, @@ -1044,7 +1044,7 @@ projects: builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, vcsClient, workingDir, @@ -1098,7 +1098,7 @@ func TestDefaultProjectCommandBuilder_WithPolicyCheckEnabled_BuildAutoplanComman builder := events.NewProjectCommandBuilder( true, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, vcsClient, workingDir, @@ -1176,7 +1176,7 @@ func TestDefaultProjectCommandBuilder_BuildVersionCommand(t *testing.T) { builder := events.NewProjectCommandBuilder( false, - &yaml.ParserValidator{}, + &config.ParserValidator{}, &events.DefaultProjectFinder{}, nil, workingDir, diff --git a/server/events/project_command_context_builder.go b/server/events/project_command_context_builder.go index 7f72ec755c..2cc5c674ba 100644 --- a/server/events/project_command_context_builder.go +++ b/server/events/project_command_context_builder.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-config-inspect/tfconfig" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) func NewProjectCommandContextBulder(policyCheckEnabled bool, commentBuilder CommentBuilder) ProjectCommandContextBuilder { diff --git a/server/events/project_command_context_builder_test.go b/server/events/project_command_context_builder_test.go index 6eca1e3433..50c5dced54 100644 --- a/server/events/project_command_context_builder_test.go +++ b/server/events/project_command_context_builder_test.go @@ -4,10 +4,10 @@ import ( "testing" . "github.com/petergtz/pegomock" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" "github.com/stretchr/testify/assert" ) diff --git a/server/events/project_command_runner.go b/server/events/project_command_runner.go index c648c73b7e..86a41d32e8 100644 --- a/server/events/project_command_runner.go +++ b/server/events/project_command_runner.go @@ -20,10 +20,10 @@ import ( "strings" "github.com/pkg/errors" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/runtime" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/webhooks" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/handlers" "github.com/runatlantis/atlantis/server/logging" ) diff --git a/server/events/project_command_runner_test.go b/server/events/project_command_runner_test.go index 5c63eb877d..052dff4288 100644 --- a/server/events/project_command_runner_test.go +++ b/server/events/project_command_runner_test.go @@ -21,13 +21,13 @@ import ( "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/runtime" tmocks "github.com/runatlantis/atlantis/server/core/terraform/mocks" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/valid" handlermocks "github.com/runatlantis/atlantis/server/handlers/mocks" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" diff --git a/server/events/project_finder.go b/server/events/project_finder.go index d6feedc7f8..b247122f7f 100644 --- a/server/events/project_finder.go +++ b/server/events/project_finder.go @@ -19,7 +19,7 @@ import ( "path/filepath" "strings" - "github.com/runatlantis/atlantis/server/events/yaml/valid" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/docker/docker/pkg/fileutils" "github.com/pkg/errors" diff --git a/server/events/project_finder_test.go b/server/events/project_finder_test.go index 006d9f8ac8..cf19538a7c 100644 --- a/server/events/project_finder_test.go +++ b/server/events/project_finder_test.go @@ -18,8 +18,8 @@ import ( "path/filepath" "testing" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) diff --git a/server/events/vcs/github_client.go b/server/events/vcs/github_client.go index bc6cec31ac..f98d5dc55a 100644 --- a/server/events/vcs/github_client.go +++ b/server/events/vcs/github_client.go @@ -24,9 +24,9 @@ import ( "github.com/Laisky/graphql" "github.com/google/go-github/v31/github" "github.com/pkg/errors" + "github.com/runatlantis/atlantis/server/core/config" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs/common" - "github.com/runatlantis/atlantis/server/events/yaml" "github.com/runatlantis/atlantis/server/logging" "github.com/shurcooL/githubv4" ) @@ -455,7 +455,7 @@ func (g *GithubClient) ExchangeCode(code string) (*GithubAppTemporarySecrets, er // if BaseRepo had one repo config file, its content will placed on the second return value func (g *GithubClient) DownloadRepoConfigFile(pull models.PullRequest) (bool, []byte, error) { opt := github.RepositoryContentGetOptions{Ref: pull.HeadBranch} - fileContent, _, resp, err := g.client.Repositories.GetContents(g.ctx, pull.BaseRepo.Owner, pull.BaseRepo.Name, yaml.AtlantisYAMLFilename, &opt) + fileContent, _, resp, err := g.client.Repositories.GetContents(g.ctx, pull.BaseRepo.Owner, pull.BaseRepo.Name, config.AtlantisYAMLFilename, &opt) if resp.StatusCode == http.StatusNotFound { return false, []byte{}, nil diff --git a/server/events/vcs/gitlab_client.go b/server/events/vcs/gitlab_client.go index 509d0e97df..623ba8cd52 100644 --- a/server/events/vcs/gitlab_client.go +++ b/server/events/vcs/gitlab_client.go @@ -22,7 +22,7 @@ import ( "strings" "time" - "github.com/runatlantis/atlantis/server/events/yaml" + "github.com/runatlantis/atlantis/server/core/config" "github.com/runatlantis/atlantis/server/events/vcs/common" @@ -365,7 +365,7 @@ func (g *GitlabClient) GetTeamNamesForUser(repo models.Repo, user models.User) ( func (g *GitlabClient) DownloadRepoConfigFile(pull models.PullRequest) (bool, []byte, error) { opt := gitlab.GetRawFileOptions{Ref: gitlab.String(pull.HeadBranch)} - bytes, resp, err := g.Client.RepositoryFiles.GetRawFile(pull.BaseRepo.FullName, yaml.AtlantisYAMLFilename, &opt) + bytes, resp, err := g.Client.RepositoryFiles.GetRawFile(pull.BaseRepo.FullName, config.AtlantisYAMLFilename, &opt) if resp.StatusCode == http.StatusNotFound { return false, []byte{}, nil } diff --git a/server/server.go b/server/server.go index 8c4aac1952..dda8c9e5d2 100644 --- a/server/server.go +++ b/server/server.go @@ -31,8 +31,8 @@ import ( "time" "github.com/mitchellh/go-homedir" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/db" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "github.com/runatlantis/atlantis/server/handlers" assetfs "github.com/elazarl/go-bindata-assetfs" @@ -42,6 +42,7 @@ import ( events_controllers "github.com/runatlantis/atlantis/server/controllers/events" "github.com/runatlantis/atlantis/server/controllers/templates" "github.com/runatlantis/atlantis/server/controllers/websocket" + cfgParser "github.com/runatlantis/atlantis/server/core/config" "github.com/runatlantis/atlantis/server/core/locking" "github.com/runatlantis/atlantis/server/core/runtime" "github.com/runatlantis/atlantis/server/core/runtime/policy" @@ -52,7 +53,6 @@ import ( "github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud" "github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver" "github.com/runatlantis/atlantis/server/events/webhooks" - "github.com/runatlantis/atlantis/server/events/yaml" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/static" "github.com/urfave/cli" @@ -394,7 +394,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { DB: boltdb, } - validator := &yaml.ParserValidator{} + validator := &cfgParser.ParserValidator{} globalCfg := valid.NewGlobalCfgFromArgs( valid.GlobalCfgArgs{