From 502c3e4a5a8a5ce21a317a32ef96d2c8b5ea3ff9 Mon Sep 17 00:00:00 2001 From: Suzuki Shunsuke Date: Fri, 4 Oct 2019 20:13:54 +0900 Subject: [PATCH] feat: fix graylog_view (wip) --- terraform/example/v0.12/view.tf | 17 +++-- terraform/graylog/resource_view.go | 113 ++++++++++++++++++++++++----- 2 files changed, 105 insertions(+), 25 deletions(-) diff --git a/terraform/example/v0.12/view.tf b/terraform/example/v0.12/view.tf index 2e374bbc..4f2a29a4 100644 --- a/terraform/example/v0.12/view.tf +++ b/terraform/example/v0.12/view.tf @@ -1,7 +1,12 @@ -# resource "graylog_view" "test" { -# title = "test" -# description = "description" -# summary = "summary" -# # set appropriate search_id -# search_id = "5d9529b275d97f58f9539279" +resource "graylog_view" "test" { + title = "test" + description = "description" + summary = "summary" + # set appropriate search_id + # search_id = "5d9529b275d97f58f9539279" +# state = { +# "6971d00a-e605-43fb-b873-e4bca773d286" = { +# selected_fields = ["source", "message"] +# } # } +} diff --git a/terraform/graylog/resource_view.go b/terraform/graylog/resource_view.go index 94817dac..0abe7864 100644 --- a/terraform/graylog/resource_view.go +++ b/terraform/graylog/resource_view.go @@ -24,6 +24,7 @@ func resourceView() *schema.Resource { Type: schema.TypeString, Required: true, }, + "search_id": { Type: schema.TypeString, Required: true, @@ -33,52 +34,126 @@ func resourceView() *schema.Resource { "state": { Type: schema.TypeMap, Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "selected_fields": { - Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "selected_fields": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + + "titles": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeMap, Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, }, }, }, + + "widget_mapping": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + + "widgets": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Optional: true, + }, + + // "aggregation_config": { + // Type: schema.TypeList, + // Optional: true, + // MaxItems: 1, + // MinItems: 1, + // Elem: &schema.Resource{ + // }, + // }, + }, + }, + }, + + "positions": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + // "width": { + // Type: schema.TypeInt, + // Optional: true, + // }, + "col": { + Type: schema.TypeInt, + Optional: true, + }, + "row": { + Type: schema.TypeInt, + Optional: true, + }, + "height": { + Type: schema.TypeInt, + Optional: true, + }, + }, + }, + }, + }, }, }, }, + "summary": { Type: schema.TypeString, Optional: true, }, + "description": { Type: schema.TypeString, Optional: true, }, + "owner": { Type: schema.TypeString, Optional: true, Computed: true, }, - // outputs + "created_at": { Type: schema.TypeString, Optional: true, Computed: true, }, - "dashboard_state": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, + + // "dashboard_state": { + // Type: schema.TypeList, + // Optional: true, + // MaxItems: 1, + // MinItems: 1, + // Elem: &schema.Resource{ + // Schema: map[string]*schema.Schema{}, + // }, + // }, }, } }