Skip to content

Commit a14799e

Browse files
committed
feat(cockpit): required for retention_days
1 parent 8ba600e commit a14799e

8 files changed

+2269
-410
lines changed

internal/services/cockpit/cockpit_data_source_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,21 @@ func TestAccDataSourceCockpit_Basic(t *testing.T) {
2525
project_id = scaleway_account_project.project.id
2626
name = "my-data-source-metrics"
2727
type = "metrics"
28+
retention_days = 31
2829
}
2930
3031
resource "scaleway_cockpit_source" "logs" {
3132
project_id = scaleway_account_project.project.id
3233
name = "my-data-source-logs"
3334
type = "logs"
35+
retention_days = 7
3436
}
3537
3638
resource "scaleway_cockpit_source" "traces" {
3739
project_id = scaleway_account_project.project.id
3840
name = "my-data-source-traces"
3941
type = "traces"
42+
retention_days = 7
4043
}
4144
4245
resource "scaleway_cockpit_alert_manager" "alert_manager" {

internal/services/cockpit/source.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ func ResourceCockpitSource() *schema.Resource {
4545
},
4646
"retention_days": {
4747
Type: schema.TypeInt,
48-
Optional: true,
49-
Default: 6,
48+
Required: true,
5049
Description: "The number of days to retain data, must be between 1 and 365.",
5150
},
5251
// computed
@@ -93,10 +92,6 @@ func ResourceCockpitSourceCreate(ctx context.Context, d *schema.ResourceData, me
9392
}
9493

9594
retentionDays := uint32(d.Get("retention_days").(int))
96-
if retentionDays == 0 {
97-
retentionDays = 6
98-
}
99-
10095
res, err := api.CreateDataSource(&cockpit.RegionalAPICreateDataSourceRequest{
10196
Region: region,
10297
ProjectID: d.Get("project_id").(string),

internal/services/cockpit/source_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ func TestAccCockpitSource_Basic_metrics(t *testing.T) {
3131
project_id = scaleway_account_project.project.id
3232
name = "my-source"
3333
type = "metrics"
34+
retention_days = 31
3435
}
3536
`,
3637
Check: resource.ComposeTestCheckFunc(
3738
isSourcePresent(tt, "scaleway_cockpit_source.main"),
3839
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "name", "my-source"),
3940
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "type", "metrics"),
4041
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "region", "fr-par"),
41-
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "retention_days", "6"),
42+
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "retention_days", "31"),
4243
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "url"),
4344
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "push_url"),
4445
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "origin"),
@@ -71,6 +72,8 @@ func TestAccCockpitSource_Basic_logs(t *testing.T) {
7172
project_id = scaleway_account_project.project.id
7273
name = "my-source"
7374
type = "logs"
75+
retention_days = 31
76+
7477
}
7578
`,
7679
Check: resource.ComposeTestCheckFunc(

internal/services/cockpit/testdata/cockpit-source-basic-logs.cassette.yaml

Lines changed: 56 additions & 56 deletions
Large diffs are not rendered by default.

internal/services/cockpit/testdata/cockpit-source-basic-metrics.cassette.yaml

Lines changed: 66 additions & 66 deletions
Large diffs are not rendered by default.

internal/services/cockpit/testdata/cockpit-source-retention-days.cassette.yaml

Lines changed: 57 additions & 57 deletions
Large diffs are not rendered by default.

internal/services/cockpit/testdata/cockpit-source-update.cassette.yaml

Lines changed: 116 additions & 116 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)