Skip to content

Commit 86acbbb

Browse files
authored
atlasaction: use plan URL instead name when checking plan for approval (#368)
This PR avoids a potential bug when running the approval process where two plans have the same name. Besides that, it also refactors minor things
1 parent fc48333 commit 86acbbb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

atlasaction/action.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,8 @@ func (a *Actions) schemaApplyWithApproval(ctx context.Context) ([]*atlasexec.Sch
10401040
if err := a.waitingForApproval(func() (bool, error) {
10411041
plans, err := a.Atlas.SchemaPlanList(ctx, a.schemaPlanListParams(
10421042
func(p *atlasexec.SchemaPlanListParams) {
1043-
p.From = []string{a.GetInput("url")}
1044-
p.To = []string{a.GetInput("to")}
1043+
p.From = a.GetArrayInput("url")
1044+
p.To = a.GetArrayInput("to")
10451045
p.Repo = repo
10461046
},
10471047
))
@@ -1051,7 +1051,7 @@ func (a *Actions) schemaApplyWithApproval(ctx context.Context) ([]*atlasexec.Sch
10511051
// Check the created plan is exists and approved.
10521052
var cloudPlan *atlasexec.SchemaPlanFile
10531053
for _, plan := range plans {
1054-
if plan.Name == f.Name {
1054+
if plan.URL == f.URL {
10551055
cloudPlan = &plan
10561056
break
10571057
}
@@ -1092,8 +1092,8 @@ You can approve the plan by visiting: %s`, f.Name, f.Link)
10921092
}
10931093
plan, err := a.Atlas.SchemaPlan(ctx, a.schemaPlanParams(
10941094
func(p *atlasexec.SchemaPlanParams) {
1095-
p.From = []string{a.GetInput("url")}
1096-
p.To = []string{a.GetInput("to")}
1095+
p.From = a.GetArrayInput("url")
1096+
p.To = a.GetArrayInput("to")
10971097
p.Repo = repo
10981098
p.Name = name
10991099
p.Pending = true
@@ -1113,8 +1113,8 @@ You can approve the plan by visiting: %s`, f.Name, f.Link)
11131113
policy := a.GetInput("approval-policy")
11141114
switch plans, err := a.Atlas.SchemaPlanList(ctx, a.schemaPlanListParams(
11151115
func(p *atlasexec.SchemaPlanListParams) {
1116-
p.From = []string{a.GetInput("url")}
1117-
p.To = []string{a.GetInput("to")}
1116+
p.From = a.GetArrayInput("url")
1117+
p.To = a.GetArrayInput("to")
11181118
p.Repo = repo
11191119
},
11201120
)); {

0 commit comments

Comments
 (0)