Merge pull request #6854 from tb365/bugfix/tb-bugfix-0617

rds postpaid instance create fix
This commit is contained in:
Zexi Li
2020-06-17 18:51:41 +08:00
committed by GitHub
+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)