Skip to content

Commit

Permalink
Merge pull request #97 from iLert/feature/deployment-pipeline-gitlab
Browse files Browse the repository at this point in the history
Feature/deployment pipeline gitlab
STLVRTX authored Nov 29, 2024
2 parents 9dc39c5 + 46c57bf commit be30741
Showing 5 changed files with 76 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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 (
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
62 changes: 62 additions & 0 deletions ilert/resource_deployment_pipeline.go
Original file line number Diff line number Diff line change
@@ -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
}

8 changes: 7 additions & 1 deletion website/docs/r/deployment_pipeline.html.markdown
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit be30741

Please sign in to comment.