Skip to content

Commit 48bff9a

Browse files
Merge pull request #7 from form3tech-oss/ng/maintenance
chore: change update tests & improve release process
2 parents 4696f69 + 3e3cd15 commit 48bff9a

15 files changed

+89
-45
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
name: CI
22
on:
3-
push:
43
pull_request:
4+
types:
5+
- synchronize
6+
- opened
7+
- reopened
8+
push:
9+
branches:
10+
- master
511

612
permissions:
713
contents: read

.github/workflows/lint.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
name: golangci-lint
22
on:
3-
push:
43
pull_request:
4+
types:
5+
- synchronize
6+
- opened
7+
- reopened
8+
push:
9+
branches:
10+
- master
511

612
permissions:
713
contents: read

.github/workflows/release.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
name: release
22
on:
33
push:
4-
branches:
5-
- master
64
tags:
7-
- v*.*.*
5+
- "v*.*.*"
86

97
permissions:
108
contents: write
119

1210
jobs:
1311
publish:
14-
if: startsWith(github.ref, 'refs/tags/')
1512
runs-on: ubuntu-latest
1613
steps:
1714
- name: Checkout Code
1815
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
1916
with:
2017
fetch-depth: 0
18+
2119
- name: Setup Golang
2220
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
2321
with:
2422
go-version-file: go.mod
23+
2524
- name: Go releaser
2625
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
2726
with:

chronicle/provider_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package chronicle
22

33
import (
4-
"math/rand"
54
"strings"
65
"testing"
76

87
chronicle "github.com/form3tech-oss/terraform-provider-chronicle/client"
8+
"github.com/google/uuid"
99
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1010
)
1111

@@ -37,11 +37,11 @@ func testAccPreCheck(t *testing.T) {
3737
}
3838

