Skip to content

Commit 1a9ef92

Browse files
authored
Merge pull request #1188 from timofurrer/feature/gitlab-15.2
Officially support GitLab 15.0, 15.1 and 15.2
2 parents 348b949 + f9989cb commit 1a9ef92

File tree

7 files changed

+21
-24
lines changed

7 files changed

+21
-24
lines changed

.github/workflows/pr-acceptance-ce.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
strategy:
3535
fail-fast: false
3636
matrix:
37-
gitlab-version: ["14.10.4-ce.0", "15.0.3-ce.0", "15.1.0-ce.0"]
37+
gitlab-version: ["15.0.4-ce.0", "15.1.3-ce.0", "15.2.0-ce.0"]
3838
steps:
3939
- uses: actions/setup-go@v3
4040
with:

.github/workflows/pr-acceptance-ee.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
strategy:
6969
fail-fast: false
7070
matrix:
71-
gitlab-version: ["14.10.4-ee.0", "15.0.3-ee.0", "15.1.0-ee.0"]
71+
gitlab-version: ["15.0.4-ee.0", "15.1.3-ee.0", "15.2.0-ee.0"]
7272
steps:
7373
- uses: actions/setup-go@v3
7474
with:

.github/workflows/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
strategy:
9898
fail-fast: false
9999
matrix:
100-
gitlab-version: ["14.10.4-ce.0", "15.0.3-ce.0", "15.1.0-ce.0"]
100+
gitlab-version: ["15.0.4-ce.0", "15.1.3-ce.0", "15.2.0-ce.0"]
101101
steps:
102102
- uses: actions/setup-go@v3
103103
with:
@@ -121,7 +121,7 @@ jobs:
121121
strategy:
122122
fail-fast: false
123123
matrix:
124-
gitlab-version: ["14.10.4-ee.0", "15.0.3-ee.0", "15.1.0-ee.0"]
124+
gitlab-version: ["15.0.4-ee.0", "15.1.3-ee.0", "15.2.0-ee.0"]
125125
steps:
126126
- uses: actions/setup-go@v3
127127
with:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.17.0 (Unreleased)
2+
3+
This release was tested against GitLab 15.0, 15.1 and 15.2 for both CE and EE.
4+
15
## 3.16.1 (2022-07-11)
26

37
This release was tested against GitLab 14.10, 15.0 and 15.1 for both CE and EE.

