Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 docs/data-sources/metric.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data "launchdarkly_metric" "example" {
### Read-Only

- `analysis_type` (String) The method for analyzing metric events. Available choices are `mean` and `percentile`.
- `archived` (Boolean) Whether the metric is archived.
- `description` (String) The description of the metric's purpose.
- `event_key` (String) The event key for your metric (if custom metric)
- `id` (String) The ID of this resource.
Expand Down
1 change: 1 addition & 0 deletions 1 docs/resources/metric.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ resource "launchdarkly_metric" "example" {
### Optional

- `analysis_type` (String) The method for analyzing metric events. Available choices are `mean` and `percentile`.
- `archived` (Boolean) Whether the metric is archived.
- `description` (String) The description of the metric's purpose.
- `event_key` (String) The event key for your metric (if custom metric)
- `include_units_without_events` (Boolean) Include units that did not send any events and set their value to 0.
Expand Down
2 changes: 1 addition & 1 deletion 2 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
)

require (
github.com/launchdarkly/api-client-go/v17 v17.1.0
github.com/launchdarkly/api-client-go/v17 v17.2.0
golang.org/x/sync v0.16.0
)

Expand Down
2 changes: 2 additions & 0 deletions 2 go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+
github.com/kyoh86/exportloopref v0.1.8/go.mod h1:1tUcJeiioIs7VWe5gcOObrux3lb66+sBqGZrRkMwPgg=
github.com/launchdarkly/api-client-go/v17 v17.1.0 h1:IbR5UDLKBmff0eRBSD3UgVDfgnifOepBIe4gqivMaec=
github.com/launchdarkly/api-client-go/v17 v17.1.0/go.mod h1:lMTmhEjepXfam8xm8b0ERBJbV9g8vdu9nbKueDXcB5o=
github.com/launchdarkly/api-client-go/v17 v17.2.0 h1:5CJxDaL7ZgqALAcohNUMlV7hfXR65s2czZ4XmZjW/qI=
github.com/launchdarkly/api-client-go/v17 v17.2.0/go.mod h1:lMTmhEjepXfam8xm8b0ERBJbV9g8vdu9nbKueDXcB5o=
github.com/ldez/gomoddirectives v0.2.2/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0=
github.com/ldez/tagliatelle v0.3.0/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88=
github.com/leonklingele/grouper v1.1.0/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY=
Expand Down
121 changes: 121 additions & 0 deletions 121 launchdarkly/data_source_launchdarkly_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,124 @@ func TestAccDataSourceMetric_exists(t *testing.T) {
},
})
}

