rds postpaid instance create fix

This commit is contained in:
tangbin
2020-06-17 15:39:37 +08:00
parent 41f97d32fb
commit 6ecebc5f2b
+6 -3
View File
@@ -355,14 +355,17 @@ func (man *SDBInstanceManager) ValidateCreateData(ctx context.Context, userCred
if err != nil {
return nil, httperrors.NewInputParameterError("invalid duration %s", input.Duration)
}
if !region.GetDriver().IsSupportedBillingCycle(billingCycle, man.KeywordPlural()) {
return nil, httperrors.NewInputParameterError("unsupported duration %s", input.Duration)
}
if !utils.IsInStringArray(input.BillingType, []string{billing_api.BILLING_TYPE_PREPAID, billing_api.BILLING_TYPE_POSTPAID}) {
input.BillingType = billing_api.BILLING_TYPE_PREPAID
}
if input.BillingType == billing_api.BILLING_TYPE_PREPAID {
if !region.GetDriver().IsSupportedBillingCycle(billingCycle, man.KeywordPlural()) {
return nil, httperrors.NewInputParameterError("unsupported duration %s", input.Duration)
}
}
tm := time.Time{}
input.BillingCycle = billingCycle.String()
input.ExpiredAt = billingCycle.EndAt(tm)