docs/resources/service_jira.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ resource "gitlab_service_jira" "jira" {
4646
- `comment_on_event_enabled` (Boolean) Enable comments inside Jira issues on each GitLab event (commit / merge request)
4747
- `commit_events` (Boolean) Enable notifications for commit events
4848
- `issues_events` (Boolean) Enable notifications for issues events.
49-
- `jira_issue_transition_id` (String) The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (Administration > Issues > Workflows) by selecting View under Operations of the desired workflow of your project. By default, this ID is set to 2. **Note**: importing this field is currently not supported.
49+
- `jira_issue_transition_id` (String) The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (Administration > Issues > Workflows) by selecting View under Operations of the desired workflow of your project. By default, this ID is set to 2. *Note**: importing this field is only supported since GitLab 15.2.
5050
- `job_events` (Boolean) Enable notifications for job events.
5151
- `merge_requests_events` (Boolean) Enable notifications for merge request events
5252
- `note_events` (Boolean) Enable notifications for note events.

internal/provider/resource_gitlab_service_jira.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var _ = registerResource("gitlab_service_jira", func() *schema.Resource {
8181
Sensitive: true,
8282
},
8383
"jira_issue_transition_id": {
84-
Description: "The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (Administration > Issues > Workflows) by selecting View under Operations of the desired workflow of your project. By default, this ID is set to 2. **Note**: importing this field is currently not supported.",
84+
Description: "The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (Administration > Issues > Workflows) by selecting View under Operations of the desired workflow of your project. By default, this ID is set to 2. *Note**: importing this field is only supported since GitLab 15.2.",
8585
Type: schema.TypeString,
8686
Optional: true,
8787
},
@@ -185,10 +185,12 @@ func resourceGitlabServiceJiraRead(ctx context.Context, d *schema.ResourceData,
185185
d.Set("api_url", jiraService.Properties.APIURL)
186186
d.Set("username", jiraService.Properties.Username)
187187
d.Set("project_key", jiraService.Properties.ProjectKey)
188-
// FIXME: The API or go-gitlab doesn't return `jira_issue_transition_id` properly,
189-
// therefore we don't overwrite the value set in the config, in case it's not set in the API
190-
// response. This currently impacts the import of this attribute.
191-
if jiraService.Properties.JiraIssueTransitionID != "" {
188+
189+
hasJiraIssueTransitionIDFixed, err := isGitLabVersionAtLeast(ctx, client, "15.2")()
190+
if err != nil {
191+
return diag.Errorf("failed to check if `jira_issue_transition_id` is properly supported in GitLab version: %v", err)
192+
}
193+
if hasJiraIssueTransitionIDFixed || jiraService.Properties.JiraIssueTransitionID != "" {
192194
d.Set("jira_issue_transition_id", jiraService.Properties.JiraIssueTransitionID)
193195
}
194196
d.Set("title", jiraService.Title)
@@ -238,14 +240,8 @@ func expandJiraOptions(d *schema.ResourceData) (*gitlab.SetJiraServiceOptions, e
238240
setJiraServiceOptions.CommitEvents = gitlab.Bool(d.Get("commit_events").(bool))
239241
setJiraServiceOptions.MergeRequestsEvents = gitlab.Bool(d.Get("merge_requests_events").(bool))
240242
setJiraServiceOptions.CommentOnEventEnabled = gitlab.Bool(d.Get("comment_on_event_enabled").(bool))
241-
242-
// Set optional properties
243-
if val, ok := d.GetOk("api_url"); ok {
244-
setJiraServiceOptions.APIURL = gitlab.String(val.(string))
245-
}
246-
if val, ok := d.GetOk("jira_issue_transition_id"); ok {
247-
setJiraServiceOptions.JiraIssueTransitionID = gitlab.String(val.(string))
248-
}
243+
setJiraServiceOptions.APIURL = gitlab.String(d.Get("api_url").(string))
244+
setJiraServiceOptions.JiraIssueTransitionID = gitlab.String(d.Get("jira_issue_transition_id").(string))
249245

250246
return &setJiraServiceOptions, nil
251247
}

internal/provider/resource_gitlab_service_jira_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
4040
ResourceName: jiraResourceName,
4141
ImportState: true,
4242
ImportStateVerify: true,
43-
// FIXME: there is a bug in the GitLab API which causes the `jira_issue_transition_id` field
44-
// to be empty in the response. Therefore, we ignore it for now in the import.
43+
// TODO: as soon as we remove support for GitLab < 15.2 we can remove ignoring `jira_issue_transition_id`.
4544
// See https://gitlab.com/gitlab-org/gitlab/-/issues/362437
4645
ImportStateVerifyIgnore: []string{"password", "jira_issue_transition_id"},
4746
},
@@ -65,8 +64,7 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
6564
ResourceName: jiraResourceName,
6665
ImportState: true,
6766
ImportStateVerify: true,
68-
// FIXME: there is a bug in the GitLab API which causes the `jira_issue_transition_id` field
69-
// to be empty in the response. Therefore, we ignore it for now in the import.
67+
// TODO: as soon as we remove support for GitLab < 15.2 we can remove ignoring `jira_issue_transition_id`.
7068
// See https://gitlab.com/gitlab-org/gitlab/-/issues/362437
7169
ImportStateVerifyIgnore: []string{"password", "jira_issue_transition_id"},
7270
},
@@ -89,8 +87,7 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
8987
ResourceName: jiraResourceName,
9088
ImportState: true,
9189
ImportStateVerify: true,
92-
// FIXME: there is a bug in the GitLab API which causes the `jira_issue_transition_id` field
93-
// to be empty in the response. Therefore, we ignore it for now in the import.
90+
// TODO: as soon as we remove support for GitLab < 15.2 we can remove ignoring `jira_issue_transition_id`.
9491
// See https://gitlab.com/gitlab-org/gitlab/-/issues/362437
9592
ImportStateVerifyIgnore: []string{"password", "jira_issue_transition_id"},
9693
},

0 commit comments

Comments
 (0)