Jelajahi Sumber

Merge branch 'master' of https://github.com/kubecost/cost-model into AjayTripathy-add-rcs

Ajay Tripathy 4 tahun lalu
induk
melakukan
7eb94e8927
3 mengubah file dengan 9 tambahan dan 2 penghapusan
  1. 3 0
      pkg/costmodel/router.go
  2. 1 1
      pkg/env/costmodelenv.go
  3. 5 1
      test/cloud_test.go

+ 3 - 0
pkg/costmodel/router.go

@@ -1092,6 +1092,9 @@ func (a *Accesses) GetPod(w http.ResponseWriter, r *http.Request, ps httprouter.
 	// TODO: ClusterCache API could probably afford to have some better filtering
 	// TODO: ClusterCache API could probably afford to have some better filtering
 	allPods := a.ClusterCache.GetAllPods()
 	allPods := a.ClusterCache.GetAllPods()
 	for _, pod := range allPods {
 	for _, pod := range allPods {
+		for _, container := range pod.Spec.Containers {
+			container.Env = make([]v1.EnvVar, 0)
+		}
 		if pod.Namespace == podNamespace && pod.Name == podName {
 		if pod.Namespace == podNamespace && pod.Name == podName {
 			body, err := json.Marshal(pod)
 			body, err := json.Marshal(pod)
 			if err != nil {
 			if err != nil {

+ 1 - 1
pkg/env/costmodelenv.go

@@ -128,7 +128,7 @@ func GetPricingConfigmapName() string {
 // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
 // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
 // the AWS access key for authentication
 // the AWS access key for authentication
 func GetAppVersion() string {
 func GetAppVersion() string {
-	return Get(AppVersionEnvVar, "1.89.0-rc.0")
+	return Get(AppVersionEnvVar, "1.89.0-rc.1")
 }
 }
 
 
 // IsEmitNamespaceAnnotationsMetric returns true if cost-model is configured to emit the kube_namespace_annotations metric
 // IsEmitNamespaceAnnotationsMetric returns true if cost-model is configured to emit the kube_namespace_annotations metric

+ 5 - 1
test/cloud_test.go

@@ -98,11 +98,15 @@ func TestPVPriceFromCSV(t *testing.T) {
 	pv := &v1.PersistentVolume{}
 	pv := &v1.PersistentVolume{}
 	pv.Name = nameWant
 	pv.Name = nameWant
 
 
+	confMan := config.NewConfigFileManager(&config.ConfigFileManagerOpts{
+		LocalConfigPath: "./",
+	})
+
 	wantPrice := "0.1337"
 	wantPrice := "0.1337"
 	c := &cloud.CSVProvider{
 	c := &cloud.CSVProvider{
 		CSVLocation: "../configs/pricing_schema_pv.csv",
 		CSVLocation: "../configs/pricing_schema_pv.csv",
 		CustomProvider: &cloud.CustomProvider{
 		CustomProvider: &cloud.CustomProvider{
-			Config: cloud.NewProviderConfig("../configs/default.json"),
+			Config: cloud.NewProviderConfig(confMan, "../configs/default.json"),
 		},
 		},
 	}
 	}
 	c.DownloadPricingData()
 	c.DownloadPricingData()