Skip to content

Commit

Permalink
Moving config files to core/config (runatlantis#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 and krrrr38 committed Dec 16, 2022
1 parent f2b2112 commit dc3a026
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 dc3a026

Please sign in to comment.