@@ -135,21 +135,6 @@ func resourceSumologicDashboard() *schema.Resource {
135135}
136136
137137func getPanelSchema () map [string ]* schema.Schema {
138- panelSchema := getPanelBaseSchema ()
139-
140- panelSchema ["container_panel" ] = & schema.Schema {
141- Type : schema .TypeList ,
142- Optional : true ,
143- MaxItems : 1 ,
144- Elem : & schema.Resource {
145- Schema : getContainerPanelSchema (),
146- },
147- }
148-
149- return panelSchema
150- }
151-
152- func getPanelBaseSchema () map [string ]* schema.Schema {
153138 return map [string ]* schema.Schema {
154139 "id" : {
155140 Type : schema .TypeString ,
@@ -201,40 +186,6 @@ func getPanelBaseSchema() map[string]*schema.Schema {
201186 }
202187}
203188
204- func getContainerPanelSchema () map [string ]* schema.Schema {
205- return map [string ]* schema.Schema {
206- "layout" : {
207- Type : schema .TypeList ,
208- Required : true ,
209- MaxItems : 1 ,
210- Elem : & schema.Resource {
211- Schema : getLayoutSchema (),
212- },
213- },
214- "panel" : {
215- Type : schema .TypeList ,
216- Required : true ,
217- Elem : & schema.Resource {
218- Schema : getPanelBaseSchema (),
219- },
220- },
221- "variable" : {
222- Type : schema .TypeList ,
223- Optional : true ,
224- Elem : & schema.Resource {
225- Schema : getVariablesSchema (),
226- },
227- },
228- "coloring_rule" : {
229- Type : schema .TypeList ,
230- Optional : true ,
231- Elem : & schema.Resource {
232- Schema : getColoringRulesSchema (),
233- },
234- },
235- }
236- }
237-
238189func getSumoSearchPanelSchema () map [string ]* schema.Schema {
239190 return map [string ]* schema.Schema {
240191 "query" : {
@@ -736,76 +687,14 @@ func resourceToDashboard(d *schema.ResourceData) Dashboard {
736687}
737688
738689func getPanel (tfPanel map [string ]interface {}) interface {} {
739- // container_panel is not part of base panel schema to avoid infinite recursion.
740- if val , ok := tfPanel ["container_panel" ].([]interface {}); ok && len (val ) == 1 {
741- return getContainerPanel (tfPanel )
742- } else if len (tfPanel ["text_panel" ].([]interface {})) == 1 {
690+ if len (tfPanel ["text_panel" ].([]interface {})) == 1 {
743691 return getTextPanel (tfPanel )
744692 } else if len (tfPanel ["sumo_search_panel" ].([]interface {})) == 1 {
745693 return getSumoSearchPanel (tfPanel )
746694 }
747695 return nil
748696}
749697
750- func getContainerPanel (tfPanel map [string ]interface {}) interface {} {
751- var containerPanel ContainerPanel
752- containerPanel .PanelType = "ContainerPanel"
753-
754- if key , ok := tfPanel ["key" ].(string ); ok {
755- containerPanel .Key = key
756- }
757- if title , ok := tfPanel ["title" ].(string ); ok {
758- containerPanel .Title = title
759- }
760- if visualSettings , ok := tfPanel ["visual_settings" ].(string ); ok {
761- containerPanel .VisualSettings = visualSettings
762- }
763- if consistentVisualSettings , ok := tfPanel ["keep_visual_settings_consistent_with_parent" ].(bool ); ok {
764- containerPanel .KeepVisualSettingsConsistentWithParent = consistentVisualSettings
765- }
766-
767- // container panel specific properties
768- tfContainerPanel := tfPanel ["container_panel" ].([]interface {})[0 ].(map [string ]interface {})
769- var panels []interface {}
770- if val , ok := tfContainerPanel ["panel" ]; ok {
771- tfPanels := val .([]interface {})
772- for _ , val := range tfPanels {
773- panel := getPanel (val .(map [string ]interface {}))
774- panels = append (panels , panel )
775- }
776- }
777- containerPanel .Panels = panels
778-
779- var layout interface {}
780- if val , ok := tfContainerPanel ["layout" ]; ok {
781- tfLayout := val .([]interface {})[0 ]
782- layout = getLayout (tfLayout .(map [string ]interface {}))
783- }
784- containerPanel .Layout = layout
785-
786- var variables []Variable
787- if val , ok := tfContainerPanel ["variable" ]; ok {
788- tfVariables := val .([]interface {})
789- for _ , tfVariable := range tfVariables {
790- variable := getVariable (tfVariable .(map [string ]interface {}))
791- variables = append (variables , variable )
792- }
793- }
794- containerPanel .Variables = variables
795-
796- var coloringRules []ColoringRule
797- if val , ok := tfContainerPanel ["coloring_rule" ]; ok {
798- tfColoringRules := val .([]interface {})
799- for _ , tfColoringRule := range tfColoringRules {
800- coloringRule := getColoringRule (tfColoringRule .(map [string ]interface {}))
801- coloringRules = append (coloringRules , coloringRule )
802- }
803- }
804- containerPanel .ColoringRules = coloringRules
805-
806- return containerPanel
807- }
808-
809698func getTextPanel (tfPanel map [string ]interface {}) interface {} {
810699 var textPanel TextPanel
811700 textPanel .PanelType = "TextPanel"
0 commit comments