瀏覽代碼

Provide mechanism for aggregating metadata across accumulations

Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Alex Meijer 2 年之前
父節點
當前提交
ecec71d182
共有 2 個文件被更改,包括 7 次插入0 次删除
  1. 6 0
      pkg/kubecost/allocation.go
  2. 1 0
      pkg/kubecost/allocationprops.go

+ 6 - 0
pkg/kubecost/allocation.go

@@ -1221,6 +1221,12 @@ func (as *AllocationSet) AggregateBy(aggregateBy []string, options *AllocationAg
 	shouldShare := len(options.SharedHourlyCosts) > 0 || len(options.ShareFuncs) > 0
 	shouldShare := len(options.SharedHourlyCosts) > 0 || len(options.ShareFuncs) > 0
 	if !shouldAggregate && !shouldFilter && !shouldShare && options.ShareIdle == ShareNone && !options.IncludeProportionalAssetResourceCosts {
 	if !shouldAggregate && !shouldFilter && !shouldShare && options.ShareIdle == ShareNone && !options.IncludeProportionalAssetResourceCosts {
 		// There is nothing for AggregateBy to do, so simply return nil
 		// There is nothing for AggregateBy to do, so simply return nil
+		// before returning, set aggregated metadata inclusion in properties
+		if options.IncludeAggregatedMetadata {
+			for index := range as.Allocations {
+				as.Allocations[index].Properties.AggregatedMetadata = true
+			}
+		}
 		return nil
 		return nil
 	}
 	}
 
 

+ 1 - 0
pkg/kubecost/allocationprops.go

@@ -161,6 +161,7 @@ func (p *AllocationProperties) Clone() *AllocationProperties {
 	}
 	}
 	clone.NamespaceAnnotations = nsAnnotations
 	clone.NamespaceAnnotations = nsAnnotations
 
 
+	clone.AggregatedMetadata = p.AggregatedMetadata
 	return clone
 	return clone
 }
 }