func TestAccDataSourceMetric_ArchivedField(t *testing.T) {
accTest := os.Getenv("TF_ACC")
if accTest == "" {
t.SkipNow()
}
client, err := newClient(os.Getenv(LAUNCHDARKLY_ACCESS_TOKEN), os.Getenv(LAUNCHDARKLY_API_HOST), false, DEFAULT_HTTP_TIMEOUT_S, DEFAULT_MAX_CONCURRENCY)
require.NoError(t, err)
projectKey := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
projectBody := ldapi.ProjectPost{
Name: "Terraform Metric Archived Test Project",
Key: projectKey,
}
project, err := testAccProjectScaffoldCreate(client, projectBody)
require.NoError(t, err)

defer func() {
err := testAccProjectScaffoldDelete(client, projectKey)
require.NoError(t, err)
}()

// Create archived metric (without Archived field since API client doesn't support it yet)
archivedMetricKey := "archived-metric"
archivedMetricName := "Archived Test Metric"
archivedMetricDescription := "Test metric for archived field testing"
archivedUrlKind := "substring"
archivedUrlSubstring := "archived-test"
archivedMetricBody := ldapi.MetricPost{
Name: &archivedMetricName,
Key: archivedMetricKey,
Description: ldapi.PtrString(archivedMetricDescription),
Kind: "pageview",
Tags: []string{"test", "archived"},
Urls: []ldapi.UrlPost{
{
Kind: &archivedUrlKind,
Substring: &archivedUrlSubstring,
},
},
}
// Create archived metric directly without scaffold (to avoid duplicate project creation)
_, _, err = client.ld.MetricsApi.PostMetric(client.ctx, project.Key).MetricPost(archivedMetricBody).Execute()
require.NoError(t, err)

// Create non-archived metric (without Archived field since API client doesn't support it yet)
nonArchivedMetricKey := "non-archived-metric"
nonArchivedMetricName := "Non-Archived Test Metric"
nonArchivedMetricDescription := "Test metric for non-archived field testing"
nonArchivedUrlKind := "substring"
nonArchivedUrlSubstring := "non-archived-test"
nonArchivedMetricBody := ldapi.MetricPost{
Name: &nonArchivedMetricName,
Key: nonArchivedMetricKey,
Description: ldapi.PtrString(nonArchivedMetricDescription),
Kind: "pageview",
Tags: []string{"test", "non-archived"},
Urls: []ldapi.UrlPost{
{
Kind: &nonArchivedUrlKind,
Substring: &nonArchivedUrlSubstring,
},
},
}
// Create non-archived metric directly without scaffold (to avoid duplicate project creation)
_, _, err = client.ld.MetricsApi.PostMetric(client.ctx, project.Key).MetricPost(nonArchivedMetricBody).Execute()
require.NoError(t, err)

// Test data source configurations
testAccDataSourceMetricArchived := `
data "launchdarkly_metric" "archived" {
key = "%s"
project_key = "%s"
}
`

testAccDataSourceMetricNonArchived := `
data "launchdarkly_metric" "non_archived" {
key = "%s"
project_key = "%s"
}
`

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
// Test reading archived metric (currently returns false since API client doesn't support Archived field yet)
{
Config: fmt.Sprintf(testAccDataSourceMetricArchived, archivedMetricKey, project.Key),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", KEY, archivedMetricKey),
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", NAME, "Archived Test Metric"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", PROJECT_KEY, project.Key),
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", KIND, "pageview"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", ARCHIVED, "false"), // Default value until API client supports Archived field
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", "tags.0", "test"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", "tags.1", "archived"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", "urls.0.kind", "substring"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.archived", "urls.0.substring", "archived-test"),
),
},
// Test reading non-archived metric
{
Config: fmt.Sprintf(testAccDataSourceMetricNonArchived, nonArchivedMetricKey, project.Key),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", KEY, nonArchivedMetricKey),
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", NAME, "Non-Archived Test Metric"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", PROJECT_KEY, project.Key),
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", KIND, "pageview"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", ARCHIVED, "false"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", "tags.0", "test"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", "tags.1", "non-archived"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", "urls.0.kind", "substring"),
resource.TestCheckResourceAttr("data.launchdarkly_metric.non_archived", "urls.0.substring", "non-archived-test"),
),
},
},
})
}
7 changes: 7 additions & 0 deletions 7 launchdarkly/metrics_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@
Computed: true,
Description: "Version of the metric",
},
ARCHIVED: {
Type: schema.TypeBool,
Optional: !isDataSource,
Computed: isDataSource,
Description: "Whether the metric is archived.",
},
}

if isDataSource {
Expand Down Expand Up @@ -210,6 +216,7 @@
_ = d.Set(ANALYSIS_TYPE, metric.AnalysisType)
_ = d.Set(PERCENTILE_VALUE, metric.PercentileValue)
_ = d.Set(VERSION, metric.Version)
_ = d.Set(ARCHIVED, metric.Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Build

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / generate

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccProject)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccProject)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlagEnvironment)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlagEnvironment)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccEnvironment)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccEnvironment)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccMetric)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccMetric)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccDestination)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccDestination)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccSegment)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccSegment)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccCustomRole)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccCustomRole)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccWebhook)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccWebhook)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeam_)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeam_)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccAuditLogSubscription)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_UpdateGeneric)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlag_)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccAuditLogSubscription)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_UpdateGeneric)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlag_)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateGeneric)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateGeneric)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamRoleMapping_)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamRoleMapping_)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFlagTrigger)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFlagTrigger)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccRelayProxy)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccRelayProxy)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

Check failure on line 219 in launchdarkly/metrics_helper.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateWithCustomRole)

