Sean Holcomb пре 5 година
родитељ
комит
97d67546f3

+ 6 - 7
pkg/cloud/awsprovider.go

@@ -854,11 +854,11 @@ func (aws *AWS) DownloadPricingData() error {
 							cost = offerTerm.PriceDimensions[sku.(string)+OnDemandRateCodeCn+HourlyRateCodeCn].PricePerUnit.CNY
 						}
 						if strings.Contains(key, "EBS:VolumeP-IOPS.piops") {
-						// If the specific UsageType is the per IO cost used on io1 volumes
-						// we need to add the per IO cost to the io1 PV cost
+							// If the specific UsageType is the per IO cost used on io1 volumes
+							// we need to add the per IO cost to the io1 PV cost
 
-						// Add the per IO cost to the PV object for the io1 volume type
-						aws.Pricing[key].PV.CostPerIO = cost
+							// Add the per IO cost to the PV object for the io1 volume type
+							aws.Pricing[key].PV.CostPerIO = cost
 						} else if strings.Contains(key, "EBS:Volume") {
 							// If volume, we need to get hourly cost and add it to the PV object
 							costFloat, _ := strconv.ParseFloat(cost, 64)
@@ -1589,7 +1589,7 @@ func (a *AWS) QueryAthenaPaginated(query string) (*athena.GetQueryResultsInput,
 	resultsBucket := customPricing.AthenaBucketName
 	database := customPricing.AthenaDatabase
 	c := &aws.Config{
-		Region: region,
+		Region:              region,
 		STSRegionalEndpoint: endpoints.RegionalSTSEndpoint,
 	}
 	s := session.Must(session.NewSession(c))
@@ -1659,7 +1659,7 @@ func (a *AWS) QueryAthenaBillingData(query string) (*athena.GetQueryResultsOutpu
 	resultsBucket := customPricing.AthenaBucketName
 	database := customPricing.AthenaDatabase
 	c := &aws.Config{
-		Region: region,
+		Region:              region,
 		STSRegionalEndpoint: endpoints.RegionalSTSEndpoint,
 	}
 	s := session.Must(session.NewSession(c))
@@ -1929,7 +1929,6 @@ func (aws *AWS) ShowAthenaColumns() (map[string]bool, error) {
 	return columnSet, nil
 }
 
-
 // ExternalAllocations represents tagged assets outside the scope of kubernetes.
 // "start" and "end" are dates of the format YYYY-MM-DD
 // "aggregator" is the tag used to determine how to allocate those assets, ie namespace, pod, etc.

+ 1 - 1
pkg/cloud/azureprovider.go

@@ -751,7 +751,7 @@ func (az *Azure) NodePricing(key Key) (*Node, error) {
 			VCPUCost: c.CPU,
 			RAMCost:  c.RAM,
 			GPUCost:  c.GPU,
-			GPU: key.(*azureKey).GetGPUCount(),
+			GPU:      key.(*azureKey).GetGPUCount(),
 		}, nil
 	}
 	return &Node{

+ 1 - 0
pkg/cloud/csvretriever.go

@@ -11,6 +11,7 @@ import (
 	"strings"
 	"time"
 )
+
 type CSVRetriever interface {
 	GetCSVReaders(start, end time.Time) ([]*csv.Reader, error)
 }

+ 1 - 1
pkg/clustermanager/clustersendpoints.go

@@ -7,8 +7,8 @@ import (
 
 	"github.com/julienschmidt/httprouter"
 
-	"k8s.io/klog"
 	"github.com/kubecost/cost-model/pkg/util/json"
+	"k8s.io/klog"
 )
 
 // DataEnvelope is a generic wrapper struct for http response data

+ 1 - 1
pkg/costmodel/allocation.go

@@ -348,7 +348,7 @@ func (cm *CostModel) ComputeAllocation(start, end time.Time, resolution time.Dur
 	for _, pod := range podMap {
 		for _, alloc := range pod.Allocations {
 			cluster := alloc.Properties.Cluster
-			nodeName:= alloc.Properties.Node
+			nodeName := alloc.Properties.Node
 			namespace := alloc.Properties.Namespace
 			pod := alloc.Properties.Pod
 			container := alloc.Properties.Container

+ 20 - 20
pkg/costmodel/cluster_helpers_test.go

@@ -711,15 +711,15 @@ func TestBuildGPUCostMap(t *testing.T) {
 			promResult: []*prom.QueryResult{
 				{
 					Metric: map[string]interface{}{
-						"cluster_id": "cluster1",
-						"node": "node1",
-						"instance_type":"type1",
-						"provider_id": "provider1",
+						"cluster_id":    "cluster1",
+						"node":          "node1",
+						"instance_type": "type1",
+						"provider_id":   "provider1",
 					},
 					Values: []*util.Vector{
 						&util.Vector{
 							Timestamp: 0,
-							Value: 0,
+							Value:     0,
 						},
 					},
 				},
@@ -744,15 +744,15 @@ func TestBuildGPUCostMap(t *testing.T) {
 			promResult: []*prom.QueryResult{
 				{
 					Metric: map[string]interface{}{
-						"cluster_id": "cluster1",
-						"node": "node1",
-						"instance_type":"type1",
-						"provider_id": "provider1",
+						"cluster_id":    "cluster1",
+						"node":          "node1",
+						"instance_type": "type1",
+						"provider_id":   "provider1",
 					},
 					Values: []*util.Vector{
 						&util.Vector{
 							Timestamp: 0,
-							Value: 2,
+							Value:     2,
 						},
 					},
 				},
@@ -777,15 +777,15 @@ func TestBuildGPUCostMap(t *testing.T) {
 			promResult: []*prom.QueryResult{
 				{
 					Metric: map[string]interface{}{
-						"cluster_id": "cluster1",
-						"node": "node1",
-						"instance_type":"type1",
-						"provider_id": "provider1",
+						"cluster_id":    "cluster1",
+						"node":          "node1",
+						"instance_type": "type1",
+						"provider_id":   "provider1",
 					},
 					Values: []*util.Vector{
 						&util.Vector{
 							Timestamp: 0,
-							Value: 2,
+							Value:     2,
 						},
 					},
 				},
@@ -818,15 +818,15 @@ func TestBuildGPUCostMap(t *testing.T) {
 			promResult: []*prom.QueryResult{
 				{
 					Metric: map[string]interface{}{
-						"cluster_id": "cluster1",
-						"node": "node1",
-						"instance_type":"type1",
-						"provider_id": "provider1",
+						"cluster_id":    "cluster1",
+						"node":          "node1",
+						"instance_type": "type1",
+						"provider_id":   "provider1",
 					},
 					Values: []*util.Vector{
 						&util.Vector{
 							Timestamp: 0,
-							Value: 2,
+							Value:     2,
 						},
 					},
 				},

+ 11 - 11
pkg/costmodel/containerkeys.go

@@ -13,22 +13,22 @@ var (
 	NewKeyTupleErr = errors.New("NewKeyTuple() Provided key not containing exactly 3 components.")
 
 	// Static Errors for ContainerMetric creation
-	InvalidKeyErr error = errors.New("Not a valid key")
-	NoContainerErr error = errors.New("Prometheus vector does not have container name")
+	InvalidKeyErr      error = errors.New("Not a valid key")
+	NoContainerErr     error = errors.New("Prometheus vector does not have container name")
 	NoContainerNameErr error = errors.New("Prometheus vector does not have string container name")
-	NoPodErr error = errors.New("Prometheus vector does not have pod name")
-	NoPodNameErr error = errors.New("Prometheus vector does not have string pod name")
-	NoNamespaceErr error = errors.New("Prometheus vector does not have namespace")
+	NoPodErr           error = errors.New("Prometheus vector does not have pod name")
+	NoPodNameErr       error = errors.New("Prometheus vector does not have string pod name")
+	NoNamespaceErr     error = errors.New("Prometheus vector does not have namespace")
 	NoNamespaceNameErr error = errors.New("Prometheus vector does not have string namespace")
-	NoNodeNameErr error = errors.New("Prometheus vector does not have string node")
-	NoClusterIDErr error = errors.New("Prometheus vector does not have string cluster_id")
+	NoNodeNameErr      error = errors.New("Prometheus vector does not have string node")
+	NoClusterIDErr     error = errors.New("Prometheus vector does not have string cluster_id")
 )
 
 //--------------------------------------------------------------------------
 //  KeyTuple
 //--------------------------------------------------------------------------
 
-// KeyTuple contains is a utility which parses Namespace, Key, and ClusterID from a 
+// KeyTuple contains is a utility which parses Namespace, Key, and ClusterID from a
 // comma delimitted string.
 type KeyTuple struct {
 	key    string
@@ -103,8 +103,8 @@ func containerMetricKey(ns, podName, containerName, nodeName, clusterID string)
 	return ns + "," + podName + "," + containerName + "," + nodeName + "," + clusterID
 }
 
-// NewContainerMetricFromKey creates a new ContainerMetric instance using a provided comma delimitted 
-// string key. 
+// NewContainerMetricFromKey creates a new ContainerMetric instance using a provided comma delimitted
+// string key.
 func NewContainerMetricFromKey(key string) (*ContainerMetric, error) {
 	s := strings.Split(key, ",")
 	if len(s) == 5 {
@@ -132,7 +132,7 @@ func NewContainerMetricFromValues(ns, podName, containerName, nodeName, clusterI
 	}
 }
 
-// NewContainerMetricsFromPod creates a slice of ContainerMetric instances for each container in the 
+// NewContainerMetricsFromPod creates a slice of ContainerMetric instances for each container in the
 // provided Pod.
 func NewContainerMetricsFromPod(pod *v1.Pod, clusterID string) ([]*ContainerMetric, error) {
 	podName := pod.GetObjectMeta().GetName()

+ 1 - 1
pkg/env/costmodelenv.go

@@ -30,7 +30,7 @@ const (
 	SQLAddressEnvVar               = "SQL_ADDRESS"
 	UseCSVProviderEnvVar           = "USE_CSV_PROVIDER"
 	CSVRegionEnvVar                = "CSV_REGION"
-	CSVEndpointEnvVar 			   = "CSV_ENDPOINT"
+	CSVEndpointEnvVar              = "CSV_ENDPOINT"
 	CSVPathEnvVar                  = "CSV_PATH"
 	ConfigPathEnvVar               = "CONFIG_PATH"
 	CloudProviderAPIKeyEnvVar      = "CLOUD_PROVIDER_API_KEY"

+ 6 - 9
pkg/kubecost/allocation.go

@@ -51,7 +51,7 @@ const ShareNone = "__none__"
 // Assets-style key() function for AllocationSet.
 type Allocation struct {
 	Name                   string                `json:"name"`
-	Properties             *AllocationProperties  `json:"properties,omitempty"`
+	Properties             *AllocationProperties `json:"properties,omitempty"`
 	Window                 Window                `json:"window"`
 	Start                  time.Time             `json:"start"`
 	End                    time.Time             `json:"end"`
@@ -105,7 +105,6 @@ type RawAllocationOnlyData struct {
 	RAMBytesUsageMax float64 `json:"ramByteUsageMax"`
 }
 
-
 // AllocationMatchFunc is a function that can be used to match Allocations by
 // returning true for any given Allocation if a condition is met.
 type AllocationMatchFunc func(*Allocation) bool
@@ -424,7 +423,6 @@ func (a *Allocation) add(that *Allocation) {
 	// Preserve string properties that are matching between the two allocations
 	a.Properties = a.Properties.Intersection(that.Properties)
 
-
 	// Expand the window to encompass both Allocations
 	a.Window = a.Window.Expand(that.Window)
 
@@ -1116,7 +1114,7 @@ func computeIdleCoeffs(options *AllocationAggregationOptions, as *AllocationSet,
 
 		// We need to key the allocations by cluster id
 		clusterID := alloc.Properties.Cluster
-		if clusterID == ""{
+		if clusterID == "" {
 			return nil, fmt.Errorf("ClusterProp is not set")
 		}
 
@@ -1177,7 +1175,6 @@ func (a *Allocation) generateKey(aggregateBy []string) string {
 	// identifies allocations.
 	names := []string{}
 
-
 	for _, agg := range aggregateBy {
 		switch true {
 		case agg == AllocationClusterProp:
@@ -1193,9 +1190,9 @@ func (a *Allocation) generateKey(aggregateBy []string) string {
 				controllerKind = UnallocatedSuffix
 			}
 			names = append(names, controllerKind)
-	case agg == AllocationDaemonSetProp || agg == AllocationStatefulSetProp || agg == AllocationDeploymentProp || agg == AllocationJobProp:
+		case agg == AllocationDaemonSetProp || agg == AllocationStatefulSetProp || agg == AllocationDeploymentProp || agg == AllocationJobProp:
 			controller := a.Properties.Controller
-			if agg != a.Properties.ControllerKind || controller == ""{
+			if agg != a.Properties.ControllerKind || controller == "" {
 				// The allocation does not have the specified controller kind
 				controller = UnallocatedSuffix
 			}
@@ -1215,7 +1212,7 @@ func (a *Allocation) generateKey(aggregateBy []string) string {
 			names = append(names, a.Properties.Container)
 		case agg == AllocationServiceProp:
 			services := a.Properties.Services
-			if services == nil || len(services) == 0  {
+			if services == nil || len(services) == 0 {
 				// Indicate that allocation has no services
 				names = append(names, UnallocatedSuffix)
 			} else {
@@ -1254,7 +1251,7 @@ func (a *Allocation) generateKey(aggregateBy []string) string {
 				names = append(names, labelNames...)
 			}
 		case strings.HasPrefix(agg, "annotation:"):
-			annotations:= a.Properties.Annotations
+			annotations := a.Properties.Annotations
 			if annotations == nil {
 				// Indicate that allocation has no annotations
 				names = append(names, UnallocatedSuffix)

+ 1 - 1
pkg/kubecost/asset.go

@@ -1916,7 +1916,7 @@ func (n *Node) Clone() Asset {
 		RAMBreakdown: n.RAMBreakdown.Clone(),
 		CPUCost:      n.CPUCost,
 		GPUCost:      n.GPUCost,
-		GPUCount:      n.GPUCount,
+		GPUCount:     n.GPUCount,
 		RAMCost:      n.RAMCost,
 		Preemptible:  n.Preemptible,
 		Discount:     n.Discount,