Skip to content

Commit

Permalink
Merge pull request #24 from MZC-CSC/develop
Browse files Browse the repository at this point in the history
fix: change the product family value to Server to query the price information of the ncp provider
  • Loading branch information
MZC-CSC authored Dec 4, 2024
2 parents 7d31ab8 + 8303c4d commit 7d38be6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 11 additions & 1 deletion internal/core/cost/price_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ type PriceCollector interface {
FetchPriceInfos(context.Context, RecommendSpecParam) (EstimateCostInfos, error)
}

const (
productFamily = "ComputeInstance"
ncpProductFamily = "Server"
)

var (
onDemandPricingPolicyMap = map[string]string{
"aws": "OnDemand",
Expand Down Expand Up @@ -85,8 +90,13 @@ func (s *SpiderPriceCollector) FetchPriceInfos(ctx context.Context, param Recomm
ConnectionName: connectionName,
FilterList: s.generateFilter(param),
}
pf := productFamily

if strings.Contains(strings.ToLower(param.ProviderName), "ncp") {
pf = ncpProductFamily
}

result, err := s.sc.GetPriceInfoWithContext(ctx, param.RegionName, req)
result, err := s.sc.GetPriceInfoWithContext(ctx, pf, param.RegionName, req)

if err != nil {

Expand Down
8 changes: 2 additions & 6 deletions internal/infra/outbound/spider/price.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ import (
"github.com/rs/zerolog/log"
)

const (
productFamily = "ComputeInstance"
)

func (s *SpiderClient) GetPriceInfoWithContext(ctx context.Context, regionName string, body PriceInfoReq) (CloudPriceDataRes, error) {
func (s *SpiderClient) GetPriceInfoWithContext(ctx context.Context, pf, regionName string, body PriceInfoReq) (CloudPriceDataRes, error) {

var cloudPriceData CloudPriceDataRes

url := s.withUrl(fmt.Sprintf("/priceinfo/%s/%s", productFamily, regionName))
url := s.withUrl(fmt.Sprintf("/priceinfo/%s/%s", pf, regionName))

marshalledBody, err := json.Marshal(body)
if err != nil {
Expand Down

0 comments on commit 7d38be6

Please sign in to comment.