metric.Archived undefined (type *ldapi.MetricRep has no field or method Archived)

d.SetId(projectKey + "/" + key)

Expand Down
4 changes: 4 additions & 0 deletions 4 launchdarkly/resource_launchdarkly_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
analysisType := d.Get(ANALYSIS_TYPE).(string)
includeUnitsWithoutEvents := d.Get(INCLUDE_UNITS_WITHOUT_EVENTS).(bool)
eventDefaultDisabled := !includeUnitsWithoutEvents
archived := d.Get(ARCHIVED).(bool)

metric := ldapi.MetricPost{
Name: &name,
Expand All @@ -210,7 +211,7 @@
Description: &description,
Tags: tags,
Kind: kind,
IsActive: &isActive,

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Build

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / generate

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccProject)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccProject)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlagEnvironment)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlagEnvironment)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccEnvironment)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccEnvironment)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccMetric)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccMetric)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccDestination)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccDestination)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccSegment)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccSegment)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccCustomRole)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccCustomRole)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccWebhook)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccWebhook)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeam_)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeam_)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccAuditLogSubscription)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_UpdateGeneric)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlag_)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccAuditLogSubscription)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_UpdateGeneric)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlag_)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateGeneric)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateGeneric)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamRoleMapping_)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamRoleMapping_)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFlagTrigger)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFlagTrigger)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccRelayProxy)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccRelayProxy)

unknown field IsActive in struct literal of type ldapi.MetricPost

Check failure on line 214 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateWithCustomRole)

unknown field IsActive in struct literal of type ldapi.MetricPost
IsNumeric: &isNumeric,
Selector: &selector,
Urls: urls,
Expand All @@ -220,6 +221,7 @@
UnitAggregationType: &unitAggregationType,
AnalysisType: &analysisType,
EventDefault: &ldapi.MetricEventDefaultRep{Disabled: &eventDefaultDisabled},
Archived: &archived,

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Build

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / generate

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccProject)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccProject)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlagEnvironment)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlagEnvironment)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccEnvironment)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccEnvironment)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccMetric)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccMetric)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccDestination)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccDestination)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccSegment)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccSegment)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccCustomRole)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccCustomRole)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccWebhook)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccWebhook)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeam_)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeam_)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccAuditLogSubscription)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_UpdateGeneric)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlag_)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccAuditLogSubscription)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_UpdateGeneric)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFeatureFlag_)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateGeneric)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateGeneric)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamRoleMapping_)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamRoleMapping_)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFlagTrigger)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccFlagTrigger)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccRelayProxy)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccRelayProxy)

unknown field Archived in struct literal of type ldapi.MetricPost

Check failure on line 224 in launchdarkly/resource_launchdarkly_metric.go

View workflow job for this annotation

GitHub Actions / Acceptance Tests (TestAccTeamMember_CreateWithCustomRole)

unknown field Archived in struct literal of type ldapi.MetricPost
}
percentileValueData, hasPercentile := d.GetOk(PERCENTILE_VALUE)
if hasPercentile {
Expand Down Expand Up @@ -310,6 +312,7 @@
unitAggregationType := d.Get(UNIT_AGGREGATION_TYPE).(string)
analysisType := d.Get(ANALYSIS_TYPE).(string)
includeUnitsWithoutEvents := d.Get(INCLUDE_UNITS_WITHOUT_EVENTS).(bool)
archived := d.Get(ARCHIVED).(bool)

patch := []ldapi.PatchOperation{
patchReplace("/name", name),
Expand All @@ -325,6 +328,7 @@
patchReplace("/unitAggregationType", unitAggregationType),
patchReplace("/analysisType", analysisType),
patchReplace("/eventDefault/disabled", !includeUnitsWithoutEvents),
patchReplace("/archived", archived),
}

percentileValueData, ok := d.GetOk(PERCENTILE_VALUE)
Expand Down
131 changes: 131 additions & 0 deletions 131 launchdarkly/resource_launchdarkly_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,3 +650,134 @@ func testAccCheckMetricExists(resourceName string) resource.TestCheckFunc {
return nil
}
}

