Skip to content

Commit

Permalink
Moving config files to core/config (#2036)
Browse files Browse the repository at this point in the history
* Moving config files to core/config

* fix package names

* fix package dependencies

* linting fixes

* more linting fixes

* ran golangci-lint run --fix
  • Loading branch information
msarvar authored Feb 3, 2022
1 parent 90c4a83 commit 7a927c0
Show file tree
Hide file tree
Showing 56 changed files with 123 additions and 124 deletions.
2 changes: 1 addition & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yaml
package config

import (
"encoding/json"
Expand All @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yaml_test
package config_test

import (
"fmt"
Expand All @@ -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"
)

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -45,21 +45,21 @@ 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")
}

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")
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -1111,7 +1111,7 @@ workflows:
}

func TestParseGlobalCfg_NotExist(t *testing.T) {
r := yaml.ParserValidator{}
r := config.ParserValidator{}
globalCfgArgs := valid.GlobalCfgArgs{
AllowRepoCfg: false,
MergeableReq: false,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
File renamed without changes.
Loading

0 comments on commit 7a927c0

Please sign in to comment.