Sfoglia il codice sorgente

Merge pull request #1177 from kubecost/sean/azure-container-path

Add container path config
Sean Holcomb 4 anni fa
parent
commit
1ac8ea3a62
2 ha cambiato i file con 19 aggiunte e 2 eliminazioni
  1. 4 2
      pkg/cloud/azureprovider.go
  2. 15 0
      pkg/kubecost/asset.go

+ 4 - 2
pkg/cloud/azureprovider.go

@@ -468,6 +468,7 @@ type AzureStorageConfig struct {
 	AccountName    string `json:"azureStorageAccount"`
 	AccessKey      string `json:"azureStorageAccessKey"`
 	ContainerName  string `json:"azureStorageContainer"`
+	ContainerPath  string `json:"azureContainerPath"`
 	AzureCloud     string `json:"azureCloud"`
 }
 
@@ -477,6 +478,7 @@ func (asc *AzureStorageConfig) IsEmpty() bool {
 		asc.AccountName == "" &&
 		asc.AccessKey == "" &&
 		asc.ContainerName == "" &&
+		asc.ContainerPath == "" &&
 		asc.AzureCloud == ""
 }
 
@@ -1268,9 +1270,9 @@ func (az *Azure) PricingSourceStatus() map[string]*PricingSource {
 		errMsg = az.RateCardPricingError.Error()
 	}
 	rcps := &PricingSource{
-		Name:  rateCardPricingSource,
+		Name:    rateCardPricingSource,
 		Enabled: true,
-		Error: errMsg,
+		Error:   errMsg,
 	}
 	if rcps.Error != "" {
 		rcps.Available = false

+ 15 - 0
pkg/kubecost/asset.go

@@ -2970,6 +2970,21 @@ func (asr *AssetSetRange) InsertRange(that *AssetSetRange) error {
 	return err
 }
 
+// IsEmpty returns false if AssetSetRange contains a single AssetSet that is not empty
+func (asr *AssetSetRange) IsEmpty() bool {
+	if asr == nil || asr.Length() == 0 {
+		return true
+	}
+	asr.RLock()
+	defer asr.RUnlock()
+	for _, asset := range asr.assets {
+		if !asset.IsEmpty() {
+			return false
+		}
+	}
+	return true
+}
+
 func (asr *AssetSetRange) MarshalJSON() ([]byte, error) {
 	asr.RLock()
 	defer asr.RUnlock()