diff --git a/CHANGELOG.md b/CHANGELOG.md index 05c71de..c1b13a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 29.11.2024, Version 2.11.1 + +- feature/deployment-pipeline-gitlab in [#97](https://github.com/iLert/terraform-provider-ilert/pull/97) + ## 17.11.2024, Version 2.11.0 - feature/deployment-pipeline in [#96](https://github.com/iLert/terraform-provider-ilert/pull/96) diff --git a/go.mod b/go.mod index b3ec654..997b110 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.25.0 - github.com/iLert/ilert-go/v3 v3.11.0 + github.com/iLert/ilert-go/v3 v3.11.1 ) require ( diff --git a/go.sum b/go.sum index 23834a4..c9fea63 100644 --- a/go.sum +++ b/go.sum @@ -103,8 +103,8 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/iLert/ilert-go/v3 v3.11.0 h1:h2FFGRO2fIaI6Ot24KXQ2/idUVBpcY2YBXbZaIUDiUU= -github.com/iLert/ilert-go/v3 v3.11.0/go.mod h1:xHJ8qdmthK4HExcQOd3V5JARed/EBKTdX86MqrJ1yJ0= +github.com/iLert/ilert-go/v3 v3.11.1 h1:IQYL62PfaDFwrJuH5jZjjoqzgZ0ru0UmM7fw/GWdHf0= +github.com/iLert/ilert-go/v3 v3.11.1/go.mod h1:xHJ8qdmthK4HExcQOd3V5JARed/EBKTdX86MqrJ1yJ0= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= diff --git a/ilert/resource_deployment_pipeline.go b/ilert/resource_deployment_pipeline.go index ac0f3cd..c0eb415 100644 --- a/ilert/resource_deployment_pipeline.go +++ b/ilert/resource_deployment_pipeline.go @@ -88,6 +88,32 @@ func resourceDeploymentPipeline() *schema.Resource { }, }, }, + "gitlab": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "branch_filter": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "event_filter": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, }, CreateContext: resourceDeploymentPipelineCreate, ReadContext: resourceDeploymentPipelineRead, @@ -158,6 +184,33 @@ func buildDeploymentPipeline(d *schema.ResourceData) (*ilert.DeploymentPipeline, } } + if val, ok := d.GetOk("gitlab"); ok && integrationType == ilert.DeploymentPipelineIntegrationType.GitLab { + vL := val.([]interface{}) + if len(vL) > 0 { + v := vL[0].(map[string]interface{}) + params := &ilert.DeploymentPipelineGitLabParams{} + if vL, ok := v["branch_filter"].([]interface{}); ok && len(vL) > 0 { + sL := make([]string, 0) + for _, m := range vL { + if v, ok := m.(string); ok && v != "" { + sL = append(sL, v) + } + } + params.BranchFilters = sL + } + if vL, ok := v["event_filter"].([]interface{}); ok && len(vL) > 0 { + sL := make([]string, 0) + for _, m := range vL { + if v, ok := m.(string); ok && v != "" { + sL = append(sL, v) + } + } + params.EventFilters = sL + } + deploymentPipeline.Params = params + } + } + return deploymentPipeline, nil } @@ -266,6 +319,15 @@ func resourceDeploymentPipelineRead(ctx context.Context, d *schema.ResourceData, }) } + if result.DeploymentPipeline.IntegrationType == ilert.DeploymentPipelineIntegrationType.GitLab { + d.Set("gitlab", []interface{}{ + map[string]interface{}{ + "branch_filter": result.DeploymentPipeline.Params.BranchFilters, + "event_filter": result.DeploymentPipeline.Params.EventFilters, + }, + }) + } + return nil } diff --git a/website/docs/r/deployment_pipeline.html.markdown b/website/docs/r/deployment_pipeline.html.markdown index b440ff0..646289e 100644 --- a/website/docs/r/deployment_pipeline.html.markdown +++ b/website/docs/r/deployment_pipeline.html.markdown @@ -28,13 +28,14 @@ resource "ilert_deployment_pipeline" "example" { The following arguments are supported: - `name` - (Required) The name of the deployment pipeline. -- `integration_type` - (Required) The integration type of the deployment pipeline. Allowed values are `GITHUB` or `API`. +- `integration_type` - (Required) The integration type of the deployment pipeline. Allowed values are `GITHUB`, `GITLAB` or `API`. - `integration_key` - (Computed) The integration key of the deployment pipeline. - `team` - (Optional) One or more [team](#team-arguments) blocks. - `created_at` - (Computed) The creation date of the deployment pipeline. - `updated_at` - (Computed) The latest date the deployment pipeline was updated at. - `integration_url` - (Computed) The integration url of the deployment pipeline. Deployment events are sent to this URL. - `github` - The [github](#github-arguments) block allows configuring parameters for GitHub. +- `gitlab` - The [gitlab](#gitlab-arguments) block allows configuring parameters for GitLab. #### Team Arguments @@ -46,6 +47,11 @@ The following arguments are supported: - `branch_filter` - One or more branch filters to only accept events on specified branches. - `event_filter` - One or more event filters to only accept events on specified actions. Allowed values are `pull_request`, `push` and `release`. +#### GitLab Arguments + +- `branch_filter` - One or more branch filters to only accept events on specified branches. +- `event_filter` - One or more event filters to only accept events on specified actions. Allowed values are `Merge Request Hook`, `Push Hook` and `Release Hook`. + ## Import Deployment pipelines can be imported using the `id`, e.g.