mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-06 10:48:31 +00:00
Merge pull request #862 from runatlantis/fix-default
Fix bug when redefining default workflow
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
version "github.com/hashicorp/go-version"
|
||||
"github.com/hashicorp/go-version"
|
||||
"github.com/runatlantis/atlantis/server/events/yaml"
|
||||
"github.com/runatlantis/atlantis/server/events/yaml/valid"
|
||||
. "github.com/runatlantis/atlantis/testing"
|
||||
@@ -1076,6 +1076,57 @@ repos:
|
||||
},
|
||||
},
|
||||
},
|
||||
"redefine default workflow": {
|
||||
input: `
|
||||
workflows:
|
||||
default:
|
||||
plan:
|
||||
steps:
|
||||
- run: custom
|
||||
apply:
|
||||
steps: []
|
||||
`,
|
||||
exp: valid.GlobalCfg{
|
||||
Repos: []valid.Repo{
|
||||
{
|
||||
IDRegex: regexp.MustCompile(".*"),
|
||||
ApplyRequirements: []string{},
|
||||
Workflow: &valid.Workflow{
|
||||
Name: "default",
|
||||
Apply: valid.Stage{
|
||||
Steps: nil,
|
||||
},
|
||||
Plan: valid.Stage{
|
||||
Steps: []valid.Step{
|
||||
{
|
||||
StepName: "run",
|
||||
RunCommand: "custom",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
AllowedOverrides: []string{},
|
||||
AllowCustomWorkflows: Bool(false),
|
||||
},
|
||||
},
|
||||
Workflows: map[string]valid.Workflow{
|
||||
"default": {
|
||||
Name: "default",
|
||||
Apply: valid.Stage{
|
||||
Steps: nil,
|
||||
},
|
||||
Plan: valid.Stage{
|
||||
Steps: []valid.Step{
|
||||
{
|
||||
StepName: "run",
|
||||
RunCommand: "custom",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for name, c := range cases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
|
||||
@@ -60,7 +60,14 @@ func (g GlobalCfg) Validate() error {
|
||||
func (g GlobalCfg) ToValid(defaultCfg valid.GlobalCfg) valid.GlobalCfg {
|
||||
workflows := make(map[string]valid.Workflow)
|
||||
for k, v := range g.Workflows {
|
||||
workflows[k] = v.ToValid(k)
|
||||
validatedWorkflow := v.ToValid(k)
|
||||
workflows[k] = validatedWorkflow
|
||||
if k == valid.DefaultWorkflowName {
|
||||
// Handle the special case where they're redefining the default
|
||||
// workflow. In this case, our default repo config references
|
||||
// the "old" default workflow and so needs to be redefined.
|
||||
defaultCfg.Repos[0].Workflow = &validatedWorkflow
|
||||
}
|
||||
}
|
||||
// Merge in defaults without overriding.
|
||||
for k, v := range defaultCfg.Workflows {
|
||||
|
||||
Reference in New Issue
Block a user