|
|
@@ -382,7 +382,7 @@ type Azure struct {
|
|
|
Clientset clustercache.ClusterCache
|
|
|
Config *ProviderConfig
|
|
|
ServiceAccountChecks map[string]*ServiceAccountCheck
|
|
|
- RateCardPricingStatus string
|
|
|
+ RateCardPricingError error
|
|
|
}
|
|
|
|
|
|
type azureKey struct {
|
|
|
@@ -732,7 +732,7 @@ func (az *Azure) DownloadPricingData() error {
|
|
|
|
|
|
config, err := az.GetConfig()
|
|
|
if err != nil {
|
|
|
- az.RateCardPricingStatus = err.Error()
|
|
|
+ az.RateCardPricingError = err
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
@@ -749,7 +749,7 @@ func (az *Azure) DownloadPricingData() error {
|
|
|
credentialsConfig := auth.NewClientCredentialsConfig(config.AzureClientID, config.AzureClientSecret, config.AzureTenantID)
|
|
|
a, err := credentialsConfig.Authorizer()
|
|
|
if err != nil {
|
|
|
- az.RateCardPricingStatus = err.Error()
|
|
|
+ az.RateCardPricingError = err
|
|
|
return err
|
|
|
}
|
|
|
authorizer = a
|
|
|
@@ -761,7 +761,7 @@ func (az *Azure) DownloadPricingData() error {
|
|
|
if err != nil { // Failed to create authorizer from environment, try from file
|
|
|
a, err := auth.NewAuthorizerFromFile(azure.PublicCloud.ResourceManagerEndpoint)
|
|
|
if err != nil {
|
|
|
- az.RateCardPricingStatus = err.Error()
|
|
|
+ az.RateCardPricingError = err
|
|
|
return err
|
|
|
}
|
|
|
authorizer = a
|
|
|
@@ -788,13 +788,13 @@ func (az *Azure) DownloadPricingData() error {
|
|
|
klog.Infof("Using ratecard query %s", rateCardFilter)
|
|
|
result, err := rcClient.Get(context.TODO(), rateCardFilter)
|
|
|
if err != nil {
|
|
|
- az.RateCardPricingStatus = err.Error()
|
|
|
+ az.RateCardPricingError = err
|
|
|
return err
|
|
|
}
|
|
|
allPrices := make(map[string]*AzurePricing)
|
|
|
regions, err := getRegions("compute", sClient, providersClient, config.AzureSubscriptionID)
|
|
|
if err != nil {
|
|
|
- az.RateCardPricingStatus = err.Error()
|
|
|
+ az.RateCardPricingError = err
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
@@ -917,7 +917,7 @@ func (az *Azure) DownloadPricingData() error {
|
|
|
}
|
|
|
|
|
|
az.Pricing = allPrices
|
|
|
- az.RateCardPricingStatus = ""
|
|
|
+ az.RateCardPricingError = nil
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -1387,9 +1387,13 @@ const rateCardPricingSource = "Rate Card API"
|
|
|
// PricingSourceStatus returns the status of the rate card api
|
|
|
func (az *Azure) PricingSourceStatus() map[string]*PricingSource {
|
|
|
sources := make(map[string]*PricingSource)
|
|
|
+ errMsg := ""
|
|
|
+ if az.RateCardPricingError != nil {
|
|
|
+ errMsg = az.RateCardPricingError.Error()
|
|
|
+ }
|
|
|
rcps := &PricingSource {
|
|
|
Name: rateCardPricingSource,
|
|
|
- Error: az.RateCardPricingStatus,
|
|
|
+ Error: errMsg,
|
|
|
}
|
|
|
if rcps.Error != "" {
|
|
|
rcps.Available = false
|