Skip to content

Commit

Permalink
Rename Workflow to WorkflowName
Browse files Browse the repository at this point in the history
  • Loading branch information
lkysow committed Mar 25, 2019
1 parent 252ddfd commit c92ba39
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
10 changes: 5 additions & 5 deletions server/events/yaml/parser_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ projects:
{
Dir: ".",
Workspace: "default",
Workflow: nil,
WorkflowName: nil,
TerraformVersion: nil,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
Expand Down Expand Up @@ -296,7 +296,7 @@ workflows:
{
Dir: ".",
Workspace: "myworkspace",
Workflow: String("myworkflow"),
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersion,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
Expand Down Expand Up @@ -334,7 +334,7 @@ workflows:
{
Dir: ".",
Workspace: "myworkspace",
Workflow: String("myworkflow"),
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersion,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
Expand Down Expand Up @@ -372,7 +372,7 @@ workflows:
{
Dir: ".",
Workspace: "myworkspace",
Workflow: String("myworkflow"),
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersion,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
Expand Down Expand Up @@ -410,7 +410,7 @@ workflows:
{
Dir: ".",
Workspace: "myworkspace",
Workflow: String("myworkflow"),
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersion,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
Expand Down
2 changes: 1 addition & 1 deletion server/events/yaml/raw/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (p Project) ToValid() valid.Project {
v.Workspace = *p.Workspace
}

v.Workflow = p.Workflow
v.WorkflowName = p.Workflow
if p.TerraformVersion != nil {
v.TerraformVersion, _ = version.NewVersion(*p.TerraformVersion)
}
Expand Down
4 changes: 2 additions & 2 deletions server/events/yaml/raw/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func TestProject_ToValid(t *testing.T) {
exp: valid.Project{
Dir: ".",
Workspace: "default",
Workflow: nil,
WorkflowName: nil,
TerraformVersion: nil,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
Expand All @@ -255,7 +255,7 @@ func TestProject_ToValid(t *testing.T) {
exp: valid.Project{
Dir: ".",
Workspace: "myworkspace",
Workflow: String("myworkflow"),
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersionPointEleven,
Autoplan: valid.Autoplan{
WhenModified: []string{"hi"},
Expand Down
10 changes: 5 additions & 5 deletions server/events/yaml/valid/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ func (g GlobalCfg) MergeProjectCfg(log logging.SimpleLogging, repoID string, pro
applyReqs = proj.ApplyRequirements
}
case WorkflowKey:
if proj.Workflow != nil {
if proj.WorkflowName != nil {
// We iterate over the global workflows first and the repo
// workflows second so that repo workflows override. This is
// safe because at this point we know if a repo is allowed to
// define its own workflow. We also know that a workflow will
// exist with this name due to earlier validation.
name := *proj.Workflow
name := *proj.WorkflowName
for k, v := range g.Workflows {
if k == name {
workflow = v
Expand Down Expand Up @@ -236,7 +236,7 @@ func (g GlobalCfg) ValidateRepoCfg(rCfg Config, repoID string) error {
}
}
for _, p := range rCfg.Projects {
if p.Workflow != nil && !sliceContainsF(allowedOverrides, WorkflowKey) {
if p.WorkflowName != nil && !sliceContainsF(allowedOverrides, WorkflowKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", WorkflowKey, AllowedOverridesKey, WorkflowKey)
}
if p.ApplyRequirements != nil && !sliceContainsF(allowedOverrides, ApplyRequirementsKey) {
Expand All @@ -260,8 +260,8 @@ func (g GlobalCfg) ValidateRepoCfg(rCfg Config, repoID string) error {

// Check if the repo has set a workflow name that doesn't exist.
for _, p := range rCfg.Projects {
if p.Workflow != nil {
name := *p.Workflow
if p.WorkflowName != nil {
name := *p.WorkflowName
if !mapContainsF(rCfg.Workflows, name) && !mapContainsF(g.Workflows, name) {
return fmt.Errorf("workflow %q is not defined anywhere", name)
}
Expand Down
26 changes: 13 additions & 13 deletions server/events/yaml/valid/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestGlobalCfg_ValidateRepoCfg(t *testing.T) {
rCfg: valid.Config{
Projects: []valid.Project{
{
Workflow: String("invalid"),
WorkflowName: String("invalid"),
},
},
},
Expand Down Expand Up @@ -165,9 +165,9 @@ func TestGlobalCfg_ValidateRepoCfg(t *testing.T) {
rCfg: valid.Config{
Projects: []valid.Project{
{
Dir: ".",
Workspace: "default",
Workflow: String("repodefined"),
Dir: ".",
Workspace: "default",
WorkflowName: String("repodefined"),
},
},
Workflows: map[string]valid.Workflow{
Expand Down Expand Up @@ -200,9 +200,9 @@ func TestGlobalCfg_ValidateRepoCfg(t *testing.T) {
rCfg: valid.Config{
Projects: []valid.Project{
{
Dir: ".",
Workspace: "default",
Workflow: String("default"),
Dir: ".",
Workspace: "default",
WorkflowName: String("default"),
},
},
},
Expand All @@ -228,9 +228,9 @@ func TestGlobalCfg_ValidateRepoCfg(t *testing.T) {
rCfg: valid.Config{
Projects: []valid.Project{
{
Dir: ".",
Workspace: "default",
Workflow: String("doesntexist"),
Dir: ".",
Workspace: "default",
WorkflowName: String("doesntexist"),
},
},
},
Expand Down Expand Up @@ -269,9 +269,9 @@ workflows:
steps: [plan]`,
repoID: "github.com/owner/repo",
proj: valid.Project{
Dir: ".",
Workspace: "default",
Workflow: String("custom"),
Dir: ".",
Workspace: "default",
WorkflowName: String("custom"),
},
repoWorkflows: nil,
exp: valid.MergedProjectCfg{
Expand Down
2 changes: 1 addition & 1 deletion server/events/yaml/valid/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Project struct {
Dir string
Workspace string
Name *string
Workflow *string
WorkflowName *string
TerraformVersion *version.Version
Autoplan Autoplan
ApplyRequirements []string
Expand Down

0 comments on commit c92ba39

Please sign in to comment.