mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 22:28:25 +00:00
Implement a new policy check workflow (#1317)
* Adding policy_check support into yaml config * Added policy check model and runtime structs * Adding BuildPolicyCheckCommand to ProjectCommandBuilder * Return incorrectly deleted code * Remove BuildAutoPolicyPlanCommand from ProjectCommandBuilder * Split runAutoCommand into two functions runAutoPlanCommand - does what originally RunAutoplancommand was doing except now it returns CommandResult and []models.ProjectCommandContext runAutoPolicyCheckCommand - accepts CommandContext, CommandResult, and []models.ProjectCommandContext as arguments and runs PolicyCheckStep runner * Refactor RunCommentCommand * Remove BuildPolicyCheckCommand and rename StepCmdExec back to TerraformExec * Add policy step runner logic and conftest interfaces. * Add show step runner to policy check stage. * Adding models.PolicyCheckCommand to buildCtx This also means buildPlanAllCommands call buildCtx twice once with models.PlanCommand and once with models.PolicyCheckCommand * Adding new project_command_builder that supports policy_check * Refactoring PolicyCheck specific logic into a PolicyCheckProjectCommandBuilder * Moving events.CommandContext to models.CommandContext this will allow me to remove buildCtx method and move ProjectCommandContext creation into models package * Policy Owners might be different types, for that reason we are refactoring Owners into its own struct with specific keys defining different owner types Co-authored-by: Nish Krishnan <nishk@lyft.com> Co-authored-by: Nish Krishnan <nishkrishnan@users.noreply.github.com>
This commit is contained in:
@@ -20,14 +20,10 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/runatlantis/atlantis/server/events"
|
||||
"github.com/runatlantis/atlantis/server/events/yaml/valid"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
. "github.com/petergtz/pegomock"
|
||||
"github.com/runatlantis/atlantis/server"
|
||||
@@ -49,35 +45,6 @@ func TestNewServer(t *testing.T) {
|
||||
}
|
||||
|
||||
// todo: test what happens if we set different flags. The generated config should be different.
|
||||
func TestRepoConfig(t *testing.T) {
|
||||
t.SkipNow()
|
||||
tmpDir, err := ioutil.TempDir("", "")
|
||||
Ok(t, err)
|
||||
|
||||
repoYaml := `
|
||||
repos:
|
||||
- id: "https://github.com/runatlantis/atlantis"
|
||||
`
|
||||
expConfig := valid.GlobalCfg{
|
||||
Repos: []valid.Repo{
|
||||
{
|
||||
ID: "https://github.com/runatlantis/atlantis",
|
||||
},
|
||||
},
|
||||
Workflows: map[string]valid.Workflow{},
|
||||
}
|
||||
repoFileLocation := filepath.Join(tmpDir, "repos.yaml")
|
||||
err = ioutil.WriteFile(repoFileLocation, []byte(repoYaml), 0600)
|
||||
Ok(t, err)
|
||||
|
||||
s, err := server.NewServer(server.UserConfig{
|
||||
DataDir: tmpDir,
|
||||
RepoConfig: repoFileLocation,
|
||||
AtlantisURL: "http://example.com",
|
||||
}, server.Config{})
|
||||
Ok(t, err)
|
||||
Equals(t, expConfig, s.CommandRunner.ProjectCommandBuilder.(*events.DefaultProjectCommandBuilder).GlobalCfg)
|
||||
}
|
||||
|
||||
func TestNewServer_InvalidAtlantisURL(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "")
|
||||
|
||||
Reference in New Issue
Block a user