Skip to content

Commit 97e3975

Browse files
authored
Merge pull request #597 from grv87/feature/jira_missing_options
feat: add api_url option for Jira service
2 parents 2b3e9c2 + d1f8688 commit 97e3975

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

docs/resources/service_jira.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ resource "gitlab_service_jira" "jira" {
3939

4040
### Optional
4141

42+
- **api_url** (String) The base URL to the Jira instance API. Web URL value is used if not set. For example, https://jira-api.example.com.
4243
- **comment_on_event_enabled** (Boolean) Enable comments inside Jira issues on each GitLab event (commit / merge request)
4344
- **commit_events** (Boolean) Enable notifications for commit events
4445
- **id** (String) The ID of this resource.

internal/provider/resource_gitlab_service_jira.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ var _ = registerResource("gitlab_service_jira", func() *schema.Resource {
5555
Required: true,
5656
ValidateFunc: validateURLFunc,
5757
},
58+
"api_url": {
59+
Description: "The base URL to the Jira instance API. Web URL value is used if not set. For example, https://jira-api.example.com.",
60+
Type: schema.TypeString,
61+
Optional: true,
62+
Computed: true,
63+
ValidateFunc: validateURLFunc,
64+
},
5865
"project_key": {
5966
Description: "The short identifier for your JIRA project, all uppercase, e.g., PROJ.",
6067
Type: schema.TypeString,
@@ -182,9 +189,14 @@ func resourceGitlabServiceJiraRead(ctx context.Context, d *schema.ResourceData,
182189
return diag.FromErr(err)
183190
}
184191

192+
log.Printf("[TIMOOOO:] %+v", jiraService)
193+
185194
if v := jiraService.Properties.URL; v != "" {
186195
d.Set("url", v)
187196
}
197+
if v := jiraService.Properties.APIURL; v != "" {
198+
d.Set("api_url", v)
199+
}
188200
if v := jiraService.Properties.Username; v != "" {
189201
d.Set("username", v)
190202
}
@@ -244,7 +256,10 @@ func expandJiraOptions(d *schema.ResourceData) (*gitlab.SetJiraServiceOptions, e
244256
setJiraServiceOptions.CommentOnEventEnabled = gitlab.Bool(d.Get("comment_on_event_enabled").(bool))
245257

246258
// Set optional properties
247-
if val := d.Get("jira_issue_transition_id"); val != nil {
259+
if val, ok := d.GetOk("api_url"); ok {
260+
setJiraServiceOptions.APIURL = gitlab.String(val.(string))
261+
}
262+
if val, ok := d.GetOk("jira_issue_transition_id"); ok {
248263
setJiraServiceOptions.JiraIssueTransitionID = gitlab.String(val.(string))
249264
}
250265

internal/provider/resource_gitlab_service_jira_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
3939
Check: resource.ComposeTestCheckFunc(
4040
testAccCheckGitlabServiceJiraExists(jiraResourceName, &jiraService),
4141
resource.TestCheckResourceAttr(jiraResourceName, "url", "https://testurl.com"),
42+
resource.TestCheckResourceAttr(jiraResourceName, "api_url", "https://testurl.com/rest"),
4243
resource.TestCheckResourceAttr(jiraResourceName, "username", "user2"),
4344
resource.TestCheckResourceAttr(jiraResourceName, "password", "mypass_update"),
4445
resource.TestCheckResourceAttr(jiraResourceName, "jira_issue_transition_id", "3"),
@@ -53,6 +54,7 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
5354
Check: resource.ComposeTestCheckFunc(
5455
testAccCheckGitlabServiceJiraExists(jiraResourceName, &jiraService),
5556
resource.TestCheckResourceAttr(jiraResourceName, "url", "https://test.com"),
57+
resource.TestCheckResourceAttr(jiraResourceName, "api_url", "https://testurl.com/rest"),
5658
resource.TestCheckResourceAttr(jiraResourceName, "username", "user1"),
5759
resource.TestCheckResourceAttr(jiraResourceName, "password", "mypass"),
5860
resource.TestCheckResourceAttr(jiraResourceName, "commit_events", "true"),
@@ -184,6 +186,7 @@ resource "gitlab_project" "foo" {
184186
resource "gitlab_service_jira" "jira" {
185187
project = "${gitlab_project.foo.id}"
186188
url = "https://testurl.com"
189+
api_url = "https://testurl.com/rest"
187190
username = "user2"
188191
password = "mypass_update"
189192
jira_issue_transition_id = "3"

0 commit comments

Comments
 (0)