@@ -542,7 +542,7 @@ func getColoringRulesSchema() map[string]*schema.Schema {
542542 Type : schema .TypeString ,
543543 Required : true ,
544544 },
545- "color_thresholds " : {
545+ "color_threshold " : {
546546 Type : schema .TypeList ,
547547 Optional : true ,
548548 Elem : & schema.Resource {
@@ -973,25 +973,26 @@ func getMetricsQueryOperator(tfQueryOperator map[string]interface{}) MetricsQuer
973973}
974974
975975func getTimeRange (tfTimeRange map [string ]interface {}) interface {} {
976- if val , ok := tfTimeRange ["complete_literal_time_range" ].([]interface {}); ok {
976+ if val := tfTimeRange ["complete_literal_time_range" ].([]interface {}); len ( val ) == 1 {
977977 if literalRange , ok := val [0 ].(map [string ]interface {}); ok {
978978 return CompleteLiteralTimeRange {
979979 Type : "CompleteLiteralTimeRange" ,
980980 RangeName : literalRange ["range_name" ].(string ),
981981 }
982982 }
983- } else if val , ok := tfTimeRange ["bounded_time_range " ].([]interface {}); ok {
983+ } else if val := tfTimeRange ["begin_bounded_time_range " ].([]interface {}); len ( val ) == 1 {
984984 if boundedRange , ok := val [0 ].(map [string ]interface {}); ok {
985- boundaryStart := boundedRange ["from" ].([]interface {})[0 ]
986- var boundaryEnd interface {}
987- if val , ok := boundedRange ["to" ].([]interface {}); ok {
988- boundaryEnd = val [0 ]
985+ from := boundedRange ["from" ].([]interface {})
986+ boundaryStart := from [0 ].(map [string ]interface {})
987+ var boundaryEnd map [string ]interface {}
988+ if to := boundedRange ["to" ].([]interface {}); len (to ) == 1 {
989+ boundaryEnd = to [0 ].(map [string ]interface {})
989990 }
990991
991992 return BeginBoundedTimeRange {
992993 Type : "BeginBoundedTimeRange" ,
993- From : getTimeRangeBoundary (boundaryStart .( map [ string ] interface {}) ),
994- To : getTimeRangeBoundary (boundaryEnd .( map [ string ] interface {}) ),
994+ From : getTimeRangeBoundary (boundaryStart ),
995+ To : getTimeRangeBoundary (boundaryEnd ),
995996 }
996997 }
997998 }
@@ -1000,28 +1001,32 @@ func getTimeRange(tfTimeRange map[string]interface{}) interface{} {
10001001}
10011002
10021003func getTimeRangeBoundary (tfRangeBoundary map [string ]interface {}) interface {} {
1003- if val , ok := tfRangeBoundary ["epoch_time_range" ].([]interface {}); ok {
1004+ if len (tfRangeBoundary ) == 0 {
1005+ return nil
1006+ }
1007+
1008+ if val := tfRangeBoundary ["epoch_time_range" ].([]interface {}); len (val ) == 1 {
10041009 if epochBoundary , ok := val [0 ].(map [string ](interface {})); ok {
10051010 return EpochTimeRangeBoundary {
10061011 Type : "EpochTimeRangeBoundary" ,
10071012 EpochMillis : epochBoundary ["epoch_millis" ].(int64 ),
10081013 }
10091014 }
1010- } else if val , ok := tfRangeBoundary ["iso8601_time_range" ].([]interface {}); ok {
1015+ } else if val := tfRangeBoundary ["iso8601_time_range" ].([]interface {}); len ( val ) == 1 {
10111016 if iso8601Boundary , ok := val [0 ].(map [string ](interface {})); ok {
10121017 return Iso8601TimeRangeBoundary {
10131018 Type : "Iso8601TimeRangeBoundary" ,
10141019 Iso8601Time : iso8601Boundary ["iso8601_time" ].(string ),
10151020 }
10161021 }
1017- } else if val , ok := tfRangeBoundary ["literal_time_range" ].([]interface {}); ok {
1022+ } else if val := tfRangeBoundary ["literal_time_range" ].([]interface {}); len ( val ) == 1 {
10181023 if literalBoundary , ok := val [0 ].(map [string ](interface {})); ok {
10191024 return LiteralTimeRangeBoundary {
10201025 Type : "LiteralTimeRangeBoundary" ,
10211026 RangeName : literalBoundary ["range_name" ].(string ),
10221027 }
10231028 }
1024- } else if val , ok := tfRangeBoundary ["relative_time_range" ].([]interface {}); ok {
1029+ } else if val := tfRangeBoundary ["relative_time_range" ].([]interface {}); len ( val ) == 1 {
10251030 if relativeBoundary , ok := val [0 ].(map [string ](interface {})); ok {
10261031 return RelativeTimeRangeBoundary {
10271032 Type : "RelativeTimeRangeBoundary" ,
@@ -1048,7 +1053,7 @@ func getTopologyLabel(tfTopologyLabel map[string]interface{}) *TopologyLabel {
10481053}
10491054
10501055func getLayout (tfLayout map [string ]interface {}) interface {} {
1051- if val , ok := tfLayout ["grid" ].([]interface {}); ok {
1056+ if val := tfLayout ["grid" ].([]interface {}); len ( val ) == 1 {
10521057 if gridLayout , ok := val [0 ].(map [string ]interface {}); ok {
10531058 if tfStructures , ok := gridLayout ["layout_structures" ].([]interface {}); ok {
10541059 var structures []LayoutStructure
@@ -1103,24 +1108,21 @@ func getVariable(tfVariable map[string]interface{}) Variable {
11031108}
11041109
11051110func getSourceDefinition (tfSourceDef map [string ]interface {}) interface {} {
1106- if len (tfSourceDef ["log_query_variable_source_definition" ].([]interface {})) == 1 {
1107- val := tfSourceDef ["log_query_variable_source_definition" ].([]interface {})
1111+ if val := tfSourceDef ["log_query_variable_source_definition" ].([]interface {}); len (val ) == 1 {
11081112 logQuerySourceDef := val [0 ].(map [string ]interface {})
11091113 return LogQueryVariableSourceDefinition {
11101114 VariableSourceType : "LogQueryVariableSourceDefinition" ,
11111115 Query : logQuerySourceDef ["query" ].(string ),
11121116 Field : logQuerySourceDef ["field" ].(string ),
11131117 }
1114- } else if len (tfSourceDef ["metadata_variable_source_definition" ].([]interface {})) == 1 {
1115- val := tfSourceDef ["metadata_variable_source_definition" ].([]interface {})
1118+ } else if val := tfSourceDef ["metadata_variable_source_definition" ].([]interface {}); len (val ) == 1 {
11161119 metadataSourceDef := val [0 ].(map [string ]interface {})
11171120 return MetadataVariableSourceDefinition {
11181121 VariableSourceType : "MetadataVariableSourceDefinition" ,
11191122 Filter : metadataSourceDef ["filter" ].(string ),
11201123 Key : metadataSourceDef ["key" ].(string ),
11211124 }
1122- } else if len (tfSourceDef ["csv_variable_source_definition" ].([]interface {})) == 1 {
1123- val := tfSourceDef ["csv_variable_source_definition" ].([]interface {})
1125+ } else if val := tfSourceDef ["csv_variable_source_definition" ].([]interface {}); len (val ) == 1 {
11241126 csvSourceDef := val [0 ].(map [string ]interface {})
11251127 return CsvVariableSourceDefinition {
11261128 VariableSourceType : "CsvVariableSourceDefinition" ,
@@ -1137,7 +1139,7 @@ func getColoringRule(tfColoringRule map[string]interface{}) ColoringRule {
11371139 coloringRule .SingleSeriesAggregateFunction = tfColoringRule ["single_series_aggregate_function" ].(string )
11381140 coloringRule .MultipleSeriesAggregateFunction = tfColoringRule ["multiple_series_aggregate_function" ].(string )
11391141
1140- tfColorThresholds := tfColoringRule ["color_thresholds " ].([]interface {})
1142+ tfColorThresholds := tfColoringRule ["color_threshold " ].([]interface {})
11411143 var colorThresholds []ColorThreshold
11421144 for _ , val := range tfColorThresholds {
11431145 tfColorThreshold := val .(map [string ]interface {})
@@ -1499,10 +1501,10 @@ func getTerraformColoringRules(coloringRules []ColoringRule) []map[string]interf
14991501 for j , threshold := range rule .ColorThresholds {
15001502 tfColorThresholds [j ] = make (map [string ]interface {})
15011503 tfColorThresholds [j ]["color" ] = threshold .Color
1502- tfColorThresholds [j ]["min" ] = threshold .Max
1503- tfColorThresholds [j ]["max" ] = threshold .Min
1504+ tfColorThresholds [j ]["min" ] = threshold .Min
1505+ tfColorThresholds [j ]["max" ] = threshold .Max
15041506 }
1505- tfColoringRules [i ]["color_thresholds " ] = tfColorThresholds
1507+ tfColoringRules [i ]["color_threshold " ] = tfColorThresholds
15061508 }
15071509
15081510 return tfColoringRules
@@ -1550,6 +1552,7 @@ func resourceSumologicDashboardRead(d *schema.ResourceData, meta interface{}) er
15501552
15511553func resourceSumologicDashboardDelete (d * schema.ResourceData , meta interface {}) error {
15521554 c := meta .(* Client )
1555+ log .Printf ("Deleting dashboard: %+v\n " , d .Id ())
15531556 return c .DeleteDashboard (d .Id ())
15541557}
15551558
0 commit comments