Skip to content

Add enableNotifications to spec's options #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions client/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,15 @@ func (client *Client) DeleteUser(userName string) error {
Method: "DELETE",
}

// The API will return a 500 error if the user cannot be found
// In this case the DeleteUser function should not return an error.
// Return error only if the body of the return message does not contain "User does not exist"
res, err := client.RequestAPI(&opts)
if err != nil {
if !strings.Contains(string(res), "User does not exist") {
return err
}
}
// The API will return a 500 error if the user cannot be found
// In this case the DeleteUser function should not return an error.
// Return error only if the body of the return message does not contain "User does not exist"
res, err := client.RequestAPI(&opts)
if err != nil {
if !strings.Contains(string(res), "User does not exist") {
return err
}
}

return nil
}
Expand Down
9 changes: 9 additions & 0 deletions codefresh/resource_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ func resourcePipeline() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"enable_notifications": {
Type: schema.TypeBool,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -503,6 +507,8 @@ func flattenSpec(spec cfClient.Spec) []interface{} {
options["keep_pvcs_for_pending_approval"] = valueOption
case keyOption == "pendingApprovalConcurrencyApplied":
options["pending_approval_concurrency_applied"] = valueOption
case keyOption == "enableNotifications":
options["enable_notifications"] = valueOption
}
}
resOptions = append(resOptions, options)
Expand Down Expand Up @@ -744,6 +750,9 @@ func mapResourceToPipeline(d *schema.ResourceData) *cfClient.Pipeline {
if pendingApprovalConcurrencyApplied, ok := d.GetOkExists("spec.0.options.0.pending_approval_concurrency_applied"); ok {
pipelineSpecOption["pendingApprovalConcurrencyApplied"] = pendingApprovalConcurrencyApplied.(bool)
}
if enableNotifications, ok := d.GetOkExists("spec.0.options.0.enable_notifications"); ok {
pipelineSpecOption["enableNotifications"] = enableNotifications.(bool)
}
pipeline.Spec.Options = pipelineSpecOption
} else {
pipeline.Spec.Options = nil
Expand Down
8 changes: 5 additions & 3 deletions codefresh/resource_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,13 @@ func TestAccCodefreshPipelineOptions(t *testing.T) {
CheckDestroy: testAccCheckCodefreshPipelineDestroy,
Steps: []resource.TestStep{
{
Config: testAccCodefreshPipelineOptions(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "master", "git", true, false),
Config: testAccCodefreshPipelineOptions(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "master", "git", true, false, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckCodefreshPipelineExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "spec.0.options.0.keep_pvcs_for_pending_approval", "true"),
resource.TestCheckResourceAttr(resourceName, "spec.0.options.0.pending_approval_concurrency_applied", "false"),
resource.TestCheckResourceAttr(resourceName, "spec.0.options.0.enable_notifications", "false"),
),
},
{
Expand Down Expand Up @@ -914,7 +915,7 @@ func TestAccCodefreshPipeline_Contexts(t *testing.T) {
})
}

func testAccCodefreshPipelineOptions(rName, repo, path, revision, context string, keepPVCsForPendingApproval, pendingApprovalConcurrencyApplied bool) string {
func testAccCodefreshPipelineOptions(rName, repo, path, revision, context string, keepPVCsForPendingApproval, pendingApprovalConcurrencyApplied, enableNotifications bool) string {
return fmt.Sprintf(`
resource "codefresh_pipeline" "test" {

Expand All @@ -936,10 +937,11 @@ resource "codefresh_pipeline" "test" {
options {
keep_pvcs_for_pending_approval = %t
pending_approval_concurrency_applied = %t
enable_notifications = %t
}
}
}
`, rName, repo, path, revision, context, keepPVCsForPendingApproval, pendingApprovalConcurrencyApplied)
`, rName, repo, path, revision, context, keepPVCsForPendingApproval, pendingApprovalConcurrencyApplied, enableNotifications)
}

func testAccCodefreshPipelineOnCreateBranchIgnoreTrigger(rName, repo, path, revision, context string, ignoreTrigger bool) string {
Expand Down
81 changes: 53 additions & 28 deletions docs/resources/pipeline.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Pipeline Resource

The central component of the Codefresh Platform. Pipelines are workflows that contain individual steps. Each step is responsible for a specific action in the process.
See the [documentation](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/introduction-to-codefresh-pipelines/) for the details.
The central component of the Codefresh Platform. Pipelines are workflows that contain individual steps. Each step is
responsible for a specific action in the process.
See the [documentation](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/introduction-to-codefresh-pipelines/)
for the details.

## Example Usage

Expand Down Expand Up @@ -86,13 +88,14 @@ resource "codefresh_pipeline" "test" {
## Argument Reference

- `name` - (Required) The display name for the pipeline.
- `revision` - (Optional) The pipeline's revision. Should be added to the **lifecycle/ignore_changes** or incremented mannually each update.
- `revision` - (Optional) The pipeline's revision. Should be added to the **lifecycle/ignore_changes** or incremented
mannually each update.
- `is_public` - (Optional) Boolean that specifies if the build logs are publicly accessible. Default: false
- `tags` - (Optional) A list of tags to mark a project for easy management and access control.
- `spec` - (Required) A collection of `spec` blocks as documented below.
- `original_yaml_string` - (Optional) A string with original yaml pipeline.
- `original_yaml_string = "version: \"1.0\"\nsteps:\n test:\n image: alpine:latest\n commands:\n - echo \"ACC tests\""`
- or `original_yaml_string = file("/path/to/my/codefresh.yml")`
- `original_yaml_string = "version: \"1.0\"\nsteps:\n test:\n image: alpine:latest\n commands:\n - echo \"ACC tests\""`
- or `original_yaml_string = file("/path/to/my/codefresh.yml")`

---

Expand All @@ -103,11 +106,15 @@ resource "codefresh_pipeline" "test" {
- `trigger_concurrency` - (Optional) The maximum amount of concurrent builds that may run for each trigger.
- `priority` - (optional) Helps to organize the order of builds execution in case of reaching the concurrency limit.
- `variables` - (Optional) Pipeline variables.
- `trigger` - (Optional) A collection of `trigger` blocks as documented below. Triggers [documentation](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/triggers/git-triggers/).
- `trigger` - (Optional) A collection of `trigger` blocks as documented below.
Triggers [documentation](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/triggers/git-triggers/).
- `spec_template` - (Optional) A collection of `spec_template` blocks as documented below.
- `runtime_environment` - (Optional) A collection of `runtime_environment` blocks as documented below.
- `pack_id` - (Optional) SAAS pack (`5cd1746617313f468d669013` for Small; `5cd1746717313f468d669014` for Medium; `5cd1746817313f468d669015` for Large; `5cd1746817313f468d669017` for XL; `5cd1746817313f468d669018` for XXL)
- `contexts` - (Optional) A list of strings representing the contexts ([shared_configuration](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/shared-configuration/)) to be configured for the pipeline
- `pack_id` - (Optional) SAAS pack (`5cd1746617313f468d669013` for Small; `5cd1746717313f468d669014` for
Medium; `5cd1746817313f468d669015` for Large; `5cd1746817313f468d669017` for XL; `5cd1746817313f468d669018` for XXL)
- `contexts` - (Optional) A list of strings representing the
contexts ([shared_configuration](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/shared-configuration/)) to be
configured for the pipeline
- `termination_policy` - (Optional) A `termination_policy` block as documented below.
- `options` - (Optional) A `options` block as documented below.

Expand All @@ -130,20 +137,27 @@ resource "codefresh_pipeline" "test" {
- `type` - (Optional) The trigger type. Default value - **git**.
- `repo` - (Optional) The GitHub `account/repo_name`.
- `branch_regex` - (Optional) A regular expression and will only trigger for branches that match this naming pattern.
- `branch_regex_input` - (Optional) Flag to manage how the `branch_regex` field is interpreted. Possible values: "multiselect-exclude", "multiselect", "regex". Default: "regex"
- `pull_request_target_branch_regex` - (Optional) A regular expression and will only trigger for pull requests to branches that match this naming pattern.
- `comment_regex` - (Optional) A regular expression and will only trigger for pull requests where a comment matches this naming pattern.
- `modified_files_glob` - (Optional) Allows to constrain the build and trigger it only if the modified files from the commit match this glob expression.
- `branch_regex_input` - (Optional) Flag to manage how the `branch_regex` field is interpreted. Possible values: "
multiselect-exclude", "multiselect", "regex". Default: "regex"
- `pull_request_target_branch_regex` - (Optional) A regular expression and will only trigger for pull requests to
branches that match this naming pattern.
- `comment_regex` - (Optional) A regular expression and will only trigger for pull requests where a comment matches this
naming pattern.
- `modified_files_glob` - (Optional) Allows to constrain the build and trigger it only if the modified files from the
commit match this glob expression.
- `events` - (Optional) A list of GitHub events for which a Pipeline is triggered. Default value - **push.heads**.
- `provider` - (Optional) Default value - **github**.
- `context` - (Optional) Codefresh Git context.
- `commit_status_title` - (Optional) The commit status title pushed to the GIT version control system.
- `variables` - (Optional) Trigger variables.
- `disabled` - (Optional) Boolean. If false, trigger will never be activated.
- `pull_request_allow_fork_events` - (Optional) Boolean. If this trigger is also applicable to Git forks.
- `contexts` - (Optional) A list of strings representing the contexts ([shared_configuration](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/shared-configuration/)) to be loaded when the trigger is executed
- `contexts` - (Optional) A list of strings representing the
contexts ([shared_configuration](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/shared-configuration/)) to be
loaded when the trigger is executed
- `runtime_environment` - (Optional) A collection of `runtime_environment` blocks as documented below.
- `options`: (Optional) A collection `option` blocks as documented below.

---

`runtime_environment` supports the following:
Expand All @@ -160,14 +174,16 @@ resource "codefresh_pipeline" "test" {
- `no_cache` - (Required) Boolean. If true, docker layer cache is disabled. Default false
- `no_cf_cache` - (Optional) Boolean. If true, extra Codefresh caching is disabled. Default false
- `reset_volume` - (Optional) Boolean. If true, all files on volume will be deleted before each execution. Default false
- `enable_notifications` - (Optional) Boolean. If false the pipeline will not send notifications to Slack and status updates back to the Git provider. Default false
- `enable_notifications` - (Optional) Boolean. If false the pipeline will not send notifications to Slack and status
updates back to the Git provider. Default false

---

`termination_policy` supports the following:

- `on_create_branch` - (Optional) A `on_create_branch` block as documented below.
- `on_terminate_annotation` - (Optional) Boolean. Enables the policy `Once a build is terminated, terminate all child builds initiated from it`. Default false.
- `on_terminate_annotation` - (Optional) Boolean. Enables the
policy `Once a build is terminated, terminate all child builds initiated from it`. Default false.

---

Expand All @@ -178,30 +194,39 @@ resource "codefresh_pipeline" "test" {
- `ignore_branch` - (Optional) Boolean. See table below for usage.

The following table presents how to configure this block based on the options available in the UI:
| Option Description | Value Selected | on_create_branch | branch_name | ignore_trigger | ignore_branch |
| ----------------------------------------------------------------------------- |:------------------------:|:----------------:|:-----------:|---------------:| -------------:|
| Once a build is created terminate previous builds from the same branch | Disabled | Omit | N/A | N/A | N/A |
| Once a build is created terminate previous builds from the same branch | From the SAME trigger | Defined | N/A | false | N/A |
| Once a build is created terminate previous builds from the same branch | From ANY trigger | Defined | N/A | true | N/A |
| Once a build is created terminate previous builds only from a specific branch | Disabled | Omit | N/A | N/A | N/A |
| Once a build is created terminate previous builds only from a specific branch | From the SAME trigger | Defined | Regex | false | N/A |
| Once a build is created terminate previous builds only from a specific branch | From ANY trigger | Defined | Regex | true | N/A |
| Once a build is created, terminate all other running builds | Disabled | Omit | N/A | N/A | N/A |
| Once a build is created, terminate all other running builds | From the SAME trigger | Defined | N/A | false | true |
| Once a build is created, terminate all other running builds | From ANY trigger | Defined | N/A | true | true |
| Option Description | Value Selected | on_create_branch | branch_name | ignore_trigger | ignore_branch |
| ----------------------------------------------------------------------------- |:------------------------:|:
----------------:|:-----------:|---------------:| -------------:|
| Once a build is created terminate previous builds from the same branch | Disabled | Omit | N/A | N/A | N/A |
| Once a build is created terminate previous builds from the same branch | From the SAME trigger | Defined | N/A | false
| N/A |
| Once a build is created terminate previous builds from the same branch | From ANY trigger | Defined | N/A | true | N/A
|
| Once a build is created terminate previous builds only from a specific branch | Disabled | Omit | N/A | N/A | N/A |
| Once a build is created terminate previous builds only from a specific branch | From the SAME trigger | Defined |
Regex | false | N/A |
| Once a build is created terminate previous builds only from a specific branch | From ANY trigger | Defined | Regex |
true | N/A |
| Once a build is created, terminate all other running builds | Disabled | Omit | N/A | N/A | N/A |
| Once a build is created, terminate all other running builds | From the SAME trigger | Defined | N/A | false | true |
| Once a build is created, terminate all other running builds | From ANY trigger | Defined | N/A | true | true |

---

`options` supports the following:

- `keep_pvcs_for_pending_approval` - (Optional) Boolean for the Settings under pending approval: `When build enters "Pending Approval" state, volume should`:
- `keep_pvcs_for_pending_approval` - (Optional) Boolean for the Settings under pending
approval: `When build enters "Pending Approval" state, volume should`:
* Default (attribute not specified): "Use Setting accounts"
* true: "Remain (build remains active)"
* false: "Be removed"
- `pending_approval_concurrency_applied` - (Optional) Boolean for the Settings under pending approval: `Pipeline concurrency policy: Builds on "Pending Approval" state should be`:
- `pending_approval_concurrency_applied` - (Optional) Boolean for the Settings under pending
approval: `Pipeline concurrency policy: Builds on "Pending Approval" state should be`:
* Default (attribute not specified): "Use Setting accounts"
* true: "Included in concurrency"
* false: "Not included in concurrency"
- `enable_notifications` - (Optional) Boolean. If false the pipeline will not send notifications to Slack and status
updates back to the Git provider. Default false

## Attributes Reference

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/bflad/tfproviderdocs v0.6.0
github.com/bflad/tfproviderlint v0.14.0
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/cenkalti/backoff/v4 v4.1.0
github.com/client9/misspell v0.3.4
github.com/dlclark/regexp2 v1.4.0
github.com/ghodss/yaml v1.0.0
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ github.com/bmatcuk/doublestar v1.2.1 h1:eetYiv8DDYOZcBADY+pRvRytf3Dlz1FhnpvL2FsC
github.com/bmatcuk/doublestar v1.2.1/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
github.com/bombsimon/wsl/v3 v3.0.0 h1:w9f49xQatuaeTJFaNP4SpiWSR5vfT6IstPtM62JjcqA=
github.com/bombsimon/wsl/v3 v3.0.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc=
github.com/cenkalti/backoff v1.1.0 h1:QnvVp8ikKCDWOsFheytRCoYWYPO/ObCTBGxT19Hc+yE=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v4 v4.1.0 h1:c8LkOFQTzuO0WBM/ae5HdGQuZPfPxp7lqBRwQRm4fSc=
github.com/cenkalti/backoff/v4 v4.1.0/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
Expand Down