func TestAccMetric_ArchivedField(t *testing.T) {
accTest := os.Getenv("TF_ACC")
if accTest == "" {
t.SkipNow()
}
projectKey := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resourceName := "launchdarkly_metric.archived_test"

// Test configuration with archived = true
testAccMetricArchivedTrue := `
resource "launchdarkly_metric" "archived_test" {
project_key = launchdarkly_project.test.key
key = "archived-metric"
name = "Archived Metric"
description = "Test metric for archived field"
kind = "pageview"
archived = true
tags = ["test", "archived"]
urls {
kind = "substring"
substring = "test"
}
}
`

// Test configuration with archived = false
testAccMetricArchivedFalse := `
resource "launchdarkly_metric" "archived_test" {
project_key = launchdarkly_project.test.key
key = "archived-metric"
name = "Archived Metric"
description = "Test metric for archived field"
kind = "pageview"
archived = false
tags = ["test", "archived"]
urls {
kind = "substring"
substring = "test"
}
}
`

// Test configuration without archived field (should default to false)
testAccMetricArchivedDefault := `
resource "launchdarkly_metric" "archived_test" {
project_key = launchdarkly_project.test.key
key = "archived-metric"
name = "Archived Metric"
description = "Test metric for archived field"
kind = "pageview"
tags = ["test", "archived"]
urls {
kind = "substring"
substring = "test"
}
}
`

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
// Step 1: Create metric with archived = true
{
Config: withRandomProject(projectKey, testAccMetricArchivedTrue),
Check: resource.ComposeTestCheckFunc(
testAccCheckProjectExists("launchdarkly_project.test"),
testAccCheckMetricExists(resourceName),
resource.TestCheckResourceAttr(resourceName, KEY, "archived-metric"),
resource.TestCheckResourceAttr(resourceName, NAME, "Archived Metric"),
resource.TestCheckResourceAttr(resourceName, PROJECT_KEY, projectKey),
resource.TestCheckResourceAttr(resourceName, KIND, "pageview"),
resource.TestCheckResourceAttr(resourceName, ARCHIVED, "true"),
resource.TestCheckResourceAttr(resourceName, "tags.0", "archived"),
resource.TestCheckResourceAttr(resourceName, "tags.1", "test"),
),
},
// Step 2: Import state verification for archived = true
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
// Step 3: Update metric to archived = false
{
Config: withRandomProject(projectKey, testAccMetricArchivedFalse),
Check: resource.ComposeTestCheckFunc(
testAccCheckProjectExists("launchdarkly_project.test"),
testAccCheckMetricExists(resourceName),
resource.TestCheckResourceAttr(resourceName, KEY, "archived-metric"),
resource.TestCheckResourceAttr(resourceName, NAME, "Archived Metric"),
resource.TestCheckResourceAttr(resourceName, PROJECT_KEY, projectKey),
resource.TestCheckResourceAttr(resourceName, KIND, "pageview"),
resource.TestCheckResourceAttr(resourceName, ARCHIVED, "false"),
resource.TestCheckResourceAttr(resourceName, "tags.0", "archived"),
resource.TestCheckResourceAttr(resourceName, "tags.1", "test"),
),
},
// Step 4: Import state verification for archived = false
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
// Step 5: Remove archived field (should default to false)
{
Config: withRandomProject(projectKey, testAccMetricArchivedDefault),
Check: resource.ComposeTestCheckFunc(
testAccCheckProjectExists("launchdarkly_project.test"),
testAccCheckMetricExists(resourceName),
resource.TestCheckResourceAttr(resourceName, KEY, "archived-metric"),
resource.TestCheckResourceAttr(resourceName, NAME, "Archived Metric"),
resource.TestCheckResourceAttr(resourceName, PROJECT_KEY, projectKey),
resource.TestCheckResourceAttr(resourceName, KIND, "pageview"),
resource.TestCheckResourceAttr(resourceName, ARCHIVED, "false"),
resource.TestCheckResourceAttr(resourceName, "tags.0", "archived"),
resource.TestCheckResourceAttr(resourceName, "tags.1", "test"),
),
},
// Step 6: Import state verification for default archived value
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.