Browse Source

Check typecast

Matt Bolt 6 năm trước cách đây
mục cha
commit
eccc828087
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      costmodel/costmodel.go

+ 5 - 1
costmodel/costmodel.go

@@ -1333,7 +1333,11 @@ func (cm *CostModel) ComputeCostDataRange(cli prometheusClient.Client, clientset
 		return cm.costDataRange(cli, clientset, cp, startString, endString, windowString, filterNamespace, filterCluster, remoteEnabled)
 	})
 
-	data := result.(map[string]*CostData)
+	data, ok := result.(map[string]*CostData)
+	if !ok {
+		return nil, fmt.Errorf("Failed to cast result as map[string]*CostData")
+	}
+
 	return data, err
 }