Просмотр исходного кода

Merge branch 'develop' into bug-fix

Ajay Tripathy 3 лет назад
Родитель
Сommit
c9d5b59166
2 измененных файлов с 16 добавлено и 0 удалено
  1. 8 0
      pkg/kubecost/allocation.go
  2. 8 0
      pkg/kubecost/asset.go

+ 8 - 0
pkg/kubecost/allocation.go

@@ -2103,6 +2103,14 @@ func (asr *AllocationSetRange) NewAccumulation() (*AllocationSet, error) {
 	var allocSet *AllocationSet
 	var err error
 
+	if asr == nil {
+		return nil, fmt.Errorf("nil AllocationSetRange in accumulation")
+	}
+
+	if len(asr.Allocations) == 0 {
+		return nil, fmt.Errorf("AllocationSetRange has empty AssetSet in accumulation")
+	}
+
 	for _, as := range asr.Allocations {
 		if allocSet == nil {
 			allocSet = as.Clone()

+ 8 - 0
pkg/kubecost/asset.go

@@ -3249,6 +3249,14 @@ func (asr *AssetSetRange) NewAccumulation() (*AssetSet, error) {
 	var assetSet *AssetSet
 	var err error
 
+	if asr == nil {
+		return nil, fmt.Errorf("nil AssetSetRange in accumulation")
+	}
+
+	if len(asr.Assets) == 0 {
+		return nil, fmt.Errorf("AssetSetRange has empty AssetSet in accumulation")
+	}
+
 	for _, as := range asr.Assets {
 		if assetSet == nil {
 			assetSet = as.Clone()