瀏覽代碼

Merge pull request #2011 from opencost/sean/lb-private-bingen

Sean/lb private bingen
Sean Holcomb 2 年之前
父節點
當前提交
07d01d5f7a
共有 4 個文件被更改,包括 22 次插入9 次删除
  1. 1 1
      pkg/kubecost/allocation.go
  2. 1 1
      pkg/kubecost/asset.go
  3. 2 2
      pkg/kubecost/bingen.go
  4. 18 5
      pkg/kubecost/kubecost_codecs.go

+ 1 - 1
pkg/kubecost/allocation.go

@@ -92,7 +92,7 @@ type Allocation struct {
 	// and appended to an Allocation, and so by default is is nil.
 	ProportionalAssetResourceCosts ProportionalAssetResourceCosts `json:"proportionalAssetResourceCosts"` //@bingen:field[ignore]
 	SharedCostBreakdown            SharedCostBreakdowns           `json:"sharedCostBreakdown"`            //@bingen:field[ignore]
-	LoadBalancers                  LbAllocations                  `json:"LoadBalancers"`                  // @bingen:field[version=17]
+	LoadBalancers                  LbAllocations                  `json:"LoadBalancers"`                  // @bingen:field[version=18]
 
 }
 

+ 1 - 1
pkg/kubecost/asset.go

@@ -2184,7 +2184,7 @@ type LoadBalancer struct {
 	Window     Window
 	Adjustment float64
 	Cost       float64
-	Private    bool
+	Private    bool // @bingen:field[version=20]
 }
 
 // NewLoadBalancer instantiates and returns a new LoadBalancer

+ 2 - 2
pkg/kubecost/bingen.go

@@ -26,7 +26,7 @@ package kubecost
 // @bingen:generate:CoverageSet
 
 // Asset Version Set: Includes Asset pipeline specific resources
-// @bingen:set[name=Assets,version=19]
+// @bingen:set[name=Assets,version=20]
 // @bingen:generate:Any
 // @bingen:generate:Asset
 // @bingen:generate:AssetLabels
@@ -46,7 +46,7 @@ package kubecost
 // @bingen:end
 
 // Allocation Version Set: Includes Allocation pipeline specific resources
-// @bingen:set[name=Allocation,version=17]
+// @bingen:set[name=Allocation,version=18]
 // @bingen:generate:Allocation
 // @bingen:generate[stringtable]:AllocationSet
 // @bingen:generate:AllocationSetRange

+ 18 - 5
pkg/kubecost/kubecost_codecs.go

@@ -13,12 +13,11 @@ package kubecost
 
 import (
 	"fmt"
+	util "github.com/opencost/opencost/pkg/util"
 	"reflect"
 	"strings"
 	"sync"
 	"time"
-
-	util "github.com/opencost/opencost/pkg/util"
 )
 
 const (
@@ -38,10 +37,10 @@ const (
 	DefaultCodecVersion uint8 = 17
 
 	// AssetsCodecVersion is used for any resources listed in the Assets version set
-	AssetsCodecVersion uint8 = 19
+	AssetsCodecVersion uint8 = 20
 
 	// AllocationCodecVersion is used for any resources listed in the Allocation version set
-	AllocationCodecVersion uint8 = 17
+	AllocationCodecVersion uint8 = 18
 
 	// AuditCodecVersion is used for any resources listed in the Audit version set
 	AuditCodecVersion uint8 = 1
@@ -1061,7 +1060,7 @@ func (target *Allocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err
 
 	}
 	// field version check
-	if uint8(17) <= version {
+	if uint8(18) <= version {
 		// --- [begin][read][alias](LbAllocations) ---
 		var xx map[string]*LbAllocation
 		if buff.ReadUInt8() == uint8(0) {
@@ -7335,6 +7334,7 @@ func (target *LbAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err
 		buff.WriteString(target.Service) // write string
 	}
 	buff.WriteFloat64(target.Cost) // write float64
+	buff.WriteBool(target.Private) // write bool
 	return nil
 }
 
@@ -7405,6 +7405,9 @@ func (target *LbAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (er
 	d := buff.ReadFloat64() // read float64
 	target.Cost = d
 
+	e := buff.ReadBool() // read bool
+	target.Private = e
+
 	return nil
 }
 
@@ -7517,6 +7520,7 @@ func (target *LoadBalancer) MarshalBinaryWithContext(ctx *EncodingContext) (err
 
 	buff.WriteFloat64(target.Adjustment) // write float64
 	buff.WriteFloat64(target.Cost)       // write float64
+	buff.WriteBool(target.Private)       // write bool
 	return nil
 }
 
@@ -7666,6 +7670,15 @@ func (target *LoadBalancer) UnmarshalBinaryWithContext(ctx *DecodingContext) (er
 	u := buff.ReadFloat64() // read float64
 	target.Cost = u
 
+	// field version check
+	if uint8(20) <= version {
+		w := buff.ReadBool() // read bool
+		target.Private = w
+
+	} else {
+		target.Private = false // default
+	}
+
 	return nil
 }