Skip to content

Commit 6bc4a6c

Browse files
committed
feat: add resource for Jira integration profile [ENG-5591]
[ENG-5591](https://stacklet.atlassian.net/browse/ENG-5591) ### what add the resource for configuratin the Jira integration profile ### why allow conifuring Jira integration via Terraform ### testing sandbox testing, added acceptance tests ### docs updated here
1 parent d620928 commit 6bc4a6c

20 files changed

+1421
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ from terraform. To enable debug:
194194

195195
## Release process
196196

197-
1. Update the [Changelog][./CHANGELOG.md] with an entry for the new release.
197+
1. Update the [Changelog](./CHANGELOG.md) with an entry for the new release.
198198
2. Create a release tag with `just tag-release X.Y.Z`.
199199
3. Push the tag upstream. This will start the Release workflow which creates
200200
the release on GitHub and builds packages.

docs/data-sources/configuration_profile_jira.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ data "stacklet_configuration_profile_jira" "example" {}
2121

2222
### Read-Only
2323

24+
- `api_key` (String) The encrypted value for the API key.
2425
- `id` (String) The GraphQL Node ID of the configuration profile.
2526
- `profile` (String) The profile name.
2627
- `project` (Block List) Jira project configuration. (see [below for nested schema](#nestedblock--project))
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stacklet_configuration_profile_jira Resource - terraform-provider-stacklet"
4+
subcategory: ""
5+
description: |-
6+
Manage the Jira configuration profile.
7+
The profile is global, adding multiple resources of this kind will cause them to override each other.
8+
---
9+
10+
# stacklet_configuration_profile_jira (Resource)
11+
12+
Manage the Jira configuration profile.
13+
14+
The profile is global, adding multiple resources of this kind will cause them to override each other.
15+
16+
## Example Usage
17+
18+
```terraform
19+
resource "stacklet_configuration_profile_jira" "jira" {
20+
url = "https://example.com/jira"
21+
user = "username"
22+
23+
api_key_wo = "seKret"
24+
api_key_wo_version = "1"
25+
26+
project {
27+
name = "PRJ1"
28+
project = "123"
29+
issue_type = "Issue"
30+
closed_status = "Closed"
31+
}
32+
33+
project {
34+
name = "PRJ2"
35+
project = "456"
36+
issue_type = "Task"
37+
closed_status = "Done"
38+
}
39+
}
40+
```
41+
42+
<!-- schema generated by tfplugindocs -->
43+
## Schema
44+
45+
### Required
46+
47+
> **NOTE**: [Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments) are supported in Terraform 1.11 and later.
48+
49+
- `api_key_wo` (String, Sensitive, [Write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments)) The input value for the API key.
50+
- `api_key_wo_version` (String) The version for the API key. Must be changed to update api_key_wo.
51+
- `user` (String) The Jira instance authentication username.
52+
53+
### Optional
54+
55+
- `project` (Block List) Jira project configuration. (see [below for nested schema](#nestedblock--project))
56+
- `url` (String) The Jira instance URL.
57+
58+
### Read-Only
59+
60+
- `api_key` (String) The encrypted value for the API key, returned by the API.
61+
- `id` (String) The GraphQL Node ID of the configuration profile.
62+
- `profile` (String) The profile name.
63+
64+
<a id="nestedblock--project"></a>
65+
### Nested Schema for `project`
66+
67+
Required:
68+
69+
- `closed_status` (String) The state for closed tickets.
70+
- `issue_type` (String) The type of issue to use for tickets.
71+
- `name` (String) The name of the project.
72+
- `project` (String) The ID of the project.
73+
74+
## Import
75+
76+
Import is supported using the following syntax:
77+
78+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
79+
80+
```shell
81+
terraform import stacklet_configuration_profile_jira.example '' # the resource ID is ignored since it's global
82+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import stacklet_configuration_profile_jira.example '' # the resource ID is ignored since it's global
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
resource "stacklet_configuration_profile_jira" "jira" {
2+
url = "https://example.com/jira"
3+
user = "username"
4+
5+
api_key_wo = "seKret"
6+
api_key_wo_version = "1"
7+
8+
project {
9+
name = "PRJ1"
10+
project = "123"
11+
issue_type = "Issue"
12+
closed_status = "Closed"
13+
}
14+
15+
project {
16+
name = "PRJ2"
17+
project = "456"
18+
issue_type = "Task"
19+
closed_status = "Done"
20+
}
21+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) 2025 - Stacklet, Inc.
2+
3+
package acceptance_tests
4+
5+
import (
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
)
10+
11+
func TestAccConfigurationProfileJiraDataSource(t *testing.T) {
12+
steps := []resource.TestStep{
13+
{
14+
Config: `
15+
resource "stacklet_configuration_profile_jira" "test" {
16+
url = "https://example.atlassian.net"
17+
18+
api_key_wo = "test-api-key"
19+
api_key_wo_version = "1"
20+
21+
project {
22+
name = "Test Project"
23+
project = "TEST"
24+
issue_type = "Task"
25+
closed_status = "Done"
26+
}
27+
}
28+
29+
data "stacklet_configuration_profile_jira" "test" {
30+
depends_on = [stacklet_configuration_profile_jira.test]
31+
}
32+
`,
33+
Check: resource.ComposeAggregateTestCheckFunc(
34+
resource.TestCheckResourceAttrPair("stacklet_configuration_profile_jira.test", "id", "data.stacklet_configuration_profile_jira.test", "id"),
35+
resource.TestCheckResourceAttrPair("stacklet_configuration_profile_jira.test", "profile", "data.stacklet_configuration_profile_jira.test", "profile"),
36+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "url", "https://example.atlassian.net"),
37+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "user", "[email protected]"),
38+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.#", "1"),
39+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.0.name", "Test Project"),
40+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.0.project", "TEST"),
41+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.0.issue_type", "Task"),
42+
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.0.closed_status", "Done"),
43+
),
44+
},
45+
}
46+
runRecordedAccTest(t, "TestAccConfigurationProfileJiraDataSource", steps)
47+
}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
// Copyright (c) 2025 - Stacklet, Inc.
2+
3+
package acceptance_tests
4+
5+
import (
6+
"fmt"
7+
"testing"
8+
9+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
10+
)
11+
12+
func TestAccConfigurationProfileJiraResource(t *testing.T) {
13+
steps := []resource.TestStep{
14+
// Create and Read testing
15+
{
16+
Config: `
17+
resource "stacklet_configuration_profile_jira" "test" {
18+
url = "https://example.atlassian.net"
19+
20+
api_key_wo = "initial-api-key"
21+
api_key_wo_version = "1"
22+
23+
project {
24+
name = "Test Project"
25+
project = "TEST"
26+
issue_type = "Task"
27+
closed_status = "Done"
28+
}
29+
}
30+
`,
31+
Check: resource.ComposeAggregateTestCheckFunc(
32+
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_jira.test", "id"),
33+
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_jira.test", "profile"),
34+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "url", "https://example.atlassian.net"),
35+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "user", "[email protected]"),
36+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "1"),
37+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.#", "1"),
38+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.name", "Test Project"),
39+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.project", "TEST"),
40+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.issue_type", "Task"),
41+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.closed_status", "Done"),
42+
),
43+
},
44+
// ImportState testing
45+
{
46+
ResourceName: "stacklet_configuration_profile_jira.test",
47+
ImportState: true,
48+
ImportStateVerify: true,
49+
ImportStateVerifyIgnore: []string{"api_key_wo", "api_key_wo_version"},
50+
},
51+
// Update and Read testing
52+
{
53+
Config: `
54+
resource "stacklet_configuration_profile_jira" "test" {
55+
url = "https://updated.atlassian.net"
56+
57+
api_key_wo = "updated-api-key"
58+
api_key_wo_version = "1"
59+
60+
project {
61+
name = "Updated Project"
62+
project = "UPD"
63+
issue_type = "Bug"
64+
closed_status = "Closed"
65+
}
66+
}
67+
`,
68+
Check: resource.ComposeAggregateTestCheckFunc(
69+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "url", "https://updated.atlassian.net"),
70+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "user", "[email protected]"),
71+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "1"),
72+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.#", "1"),
73+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.name", "Updated Project"),
74+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.project", "UPD"),
75+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.issue_type", "Bug"),
76+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.closed_status", "Closed"),
77+
),
78+
},
79+
}
80+
runRecordedAccTest(t, "TestAccConfigurationProfileJiraResource", steps)
81+
}
82+
83+
func TestAccConfigurationProfileJiraResource_APIKeyChange(t *testing.T) {
84+
var returnedAPIKey string
85+
86+
steps := []resource.TestStep{
87+
// Initial API key setup
88+
{
89+
Config: `
90+
resource "stacklet_configuration_profile_jira" "test" {
91+
url = "https://example.atlassian.net"
92+
93+
api_key_wo = "initial-api-key"
94+
api_key_wo_version = "1"
95+
96+
project {
97+
name = "Test Project"
98+
project = "TEST"
99+
issue_type = "Task"
100+
closed_status = "Done"
101+
}
102+
}
103+
`,
104+
Check: resource.ComposeAggregateTestCheckFunc(
105+
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_jira.test", "id"),
106+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "1"),
107+
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_jira.test", "api_key"),
108+
resource.TestCheckResourceAttrWith("stacklet_configuration_profile_jira.test", "api_key", func(value string) error {
109+
returnedAPIKey = value
110+
return nil
111+
}),
112+
),
113+
},
114+
// Same version, API key should remain the same
115+
{
116+
Config: `
117+
resource "stacklet_configuration_profile_jira" "test" {
118+
url = "https://example.atlassian.net"
119+
120+
api_key_wo = "changed-api-key-but-same-version"
121+
api_key_wo_version = "1"
122+
123+
project {
124+
name = "Test Project"
125+
project = "TEST"
126+
issue_type = "Task"
127+
closed_status = "Done"
128+
}
129+
}
130+
`,
131+
Check: resource.ComposeAggregateTestCheckFunc(
132+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "1"),
133+
resource.TestCheckResourceAttrWith("stacklet_configuration_profile_jira.test", "api_key", func(value string) error {
134+
if value != returnedAPIKey {
135+
return fmt.Errorf("api_key should not have changed, was %s, now: %s", returnedAPIKey, value)
136+
}
137+
returnedAPIKey = value
138+
return nil
139+
}),
140+
),
141+
},
142+
// Version changed, API key should change
143+
{
144+
Config: `
145+
resource "stacklet_configuration_profile_jira" "test" {
146+
url = "https://example.atlassian.net"
147+
148+
api_key_wo = "updated-api-key"
149+
api_key_wo_version = "2"
150+
151+
project {
152+
name = "Test Project"
153+
project = "TEST"
154+
issue_type = "Task"
155+
closed_status = "Done"
156+
}
157+
}
158+
`,
159+
Check: resource.ComposeAggregateTestCheckFunc(
160+
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "2"),
161+
resource.TestCheckResourceAttrWith("stacklet_configuration_profile_jira.test", "api_key", func(value string) error {
162+
if value == returnedAPIKey {
163+
return fmt.Errorf("api_key should have changed")
164+
}
165+
return nil
166+
}),
167+
),
168+
},
169+
}
170+
runRecordedAccTest(t, "TestAccConfigurationProfileJiraResource_APIKeyChange", steps)
171+
}

0 commit comments

Comments
 (0)