delete cert info when do not bind it

This commit is contained in:
凡羊羊 2019-11-12 20:23:46 +08:00
parent 3d16d353df
commit 10c7eaf2a1

View File

@ -134,7 +134,7 @@ func (g *GatewayAction) UpdateHTTPRule(req *apimodel.UpdateHTTPRuleStruct) (stri
tx.Rollback()
return "", err
}
if rule == nil {
if rule == nil || rule.UUID == "" { // rule won't be nil
tx.Rollback()
return "", fmt.Errorf("HTTPRule dosen't exist based on uuid(%s)", req.HTTPRuleID)
}
@ -156,6 +156,13 @@ func (g *GatewayAction) UpdateHTTPRule(req *apimodel.UpdateHTTPRuleStruct) (stri
return "", err
}
rule.CertificateID = req.CertificateID
} else {
// if certificateID is '' means do not need https cetificate any more, so delete Certificate
if err := g.dbmanager.CertificateDaoTransactions(tx).DeleteCertificateByID(rule.CertificateID); err != nil {
tx.Rollback()
return "", err
}
rule.CertificateID = ""
}
if len(req.RuleExtensions) > 0 {
// delete old RuleExtensions