Skip to content

Commit

Permalink
remove old workflow mode that is not platform (pr)
Browse files Browse the repository at this point in the history
  • Loading branch information
smonero committed Jul 19, 2024
1 parent 3aaf0d7 commit d4b57a6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 43 deletions.
2 changes: 1 addition & 1 deletion server/config/raw/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (p Project) ToValid(defaultWorkflowModeType valid.WorkflowModeType) valid.P
v.DeploymentWorkflowName = p.DeploymentWorkflowName
v.WorkflowModeType = defaultWorkflowModeType
if p.WorkflowModeType != nil {
v.WorkflowModeType = toWorkflowModeType(*p.WorkflowModeType)
v.WorkflowModeType = toWorkflowModeType()
}
if p.TerraformVersion != nil {
v.TerraformVersion, _ = version.NewVersion(*p.TerraformVersion)
Expand Down
22 changes: 11 additions & 11 deletions server/config/raw/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestProject_ToValid(t *testing.T) {
},
ApplyRequirements: nil,
Name: nil,
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
{
Expand Down Expand Up @@ -314,7 +314,7 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
// Directories.
Expand All @@ -330,7 +330,7 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
{
Expand All @@ -345,7 +345,7 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
{
Expand All @@ -360,7 +360,7 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
{
Expand All @@ -376,7 +376,7 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
{
Expand All @@ -391,7 +391,7 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
{
Expand All @@ -406,7 +406,7 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
{
Expand All @@ -421,7 +421,7 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},

Expand All @@ -438,13 +438,13 @@ func TestProject_ToValid(t *testing.T) {
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
},
},
}
for _, c := range cases {
t.Run(c.description, func(t *testing.T) {
Equals(t, c.exp, c.input.ToValid(valid.DefaultWorkflowMode))
Equals(t, c.exp, c.input.ToValid(valid.PlatformWorkflowMode))
})
}
}
10 changes: 3 additions & 7 deletions server/config/raw/repo_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func (r RepoCfg) Validate() error {
return validation.ValidateStruct(&r,
validation.Field(&r.Version, validation.By(equals2)),
validation.Field(&r.Projects),
validation.Field(&r.WorkflowModeType, validation.In("pr", "platform")),
validation.Field(&r.WorkflowModeType, validation.In("platform")),
)
}

func (r RepoCfg) ToValid() valid.RepoCfg {
workflowModeType := toWorkflowModeType(r.WorkflowModeType)
workflowModeType := toWorkflowModeType()

var validProjects []valid.Project
for _, p := range r.Projects {
Expand All @@ -72,11 +72,7 @@ func (r RepoCfg) ToValid() valid.RepoCfg {
}
}

func toWorkflowModeType(workflowModeType string) valid.WorkflowModeType {
func toWorkflowModeType() valid.WorkflowModeType {
result := valid.PlatformWorkflowMode
switch workflowModeType {
case "pr":
result = valid.DefaultWorkflowMode
}
return result
}
1 change: 0 additions & 1 deletion server/config/valid/global_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type WorkflowModeType int

const (
PlatformWorkflowMode WorkflowModeType = iota
DefaultWorkflowMode
)

type BackendType string
Expand Down
2 changes: 1 addition & 1 deletion server/legacy/events/project_command_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func TestDefaultProjectCommandRunner_ApplyDiverged(t *testing.T) {
}
prjCtx := command.ProjectContext{
ApplyRequirements: []string{"undiverged"},
WorkflowModeType: valid.DefaultWorkflowMode,
WorkflowModeType: valid.PlatformWorkflowMode,
}
tmp, cleanup := TempDir(t)
defer cleanup()
Expand Down
23 changes: 1 addition & 22 deletions server/legacy/lyft/command/feature_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ func (b *TestMultiBuilder) BuildApplyCommands(ctx *command.Context, comment *com
{
WorkflowModeType: valid.PlatformWorkflowMode,
},
{
WorkflowModeType: valid.DefaultWorkflowMode,
},
}, nil
}

Expand Down Expand Up @@ -148,7 +145,7 @@ func TestPlatformModeRunner_allocatesButNotPlatformMode(t *testing.T) {
}

builder := &TestBuilder{
Type: valid.DefaultWorkflowMode,
Type: valid.PlatformWorkflowMode,
}
runner := &testCMDRunner{
t: t,
Expand Down Expand Up @@ -303,15 +300,6 @@ func TestPlatformModeProjectRunner_plan(t *testing.T) {
},
prModeRunner: &testRunner{},
},
{
description: "allocated and platform mode not enabled",
shouldAllocate: true,
workflowModeType: valid.DefaultWorkflowMode,
platformRunner: &testRunner{},
prModeRunner: &testRunner{
expectedPlanResult: expectedResult,
},
},
}

for _, c := range cases {
Expand Down Expand Up @@ -365,15 +353,6 @@ func TestPlatformModeProjectRunner_policyCheck(t *testing.T) {
},
prModeRunner: &testRunner{},
},
{
description: "allocated and platform mode not enabled",
shouldAllocate: true,
workflowModeType: valid.DefaultWorkflowMode,
platformRunner: &testRunner{},
prModeRunner: &testRunner{
expectedPolicyCheckResult: expectedResult,
},
},
}

for _, c := range cases {
Expand Down

0 comments on commit d4b57a6

Please sign in to comment.