Skip to content

Commit fb919c4

Browse files
re-implement #86
1 parent 87d6913 commit fb919c4

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

codefresh/resource_pipeline.go

+9
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ Pipeline concurrency policy: Builds on 'Pending Approval' state should be:
600600
Type: schema.TypeBool,
601601
Optional: true,
602602
},
603+
"enable_notifications": {
604+
Type: schema.TypeBool,
605+
Optional: true,
606+
},
603607
},
604608
},
605609
},
@@ -762,6 +766,8 @@ func flattenSpec(spec cfclient.Spec) []interface{} {
762766
options["keep_pvcs_for_pending_approval"] = valueOption
763767
case keyOption == "pendingApprovalConcurrencyApplied":
764768
options["pending_approval_concurrency_applied"] = valueOption
769+
case keyOption == "enableNotifications":
770+
options["enable_notifications"] = valueOption
765771
}
766772
}
767773
resOptions = append(resOptions, options)
@@ -1074,6 +1080,9 @@ func mapResourceToPipeline(d *schema.ResourceData) (*cfclient.Pipeline, error) {
10741080
if pendingApprovalConcurrencyApplied, ok := d.GetOkExists("spec.0.options.0.pending_approval_concurrency_applied"); ok {
10751081
pipelineSpecOption["pendingApprovalConcurrencyApplied"] = pendingApprovalConcurrencyApplied.(bool)
10761082
}
1083+
if enableNotifications, ok := d.GetOkExists("spec.0.options.0.enable_notifications"); ok {
1084+
pipelineSpecOption["enableNotifications"] = enableNotifications.(bool)
1085+
}
10771086
pipeline.Spec.Options = pipelineSpecOption
10781087
} else {
10791088
pipeline.Spec.Options = nil

codefresh/resource_pipeline_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,14 @@ func TestAccCodefreshPipelineOptions(t *testing.T) {
702702
CheckDestroy: testAccCheckCodefreshPipelineDestroy,
703703
Steps: []resource.TestStep{
704704
{
705-
Config: testAccCodefreshPipelineOptions(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "master", "git", true, false),
705+
Config: testAccCodefreshPipelineOptions(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "master", "git", true, false, false),
706706
Check: resource.ComposeTestCheckFunc(
707707
testAccCheckCodefreshPipelineExists(resourceName, &pipeline),
708708
resource.TestCheckResourceAttr(resourceName, "name", name),
709709
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "spec.0.options.*", map[string]string{
710710
"keep_pvcs_for_pending_approval": "true",
711711
"pending_approval_concurrency_applied": "false",
712+
"enable_notifications": "false",
712713
}),
713714
),
714715
},
@@ -1278,7 +1279,7 @@ func TestAccCodefreshPipeline_Contexts(t *testing.T) {
12781279
})
12791280
}
12801281

1281-
func testAccCodefreshPipelineOptions(rName, repo, path, revision, context string, keepPVCsForPendingApproval, pendingApprovalConcurrencyApplied bool) string {
1282+
func testAccCodefreshPipelineOptions(rName, repo, path, revision, context string, keepPVCsForPendingApproval, pendingApprovalConcurrencyApplied bool, enableNotifications bool) string {
12821283
return fmt.Sprintf(`
12831284
resource "codefresh_pipeline" "test" {
12841285
@@ -1300,10 +1301,11 @@ resource "codefresh_pipeline" "test" {
13001301
options {
13011302
keep_pvcs_for_pending_approval = %t
13021303
pending_approval_concurrency_applied = %t
1304+
enable_notifications = %t
13031305
}
13041306
}
13051307
}
1306-
`, rName, repo, path, revision, context, keepPVCsForPendingApproval, pendingApprovalConcurrencyApplied)
1308+
`, rName, repo, path, revision, context, keepPVCsForPendingApproval, pendingApprovalConcurrencyApplied, enableNotifications)
13071309
}
13081310

13091311
func testAccCodefreshPipelineOnCreateBranchIgnoreTrigger(rName, repo, path, revision, context string, ignoreTrigger bool) string {

docs/resources/pipeline.md

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ Optional:
187187

188188
Optional:
189189

190+
- `enable_notifications` (Boolean)
190191
- `keep_pvcs_for_pending_approval` (Boolean) When build enters 'Pending Approval' state, volume should:
191192
* Default (attribute not specified): "Use Setting accounts"
192193
* true: "Remain (build remains active)"

0 commit comments

Comments
 (0)