Przeglądaj źródła

Niko's comments

Sean Holcomb 5 lat temu
rodzic
commit
012986899a
2 zmienionych plików z 9 dodań i 11 usunięć
  1. 1 1
      pkg/kubecost/allocation.go
  2. 8 10
      pkg/kubecost/allocationprops.go

+ 1 - 1
pkg/kubecost/allocation.go

@@ -628,7 +628,7 @@ func (as *AllocationSet) AggregateBy(properties AllocationProperties, options *A
 	//
 	// In order to maintain stable results when multiple operations are being
 	// carried out (e.g. sharing idle, sharing resources, and filtering) these
-	// coefficients are computed for the full set of allocaitons prior to
+	// coefficients are computed for the full set of allocations prior to
 	// adding shared overhead and prior to applying filters.
 
 	var err error

+ 8 - 10
pkg/kubecost/allocationprops.go

@@ -139,31 +139,31 @@ func (p *AllocationProperties) Equal(that *AllocationProperties) bool {
 
 	pLabels := p.Labels
 	thatLabels := that.Labels
-	if len(pLabels) != len(thatLabels) {
+	if len(pLabels) == len(thatLabels) {
 		for k, pv := range pLabels {
 			tv, ok := thatLabels[k]
 			if !ok || tv != pv {
 				return false
 			}
 		}
-		return false
 	}
 
 	pAnnotations := p.Annotations
 	thatAnnotations := that.Annotations
-	if len(pAnnotations) != len(thatAnnotations) {
+	if len(pAnnotations) == len(thatAnnotations) {
 		for k, pv := range pAnnotations {
 			tv, ok := thatAnnotations[k]
 			if !ok || tv != pv {
 				return false
 			}
 		}
+	} else {
 		return false
 	}
 
 	pServices := p.Services
 	thatServices := that.Services
-	if len(pServices) != len(thatServices) {
+	if len(pServices) == len(thatServices) {
 		sort.Strings(pServices)
 		sort.Strings(thatServices)
 		for i, pv := range pServices {
@@ -172,9 +172,9 @@ func (p *AllocationProperties) Equal(that *AllocationProperties) bool {
 				return false
 			}
 		}
+	} else {
 		return false
 	}
-
 	return true
 }
 
@@ -233,13 +233,13 @@ func (p *AllocationProperties) String() string {
 	}
 	strs = append(strs, fmt.Sprintf("Annotations:{%s}", strings.Join(strs, ",")))
 
-	return strings.Join(strs, ",")
+	return fmt.Sprintf("{%s}", strings.Join(strs, "; "))
 }
 
 // AggregationStrings converts a AllocationProperties object into a slice of strings
 // representing a request to aggregate by certain properties.
 // NOTE: today, the ordering of the properties *has to match the ordering
-// of the allocaiton function generateKey*
+// of the allocation function generateKey*
 func (p *AllocationProperties) AggregationStrings() []string {
 	if p == nil {
 		return []string{}
@@ -273,9 +273,7 @@ func (p *AllocationProperties) AggregationStrings() []string {
 	if len(p.Services) > 0 {
 		aggStrs = append(aggStrs, AllocationServiceProp.String())
 	}
-	if len(p.Services) > 0 {
-		aggStrs = append(aggStrs, AllocationServiceProp.String())
-	}
+	
 	if len(p.Labels) > 0  {
 		// e.g. expect format map[string]string{
 		// 	 "env":""