Procházet zdrojové kódy

Merge pull request #1185 from kubecost/kaelan-clone-errors

Allow alloc/asset set clone of errors/warnings
Kaelan Patel před 4 roky
rodič
revize
aed2cff2a6
2 změnil soubory, kde provedl 38 přidání a 0 odebrání
  1. 19 0
      pkg/kubecost/allocation.go
  2. 19 0
      pkg/kubecost/asset.go

+ 19 - 0
pkg/kubecost/allocation.go

@@ -1668,11 +1668,30 @@ func (as *AllocationSet) Clone() *AllocationSet {
 		idleKeys[k] = v
 		idleKeys[k] = v
 	}
 	}
 
 
+	var errors []string
+	var warnings []string
+
+	if as.Errors != nil {
+		errors = make([]string, len(as.Errors))
+		copy(errors, as.Errors)
+	} else {
+		errors = nil
+	}
+
+	if as.Warnings != nil {
+		warnings := make([]string, len(as.Warnings))
+		copy(warnings, as.Warnings)
+	} else {
+		warnings = nil
+	}
+
 	return &AllocationSet{
 	return &AllocationSet{
 		allocations:  allocs,
 		allocations:  allocs,
 		externalKeys: externalKeys,
 		externalKeys: externalKeys,
 		idleKeys:     idleKeys,
 		idleKeys:     idleKeys,
 		Window:       as.Window.Clone(),
 		Window:       as.Window.Clone(),
+		Errors:       errors,
+		Warnings:     warnings,
 	}
 	}
 }
 }
 
 

+ 19 - 0
pkg/kubecost/asset.go

@@ -2533,10 +2533,29 @@ func (as *AssetSet) Clone() *AssetSet {
 	s := as.Start()
 	s := as.Start()
 	e := as.End()
 	e := as.End()
 
 
+	var errors []string
+	var warnings []string
+
+	if as.Errors != nil {
+		errors = make([]string, len(as.Errors))
+		copy(errors, as.Errors)
+	} else {
+		errors = nil
+	}
+
+	if as.Warnings != nil {
+		warnings := make([]string, len(as.Warnings))
+		copy(warnings, as.Warnings)
+	} else {
+		warnings = nil
+	}
+
 	return &AssetSet{
 	return &AssetSet{
 		Window:      NewWindow(&s, &e),
 		Window:      NewWindow(&s, &e),
 		aggregateBy: aggregateBy,
 		aggregateBy: aggregateBy,
 		assets:      assets,
 		assets:      assets,
+		Errors:      errors,
+		Warnings:    warnings,
 	}
 	}
 }
 }