Skip to content

Commit 5f016b0

Browse files
authored
[T-5361] Add support for optional resource_group_id on source resource (#35)
1 parent f9535bf commit 5f016b0

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ on:
88
- main
99
jobs:
1010
lint:
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-24.04
1212
steps:
1313
- uses: actions/checkout@v3
1414
- uses: actions/setup-go@v4
1515
with:
1616
go-version: '1.23.x'
17+
- uses: hashicorp/setup-terraform@v3
18+
with:
19+
terraform_version: 'latest'
1720
- run: make lint
1821
check_docs:
19-
runs-on: ubuntu-20.04
22+
runs-on: ubuntu-24.04
2023
steps:
2124
- uses: actions/checkout@v3
2225
- uses: actions/setup-go@v4
2326
with:
2427
go-version: '1.23.x'
28+
- uses: hashicorp/setup-terraform@v3
29+
with:
30+
terraform_version: 'latest'
2531
- name: Generate docs automatically
2632
run: make gen
2733
- name: Check no versioned file has been updated

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GOLANGCI_LINT := golangci-lint run --disable-all \
88
-E staticcheck \
99
-E typecheck \
1010
-E unused
11-
VERSION := 0.4
11+
VERSION := 0.5
1212
.PHONY: test build
1313

1414
help:

docs/data-sources/source.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ This Data Source allows you to look up existing Sources using their table name.
7979
- `ubuntu`
8080
- `vector`
8181
- `vercel_integration`
82+
- `resource_group_id` (Number) The ID of the resource group this source belongs to.
8283
- `scrape_frequency_secs` (Number) For scrape platform types, how often to scrape the URLs.
8384
- `scrape_request_basic_auth_password` (String, Sensitive) Basic auth password for scraping.
8485
- `scrape_request_basic_auth_user` (String) Basic auth username for scraping.

docs/resources/source.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ This resource allows you to create, modify, and delete your Sources. For more in
7575
- `live_tail_pattern` (String) Freeform text template for formatting Live tail output with columns wrapped in {column} brackets. Example: "PID: {message_json.pid} {level} {message}"
7676
- `logs_retention` (Number) Data retention for logs in days. There might be additional charges for longer retention.
7777
- `metrics_retention` (Number) Data retention for metrics in days. There might be additional charges for longer retention.
78+
- `resource_group_id` (Number) The ID of the resource group this source belongs to.
7879
- `scrape_frequency_secs` (Number) For scrape platform types, how often to scrape the URLs.
7980
- `scrape_request_basic_auth_password` (String, Sensitive) Basic auth password for scraping.
8081
- `scrape_request_basic_auth_user` (String) Basic auth username for scraping.

internal/provider/resource_source.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ var sourceSchema = map[string]*schema.Schema{
203203
Optional: true,
204204
Computed: true,
205205
},
206+
"resource_group_id": {
207+
Description: "The ID of the resource group this source belongs to.",
208+
Type: schema.TypeInt,
209+
Optional: true,
210+
},
206211
}
207212

208213
func newSourceResource() *schema.Resource {
@@ -239,6 +244,7 @@ type source struct {
239244
ScrapeRequestBasicAuthUser *string `json:"scrape_request_basic_auth_user,omitempty"`
240245
ScrapeRequestBasicAuthPassword *string `json:"scrape_request_basic_auth_password,omitempty"`
241246
DataRegion *string `json:"data_region,omitempty"`
247+
ResourceGroupID *int `json:"resource_group_id,omitempty"`
242248
}
243249

244250
type sourceHTTPResponse struct {
@@ -273,6 +279,7 @@ func sourceRef(in *source) []struct {
273279
{k: "scrape_request_basic_auth_user", v: &in.ScrapeRequestBasicAuthUser},
274280
{k: "scrape_request_basic_auth_password", v: &in.ScrapeRequestBasicAuthPassword},
275281
{k: "data_region", v: &in.DataRegion},
282+
{k: "resource_group_id", v: &in.ResourceGroupID},
276283
}
277284
}
278285

internal/provider/resource_source_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func TestResourceSource(t *testing.T) {
9393
name = "%s"
9494
platform = "%s"
9595
data_region = "eu-hel-1-legacy"
96+
resource_group_id = 123
9697
}
9798
`, name, platform),
9899
Check: resource.ComposeTestCheckFunc(
@@ -102,6 +103,7 @@ func TestResourceSource(t *testing.T) {
102103
resource.TestCheckResourceAttr("logtail_source.this", "token", "generated_by_logtail"),
103104
resource.TestCheckResourceAttr("logtail_source.this", "ingesting_host", "in.logs.betterstack.com"),
104105
resource.TestCheckResourceAttr("logtail_source.this", "data_region", "eu-hel-1-legacy"),
106+
resource.TestCheckResourceAttr("logtail_source.this", "resource_group_id", "123"),
105107
),
106108
},
107109
// Step 2 - update.
@@ -118,6 +120,7 @@ func TestResourceSource(t *testing.T) {
118120
metrics_retention = 60
119121
live_tail_pattern = "{level} {message}"
120122
ingesting_paused = true
123+
resource_group_id = 456
121124
}
122125
`, name, platform),
123126
Check: resource.ComposeTestCheckFunc(
@@ -128,6 +131,7 @@ func TestResourceSource(t *testing.T) {
128131
resource.TestCheckResourceAttr("logtail_source.this", "token", "generated_by_logtail"),
129132
resource.TestCheckResourceAttr("logtail_source.this", "ingesting_host", "in.logs.betterstack.com"),
130133
resource.TestCheckResourceAttr("logtail_source.this", "data_region", "eu-hel-1-legacy"),
134+
resource.TestCheckResourceAttr("logtail_source.this", "resource_group_id", "456"),
131135
),
132136
},
133137
// Step 3 - make no changes, check plan is empty (omitted attributes are not controlled)
@@ -140,6 +144,7 @@ func TestResourceSource(t *testing.T) {
140144
resource "logtail_source" "this" {
141145
name = "%s"
142146
platform = "%s"
147+
resource_group_id = 456
143148
}
144149
`, name, platform),
145150
PlanOnly: true,

0 commit comments

Comments
 (0)