Skip to content

Commit d1f8688

Browse files
committed
resource/gitlab_service_jira: cleanup api_url for #597.
1 parent 856c59a commit d1f8688

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ var _ = registerResource("gitlab_service_jira", func() *schema.Resource {
5656
ValidateFunc: validateURLFunc,
5757
},
5858
"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.",
5960
Type: schema.TypeString,
6061
Optional: true,
62+
Computed: true,
6163
ValidateFunc: validateURLFunc,
62-
Default: "",
6364
},
6465
"project_key": {
6566
Description: "The short identifier for your JIRA project, all uppercase, e.g., PROJ.",
@@ -188,6 +189,8 @@ func resourceGitlabServiceJiraRead(ctx context.Context, d *schema.ResourceData,
188189
return diag.FromErr(err)
189190
}
190191

192+
log.Printf("[TIMOOOO:] %+v", jiraService)
193+
191194
if v := jiraService.Properties.URL; v != "" {
192195
d.Set("url", v)
193196
}
@@ -253,10 +256,10 @@ func expandJiraOptions(d *schema.ResourceData) (*gitlab.SetJiraServiceOptions, e
253256
setJiraServiceOptions.CommentOnEventEnabled = gitlab.Bool(d.Get("comment_on_event_enabled").(bool))
254257

255258
// Set optional properties
256-
if val := d.Get("api_url"); val != nil {
259+
if val, ok := d.GetOk("api_url"); ok {
257260
setJiraServiceOptions.APIURL = gitlab.String(val.(string))
258261
}
259-
if val := d.Get("jira_issue_transition_id"); val != nil {
262+
if val, ok := d.GetOk("jira_issue_transition_id"); ok {
260263
setJiraServiceOptions.JiraIssueTransitionID = gitlab.String(val.(string))
261264
}
262265

internal/provider/resource_gitlab_service_jira_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
2626
Check: resource.ComposeTestCheckFunc(
2727
testAccCheckGitlabServiceJiraExists(jiraResourceName, &jiraService),
2828
resource.TestCheckResourceAttr(jiraResourceName, "url", "https://test.com"),
29-
resource.TestCheckResourceAttr(jiraResourceName, "api_url", "https://test.com/api"),
3029
resource.TestCheckResourceAttr(jiraResourceName, "username", "user1"),
3130
resource.TestCheckResourceAttr(jiraResourceName, "password", "mypass"),
3231
resource.TestCheckResourceAttr(jiraResourceName, "commit_events", "true"),
@@ -55,7 +54,7 @@ func TestAccGitlabServiceJira_basic(t *testing.T) {
5554
Check: resource.ComposeTestCheckFunc(
5655
testAccCheckGitlabServiceJiraExists(jiraResourceName, &jiraService),
5756
resource.TestCheckResourceAttr(jiraResourceName, "url", "https://test.com"),
58-
resource.TestCheckResourceAttr(jiraResourceName, "api_url", "https://test.com/api"),
57+
resource.TestCheckResourceAttr(jiraResourceName, "api_url", "https://testurl.com/rest"),
5958
resource.TestCheckResourceAttr(jiraResourceName, "username", "user1"),
6059
resource.TestCheckResourceAttr(jiraResourceName, "password", "mypass"),
6160
resource.TestCheckResourceAttr(jiraResourceName, "commit_events", "true"),
@@ -165,7 +164,6 @@ resource "gitlab_project" "foo" {
165164
resource "gitlab_service_jira" "jira" {
166165
project = "${gitlab_project.foo.id}"
167166
url = "https://test.com"
168-
api_url = "https://test.com/api"
169167
username = "user1"
170168
password = "mypass"
171169
commit_events = true

0 commit comments

Comments
 (0)