mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-06-19 07:36:59 +00:00
feat(cert): add Status, LastError, LastAttemptAt fields
This commit is contained in:
@@ -17,6 +17,12 @@ const (
|
||||
AutoCertDisabled = -1
|
||||
CertChallengeMethodHTTP01 = "http01"
|
||||
CertChallengeMethodDNS01 = "dns01"
|
||||
|
||||
// CertStatus values track the most recent issuance attempt outcome.
|
||||
// Empty string represents pre-migration / imported certificates.
|
||||
CertStatusPending = "pending"
|
||||
CertStatusSuccess = "success"
|
||||
CertStatusFailure = "failure"
|
||||
)
|
||||
|
||||
type CertDomains []string
|
||||
@@ -52,6 +58,9 @@ type Cert struct {
|
||||
RevokeOld bool `json:"revoke_old"`
|
||||
LastAutoRenewAt *time.Time `json:"-"`
|
||||
LastAutoRenewError string `json:"-"`
|
||||
Status string `json:"status"`
|
||||
LastError string `json:"last_error"`
|
||||
LastAttemptAt *time.Time `json:"last_attempt_at"`
|
||||
}
|
||||
|
||||
func FirstCert(confName string) (c Cert, err error) {
|
||||
|
||||
+13
-1
@@ -50,6 +50,9 @@ func newCert(db *gorm.DB, opts ...gen.DOOption) cert {
|
||||
_cert.RevokeOld = field.NewBool(tableName, "revoke_old")
|
||||
_cert.LastAutoRenewAt = field.NewTime(tableName, "last_auto_renew_at")
|
||||
_cert.LastAutoRenewError = field.NewString(tableName, "last_auto_renew_error")
|
||||
_cert.Status = field.NewString(tableName, "status")
|
||||
_cert.LastError = field.NewString(tableName, "last_error")
|
||||
_cert.LastAttemptAt = field.NewTime(tableName, "last_attempt_at")
|
||||
_cert.DnsCredential = certBelongsToDnsCredential{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
@@ -93,6 +96,9 @@ type cert struct {
|
||||
RevokeOld field.Bool
|
||||
LastAutoRenewAt field.Time
|
||||
LastAutoRenewError field.String
|
||||
Status field.String
|
||||
LastError field.String
|
||||
LastAttemptAt field.Time
|
||||
DnsCredential certBelongsToDnsCredential
|
||||
|
||||
ACMEUser certBelongsToACMEUser
|
||||
@@ -134,6 +140,9 @@ func (c *cert) updateTableName(table string) *cert {
|
||||
c.RevokeOld = field.NewBool(table, "revoke_old")
|
||||
c.LastAutoRenewAt = field.NewTime(table, "last_auto_renew_at")
|
||||
c.LastAutoRenewError = field.NewString(table, "last_auto_renew_error")
|
||||
c.Status = field.NewString(table, "status")
|
||||
c.LastError = field.NewString(table, "last_error")
|
||||
c.LastAttemptAt = field.NewTime(table, "last_attempt_at")
|
||||
|
||||
c.fillFieldMap()
|
||||
|
||||
@@ -150,7 +159,7 @@ func (c *cert) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
}
|
||||
|
||||
func (c *cert) fillFieldMap() {
|
||||
c.fieldMap = make(map[string]field.Expr, 24)
|
||||
c.fieldMap = make(map[string]field.Expr, 27)
|
||||
c.fieldMap["id"] = c.ID
|
||||
c.fieldMap["created_at"] = c.CreatedAt
|
||||
c.fieldMap["updated_at"] = c.UpdatedAt
|
||||
@@ -173,6 +182,9 @@ func (c *cert) fillFieldMap() {
|
||||
c.fieldMap["revoke_old"] = c.RevokeOld
|
||||
c.fieldMap["last_auto_renew_at"] = c.LastAutoRenewAt
|
||||
c.fieldMap["last_auto_renew_error"] = c.LastAutoRenewError
|
||||
c.fieldMap["status"] = c.Status
|
||||
c.fieldMap["last_error"] = c.LastError
|
||||
c.fieldMap["last_attempt_at"] = c.LastAttemptAt
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user