Skip to content

Commit 16b3781

Browse files
committed
Add support for tag cloud panels
1 parent e247b0a commit 16b3781

File tree

8 files changed

+1049
-6
lines changed

8 files changed

+1049
-6
lines changed

docs/resources/fleet_integration_policy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ resource "elasticstack_fleet_integration_policy" "sample" {
102102
- `output_id` (String) The ID of the output to send data to. When not specified, the default output of the agent policy will be used.
103103
- `policy_id` (String) Unique identifier of the integration policy.
104104
- `space_ids` (Set of String) The Kibana space IDs where this integration policy is available. When set, must match the space_ids of the referenced agent policy. If not set, will be inherited from the agent policy. Note: The order of space IDs does not matter as this is a set.
105-
- `vars_json` (String, Sensitive) Integration-level variables as JSON. Variables vary depending on the integration package.
105+
- `vars_json` (String) Integration-level variables as JSON. Variables vary depending on the integration package.
106106

107107
The provider injects the '__tf_provider_context' property into this JSON object. In most cases this field will be ignored when computing the difference between the current and desired state. In some cases however, this property may be shown in the Terraform plan. Any changes to the '__tf_provider_context' property can be safely ignored. This property is used internally by the provider, and you should not set this property within your Terraform configuration.
108108

@@ -117,7 +117,7 @@ Optional:
117117

118118
- `enabled` (Boolean) Enable the input.
119119
- `streams` (Attributes Map) Input streams mapped by stream ID. (see [below for nested schema](#nestedatt--inputs--streams))
120-
- `vars` (String, Sensitive) Input-level variables as JSON.
120+
- `vars` (String) Input-level variables as JSON.
121121

122122
Read-Only:
123123

@@ -129,7 +129,7 @@ Read-Only:
129129
Optional:
130130

131131
- `enabled` (Boolean) Enable the stream.
132-
- `vars` (String, Sensitive) Stream-level variables as JSON.
132+
- `vars` (String) Stream-level variables as JSON.
133133

134134

135135
<a id="nestedatt--inputs--defaults"></a>

internal/kibana/dashboard/acc_test.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,89 @@ func TestAccResourceDashboardXYChart(t *testing.T) {
395395
},
396396
})
397397
}
398+
399+
func TestAccResourceDashboardTagcloud(t *testing.T) {
400+
dashboardTitle := "Test Dashboard with Tagcloud " + sdkacctest.RandStringFromCharSet(4, sdkacctest.CharSetAlphaNum)
401+
402+
resource.Test(t, resource.TestCase{
403+
PreCheck: func() { acctest.PreCheck(t) },
404+
Steps: []resource.TestStep{
405+
{
406+
ProtoV6ProviderFactories: acctest.Providers,
407+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minDashboardAPISupport),
408+
ConfigDirectory: acctest.NamedTestCaseDirectory("basic"),
409+
ConfigVariables: config.Variables{
410+
"dashboard_title": config.StringVariable(dashboardTitle),
411+
},
412+
Check: resource.ComposeTestCheckFunc(
413+
resource.TestCheckResourceAttrSet("elasticstack_kibana_dashboard.test", "id"),
414+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "title", dashboardTitle),
415+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.#", "1"),
416+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.type", "lens"),
417+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.grid.h", "15"),
418+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.grid.w", "24"),
419+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.grid.x", "0"),
420+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.grid.y", "0"),
421+
// Check tagcloud config
422+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.title", "Sample Tagcloud"),
423+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.description", "Test tagcloud visualization"),
424+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.orientation", "horizontal"),
425+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.font_size.min", "18"),
426+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.font_size.max", "72"),
427+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.ignore_global_filters", "false"),
428+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.sampling", "1"),
429+
// Check query
430+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.query.language", "kuery"),
431+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.query.query", ""),
432+
// Check JSON fields are set
433+
resource.TestCheckResourceAttrSet("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.dataset"),
434+
resource.TestCheckResourceAttrSet("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.metric"),
435+
resource.TestCheckResourceAttrSet("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.tag_by"),
436+
),
437+
},
438+
{
439+
ProtoV6ProviderFactories: acctest.Providers,
440+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minDashboardAPISupport),
441+
ConfigDirectory: acctest.NamedTestCaseDirectory("with_filters"),
442+
ConfigVariables: config.Variables{
443+
"dashboard_title": config.StringVariable(dashboardTitle + " with Filters"),
444+
},
445+
Check: resource.ComposeTestCheckFunc(
446+
resource.TestCheckResourceAttrSet("elasticstack_kibana_dashboard.test", "id"),
447+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "title", dashboardTitle+" with Filters"),
448+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.#", "1"),
449+
// Check tagcloud config with filters
450+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.title", "Filtered Tagcloud"),
451+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.description", "Tagcloud with filters and custom settings"),
452+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.orientation", "vertical"),
453+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.font_size.min", "12"),
454+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.font_size.max", "100"),
455+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.ignore_global_filters", "true"),
456+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.sampling", "0.5"),
457+
// Check query with filter
458+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.query.language", "kuery"),
459+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.query.query", "service.name:*"),
460+
// Check filters
461+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.filters.#", "1"),
462+
resource.TestCheckResourceAttr("elasticstack_kibana_dashboard.test", "panels.0.tagcloud_config.filters.0.query", "log.level:error OR log.level:warning"),
463+
),
464+
},
465+
{
466+
ProtoV6ProviderFactories: acctest.Providers,
467+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minDashboardAPISupport),
468+
ConfigDirectory: acctest.NamedTestCaseDirectory("basic"),
469+
ConfigVariables: config.Variables{
470+
"dashboard_title": config.StringVariable(dashboardTitle),
471+
},
472+
ResourceName: "elasticstack_kibana_dashboard.test",
473+
ImportState: true,
474+
ImportStateVerify: true,
475+
// Ignore JSON fields with API defaults
476+
ImportStateVerifyIgnore: []string{
477+
"panels.0.tagcloud_config.metric",
478+
"panels.0.tagcloud_config.tag_by",
479+
},
480+
},
481+
},
482+
})
483+
}

internal/kibana/dashboard/models_panels.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type panelModel struct {
1717
ID types.String `tfsdk:"id"`
1818
MarkdownConfig *markdownConfigModel `tfsdk:"markdown_config"`
1919
XYChartConfig *xyChartConfigModel `tfsdk:"xy_chart_config"`
20+
TagcloudConfig *tagcloudConfigModel `tfsdk:"tagcloud_config"`
2021
ConfigJSON jsontypes.Normalized `tfsdk:"config_json"`
2122
}
2223

@@ -49,6 +50,7 @@ type panelConfigConverter interface {
4950
var panelConfigConverters = []panelConfigConverter{
5051
markdownPanelConfigConverter{},
5152
newXYChartPanelConfigConverter(),
53+
newTagcloudPanelConfigConverter(),
5254
}
5355

5456
func (m *dashboardModel) mapPanelsFromAPI(ctx context.Context, apiPanels *kbapi.DashboardPanels) ([]panelModel, []sectionModel, diag.Diagnostics) {

0 commit comments

Comments
 (0)