diff --git a/internal/core/cost/price_collector.go b/internal/core/cost/price_collector.go index 5547a9a..cc855ad 100644 --- a/internal/core/cost/price_collector.go +++ b/internal/core/cost/price_collector.go @@ -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", @@ -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 { diff --git a/internal/infra/outbound/spider/price.go b/internal/infra/outbound/spider/price.go index 6608917..6ba0ca2 100644 --- a/internal/infra/outbound/spider/price.go +++ b/internal/infra/outbound/spider/price.go @@ -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 {