Explorar el Código

Provide mechanism for aggregating metadata across accumulations

Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Alex Meijer hace 2 años
padre
commit
ecec71d182
Se han modificado 2 ficheros con 7 adiciones y 0 borrados
  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
 	if !shouldAggregate && !shouldFilter && !shouldShare && options.ShareIdle == ShareNone && !options.IncludeProportionalAssetResourceCosts {
 		// 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
 	}
 

+ 1 - 0
pkg/kubecost/allocationprops.go

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