Просмотр исходного кода

Merge branch 'develop' into scaleway

Ajay Tripathy 3 лет назад
Родитель
Сommit
712cebd61c
2 измененных файлов с 31 добавлено и 16 удалено
  1. 18 13
      pkg/cloud/azureprovider.go
  2. 13 3
      pkg/kubecost/asset.go

+ 18 - 13
pkg/cloud/azureprovider.go

@@ -55,6 +55,9 @@ var (
 		"us": "us",
 		"za": "southafrica",
 		"no": "norway",
+		"ch": "switzerland",
+		"de": "germany",
+		"ue": "uae",
 	}
 
 	//mtBasic, _     = regexp.Compile("^BASIC.A\\d+[_Promo]*$")
@@ -561,19 +564,21 @@ func (az *Azure) GetAzureStorageConfig(forceReload bool, cp *CustomPricing) (*Az
 	asc, err := az.loadAzureStorageConfig(forceReload)
 	if err != nil {
 		log.Errorf("Error, %s", err.Error())
-	}
-	// To support already configured users, subscriptionID may not be set in secret in which case, the subscriptionID
-	// for the rate card API is used
-	if asc.SubscriptionId == "" {
-		asc.SubscriptionId = defaultSubscriptionID
-	}
-	// check for required fields
-	if asc != nil && asc.AccessKey != "" && asc.AccountName != "" && asc.ContainerName != "" && asc.SubscriptionId == "" {
-		az.serviceAccountChecks.set("hasStorage", &ServiceAccountCheck{
-			Message: "Azure Storage Config exists",
-			Status:  true,
-		})
-		return asc, nil
+	} else if asc != nil {
+		// To support already configured users, subscriptionID may not be set in secret in which case, the subscriptionID
+		// for the rate card API is used
+		if asc.SubscriptionId == "" {
+			asc.SubscriptionId = defaultSubscriptionID
+		}
+		// check for required fields
+		if asc.AccessKey != "" && asc.AccountName != "" && asc.ContainerName != "" && asc.SubscriptionId == "" {
+			az.serviceAccountChecks.set("hasStorage", &ServiceAccountCheck{
+				Message: "Azure Storage Config exists",
+				Status:  true,
+			})
+			
+			return asc, nil
+		}
 	}
 
 	az.serviceAccountChecks.set("hasStorage", &ServiceAccountCheck{

+ 13 - 3
pkg/kubecost/asset.go

@@ -2484,9 +2484,19 @@ func (as *AssetSet) AggregateBy(aggregateBy []string, opts *AssetAggregationOpti
 		sa := NewSharedAsset(name, as.Window.Clone())
 		sa.Cost = hourlyCost * hours
 
-		err := aggSet.Insert(sa)
-		if err != nil {
-			return err
+		// Insert shared asset if it passes all filters
+		insert := true
+		for _, ff := range opts.FilterFuncs {
+			if !ff(sa) {
+				insert = false
+				break
+			}
+		}
+		if insert {
+			err := aggSet.Insert(sa)
+			if err != nil {
+				return err
+			}
 		}
 	}