3939
func randString(length int) string {
40-
result := make([]byte, length)
41-
set := "abcdefghijklmnopqrstuvwxyz012346789"
42-
for i := 0; i < length; i++ {
43-
//nolint:all
44-
result[i] = set[rand.Intn(len(set))]
40+
id := uuid.New().String()
41+
42+
if len(id) > length {
43+
id = id[:length]
4544
}
46-
return string(result)
45+
46+
return id
4747
}

chronicle/resource_feed_amazon_s3_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func TestAccChronicleFeedAmazonS3_Basic(t *testing.T) {
4949

5050
func TestAccChronicleFeedAmazonS3_UpdateAuth(t *testing.T) {
5151
displayName := "test" + randString(10)
52+
displayName1 := "test" + randString(10)
5253
logType := "GITHUB"
5354
enabled := "true"
5455
namespace := "test"
@@ -79,7 +80,7 @@ func TestAccChronicleFeedAmazonS3_UpdateAuth(t *testing.T) {
7980
),
8081
},
8182
{
82-
Config: testAccCheckChronicleFeedAmazonS3(displayName, logType, enabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region1, accesKeyID1, secretAccessKey1),
83+
Config: testAccCheckChronicleFeedAmazonS3(displayName1, logType, enabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region1, accesKeyID1, secretAccessKey1),
8384
Check: resource.ComposeTestCheckFunc(
8485
testAccCheckChronicleFeedAmazonS3Exists(rootRef),
8586
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
@@ -101,6 +102,7 @@ func TestAccChronicleFeedAmazonS3_UpdateAuth(t *testing.T) {
101102

102103
func TestAccChronicleFeedAmazonS3_UpdateEnabled(t *testing.T) {
103104
displayName := "test" + randString(10)
105+
displayName1 := "test" + randString(10)
104106
logType := "GITHUB"
105107
enabled := "true"
106108
notEnabled := "false"
@@ -129,7 +131,7 @@ func TestAccChronicleFeedAmazonS3_UpdateEnabled(t *testing.T) {
129131
),
130132
},
131133
{
132-
Config: testAccCheckChronicleFeedAmazonS3(displayName, logType, notEnabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region, accesKeyID, secretAccessKey),
134+
Config: testAccCheckChronicleFeedAmazonS3(displayName1, logType, notEnabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region, accesKeyID, secretAccessKey),
133135
Check: resource.ComposeTestCheckFunc(
134136
testAccCheckChronicleFeedAmazonS3Exists(rootRef),
135137
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
@@ -150,6 +152,7 @@ func TestAccChronicleFeedAmazonS3_UpdateEnabled(t *testing.T) {
150152

151153
func TestAccChronicleFeedAmazonS3_UpdateLogType(t *testing.T) {
152154
displayName := "test" + randString(10)
155+
displayName1 := "test" + randString(10)
153156
logType := "GITHUB"
154157
logType1 := "AWS_CLOUDTRAIL"
155158
notEnabled := "false"
@@ -178,7 +181,7 @@ func TestAccChronicleFeedAmazonS3_UpdateLogType(t *testing.T) {
178181
),
179182
},
180183
{
181-
Config: testAccCheckChronicleFeedAmazonS3(displayName, logType1, notEnabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region, accesKeyID, secretAccessKey),
184+
Config: testAccCheckChronicleFeedAmazonS3(displayName1, logType1, notEnabled, namespace, labels, s3Uri, s3SourceType, sourceDeleteOptions, region, accesKeyID, secretAccessKey),
182185
Check: resource.ComposeTestCheckFunc(
183186
testAccCheckChronicleFeedAmazonS3Exists(rootRef),
184187
resource.TestCheckResourceAttr(rootRef, "log_type", logType1),

chronicle/resource_feed_amazon_sqs_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func TestAccChronicleFeedAmazonSQS_BasicWithS3Auth(t *testing.T) {
104104

105105
func TestAccChronicleFeedAmazonSQS_UpdateAuth(t *testing.T) {
106106
displayName := "test" + randString(10)
107+
displayName1 := "test" + randString(10)
107108
logType := "GITHUB"
108109
enabled := "true"
109110
namespace := "test"
@@ -139,7 +140,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateAuth(t *testing.T) {
139140
),
140141
},
141142
{
142-
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType, enabled, namespace, labels, queue, region1, accountNumber,
143+
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType, enabled, namespace, labels, queue, region1, accountNumber,
143144
sourceDeleteOptions, sqsAccesKeyID1, sqsSecretAccessKey1, s3AccesKeyID1, s3SecretAccessKey1),
144145
Check: resource.ComposeTestCheckFunc(
145146
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
@@ -162,6 +163,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateAuth(t *testing.T) {
162163

163164
func TestAccChronicleFeedAmazonSQS_UpdateEnabled(t *testing.T) {
164165
displayName := "test" + randString(10)
166+
displayName1 := "test" + randString(10)
165167
logType := "GITHUB"
166168
enabled := "true"
167169
notEnabled := "false"
@@ -193,7 +195,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateEnabled(t *testing.T) {
193195
),
194196
},
195197
{
196-
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType, notEnabled, namespace, labels, queue, region, accountNumber,
198+
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType, notEnabled, namespace, labels, queue, region, accountNumber,
197199
sourceDeleteOptions, sqsAccesKeyID, sqsSecretAccessKey, s3AccesKeyID, s3SecretAccessKey),
198200
Check: resource.ComposeTestCheckFunc(
199201
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
@@ -215,6 +217,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateEnabled(t *testing.T) {
215217

216218
func TestAccChronicleFeedAmazonSQS_UpdateLogType(t *testing.T) {
217219
displayName := "test" + randString(10)
220+
displayName1 := "test" + randString(10)
218221
logType := "GITHUB"
219222
logType1 := "AWS_CLOUDTRAIL"
220223
notEnabled := "false"
@@ -246,7 +249,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateLogType(t *testing.T) {
246249
),
247250
},
248251
{
249-
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType1, notEnabled, namespace, labels, queue, region, accountNumber,
252+
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType1, notEnabled, namespace, labels, queue, region, accountNumber,
250253
sourceDeleteOptions, sqsAccesKeyID, sqsSecretAccessKey, s3AccesKeyID, s3SecretAccessKey),
251254
Check: resource.ComposeTestCheckFunc(
252255
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
@@ -268,6 +271,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateLogType(t *testing.T) {
268271

269272
func TestAccChronicleFeedAmazonSQS_UpdateAccountNumber(t *testing.T) {
270273
displayName := "test" + randString(10)
274+
displayName1 := "test" + randString(10)
271275
logType := "GITHUB"
272276
notEnabled := "false"
273277
namespace := "test"
@@ -300,7 +304,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateAccountNumber(t *testing.T) {
300304
),
301305
},
302306
{
303-
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType, notEnabled, namespace, labels, queue, region, accountNumber1,
307+
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType, notEnabled, namespace, labels, queue, region, accountNumber1,
304308
sourceDeleteOptions, sqsAccesKeyID, sqsSecretAccessKey, s3AccesKeyID, s3SecretAccessKey),
305309
Check: resource.ComposeTestCheckFunc(
306310
testAccCheckChronicleFeedAmazonSQSExists(rootRef),
@@ -323,6 +327,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateAccountNumber(t *testing.T) {
323327

324328
func TestAccChronicleFeedAmazonSQS_UpdateRegion(t *testing.T) {
325329
displayName := "test" + randString(10)
330+
displayName1 := "test" + randString(10)
326331
logType := "GITHUB"
327332
notEnabled := "false"
328333
namespace := "test"
@@ -355,7 +360,7 @@ func TestAccChronicleFeedAmazonSQS_UpdateRegion(t *testing.T) {
355360
),
356361
},
357362
{
358-
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName, logType, notEnabled, namespace, labels, queue, region1, accountNumber,
363+
Config: testAccCheckChronicleFeedAmazonSQSWithS3Auth(displayName1, logType, notEnabled, namespace, labels, queue, region1, accountNumber,
359364
sourceDeleteOptions, sqsAccesKeyID, sqsSecretAccessKey, s3AccesKeyID, s3SecretAccessKey),
360365
Check: resource.ComposeTestCheckFunc(
361366
testAccCheckChronicleFeedAmazonSQSExists(rootRef),

chronicle/resource_feed_azure_blobstore_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func TestAccChronicleFeedAzureBlobStore_Basic(t *testing.T) {
4747

4848
func TestAccChronicleFeedAzureBlobStore_UpdateAuth(t *testing.T) {
4949
displayName := "test" + randString(10)
50+
displayName1 := "test" + randString(10)
5051
logType := "GITHUB"
5152
enabled := "true"
5253
namespace := "test"
@@ -73,7 +74,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateAuth(t *testing.T) {
7374
),
7475
},
7576
{
76-
Config: testAccCheckChronicleFeedAzureBlobStore(displayName, logType, enabled, namespace, labels, uri, sourceType, sharedKey1),
77+
Config: testAccCheckChronicleFeedAzureBlobStore(displayName1, logType, enabled, namespace, labels, uri, sourceType, sharedKey1),
7778
Check: resource.ComposeTestCheckFunc(
7879
testAccCheckChronicleFeedAzureBlobStoreExists(rootRef),
7980
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
@@ -97,6 +98,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateEnabled(t *testing.T) {
9798
enabled := "true"
9899
notEnabled := "false"
99100
displayName := "test" + randString(10)
101+
displayName1 := "test" + randString(10)
100102
logType := "GITHUB"
101103
namespace := "test"
102104
labels := `"test"="test"`
@@ -121,7 +123,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateEnabled(t *testing.T) {
121123
),
122124
},
123125
{
124-
Config: testAccCheckChronicleFeedAzureBlobStore(displayName, logType, notEnabled, namespace, labels, uri, sourceType, sharedKey),
126+
Config: testAccCheckChronicleFeedAzureBlobStore(displayName1, logType, notEnabled, namespace, labels, uri, sourceType, sharedKey),
125127
Check: resource.ComposeTestCheckFunc(
126128
testAccCheckChronicleFeedAzureBlobStoreExists(rootRef),
127129
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
@@ -143,6 +145,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateEnabled(t *testing.T) {
143145

144146
func TestAccChronicleFeedAzureBlobStore_UpdateLogType(t *testing.T) {
145147
displayName := "test" + randString(10)
148+
displayName1 := "test" + randString(10)
146149
notEnabled := "false"
147150
logType := "GITHUB"
148151
logType1 := "AWS_CLOUDTRAIL"
@@ -168,7 +171,7 @@ func TestAccChronicleFeedAzureBlobStore_UpdateLogType(t *testing.T) {
168171
),
169172
},
170173
{
171-
Config: testAccCheckChronicleFeedAzureBlobStore(displayName, logType1, notEnabled, namespace, labels, uri, sourceType, sharedKey),
174+
Config: testAccCheckChronicleFeedAzureBlobStore(displayName1, logType1, notEnabled, namespace, labels, uri, sourceType, sharedKey),
172175
Check: resource.ComposeTestCheckFunc(
173176
testAccCheckChronicleFeedAzureBlobStoreExists(rootRef),
174177
resource.TestCheckResourceAttr(rootRef, "log_type", logType1),

chronicle/resource_feed_google_cloud_storage_bucket_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_Basic(t *testing.T) {
4848

4949
func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateBucketSourceType(t *testing.T) {
5050
displayName := "test" + randString(10)
51+
displayName1 := "test" + randString(10)
5152
logType := "ONEPASSWORD"
5253
enabled := "true"
5354
namespace := "test"
@@ -76,7 +77,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateBucketSourceType(t *test
7677
),
7778
},
7879
{
79-
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName, logType, enabled, namespace, labels, bucketUri, bucketSourceType1, sourceDeleteOptions),
80+
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName1, logType, enabled, namespace, labels, bucketUri, bucketSourceType1, sourceDeleteOptions),
8081
Check: resource.ComposeTestCheckFunc(
8182
testAccCheckChronicleFeedGoogleCloudStorageBucketExists(rootRef),
8283
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
@@ -99,6 +100,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateBucketSourceType(t *test
99100

100101
func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateSourceDeletionOptions(t *testing.T) {
101102
displayName := "test" + randString(10)
103+
displayName1 := "test" + randString(10)
102104
logType := "ONEPASSWORD"
103105
enabled := "true"
104106
namespace := "test"
@@ -127,7 +129,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateSourceDeletionOptions(t
127129
),
128130
},
129131
{
130-
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName, logType, enabled, namespace, labels, bucketUri, bucketSourceType, sourceDeleteOptions1),
132+
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName1, logType, enabled, namespace, labels, bucketUri, bucketSourceType, sourceDeleteOptions1),
131133
Check: resource.ComposeTestCheckFunc(
132134
testAccCheckChronicleFeedGoogleCloudStorageBucketExists(rootRef),
133135
resource.TestCheckResourceAttr(rootRef, "log_type", logType),
@@ -150,6 +152,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateSourceDeletionOptions(t
150152

151153
func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateLogType(t *testing.T) {
152154
displayName := "test" + randString(10)
155+
displayName1 := "test" + randString(10)
153156
logType := "ONEPASSWORD"
154157
logType1 := "AWS_CLOUDTRAIL"
155158
enabled := "true"
@@ -178,7 +181,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateLogType(t *testing.T) {
178181
),
179182
},
180183
{
181-
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName, logType1, enabled, namespace, labels, bucketUri, bucketSourceType, sourceDeleteOptions),
184+
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName1, logType1, enabled, namespace, labels, bucketUri, bucketSourceType, sourceDeleteOptions),
182185
Check: resource.ComposeTestCheckFunc(
183186
testAccCheckChronicleFeedGoogleCloudStorageBucketExists(rootRef),
184187
resource.TestCheckResourceAttr(rootRef, "log_type", logType1),
@@ -201,6 +204,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateLogType(t *testing.T) {
201204

202205
func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateNamespace(t *testing.T) {
203206
displayName := "test" + randString(10)
207+
displayName1 := "test" + randString(10)
204208
logType := "ONEPASSWORD"
205209
enabled := "true"
206210
namespace := "test"
@@ -229,7 +233,7 @@ func TestAccChronicleFeedGoogleCloudStorageBucket_UpdateNamespace(t *testing.T)
229233
),
230234
},
231235
{
232-
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName, logType, enabled, namespace1, labels, bucketUri, bucketSourceType, sourceDeleteOptions),
236+
Config: testAccCheckChronicleFeedGoogleCloudStorageBucket(displayName1, logType, enabled, namespace1, labels, bucketUri, bucketSourceType, sourceDeleteOptions),
233237
Check: resource.ComposeTestCheckFunc(
234238
testAccCheckChronicleFeedGoogleCloudStorageBucketExists(rootRef),
235239
resource.TestCheckResourceAttr(rootRef, "log_type", logType),

chronicle/resource_feed_microsoft_office_365_management_activity_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_Basic(t *testing.T
5050

5151
func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateAuth(t *testing.T) {
5252
displayName := "testtf" + randString(10)
53+
displayName1 := "testf" + randString(10)
5354
enabled := "true"
5455
namespace := "test"
5556
labels := `"test"="test"`
@@ -80,7 +81,7 @@ func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateAuth(t *test
8081
),
8182
},
8283
{
83-
Config: testAccCheckChronicleFeedMicrosoftOffice365ManagementActivity(displayName, enabled, namespace, labels, hostname, tenantID, contentType, clientID1, clientSecret1),
84+
Config: testAccCheckChronicleFeedMicrosoftOffice365ManagementActivity(displayName1, enabled, namespace, labels, hostname, tenantID, contentType, clientID1, clientSecret1),
8485
Check: resource.ComposeTestCheckFunc(
8586
testAccCheckChronicleFeedMicrosoftOffice365ManagementActivityExists(rootRef),
8687
resource.TestCheckResourceAttr(rootRef, "enabled", enabled),
@@ -104,6 +105,7 @@ func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateAuth(t *test
104105

105106
func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateEnabled(t *testing.T) {
106107
displayName := "testtf" + randString(10)
108+
displayName1 := "testf" + randString(10)
107109
enabled := "true"
108110
notEnabled := "false"
109111
namespace := "test"
@@ -133,7 +135,7 @@ func TestAccChronicleFeedMicrosoftOffice365ManagementActivity_UpdateEnabled(t *t
133135
),
134136
},
135137
{
136-
Config: testAccCheckChronicleFeedMicrosoftOffice365ManagementActivity(displayName, notEnabled, namespace, labels, hostname, tenantID, contentType, clientID, clientSecret),
138+
Config: testAccCheckChronicleFeedMicrosoftOffice365ManagementActivity(displayName1, notEnabled, namespace, labels, hostname, tenantID, contentType, clientID, clientSecret),
137139
Check: resource.ComposeTestCheckFunc(
138140
testAccCheckChronicleFeedMicrosoftOffice365ManagementActivityExists(rootRef),
139141
resource.TestCheckResourceAttr(rootRef, "enabled", notEnabled),

0 commit comments

Comments
 (0)