Updated deps, go.19 migration, nginx template work
This commit is contained in:
@ -264,3 +264,38 @@ func (m *Model) Request() error {
|
||||
logger.Info("Request for certificate for: #%d %v was completed", m.ID, m.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTemplate will convert the Model to a Template
|
||||
func (m *Model) GetTemplate() Template {
|
||||
domainNames, _ := m.DomainNames.AsStringArray()
|
||||
|
||||
t := Template{
|
||||
ID: m.ID,
|
||||
CreatedOn: m.CreatedOn.Time.String(),
|
||||
ModifiedOn: m.ModifiedOn.Time.String(),
|
||||
ExpiresOn: m.ExpiresOn.AsString(),
|
||||
Type: m.Type,
|
||||
UserID: m.UserID,
|
||||
CertificateAuthorityID: m.CertificateAuthorityID,
|
||||
DNSProviderID: m.DNSProviderID,
|
||||
Name: m.Name,
|
||||
DomainNames: domainNames,
|
||||
Status: m.Status,
|
||||
IsECC: m.IsECC,
|
||||
// These are helpers for template generation
|
||||
IsCustom: m.Type == TypeCustom,
|
||||
IsAcme: m.Type != TypeCustom,
|
||||
IsProvided: m.ID > 0 && m.Status == StatusProvided,
|
||||
Folder: m.GetFolder(),
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
// GetFolder returns the folder where these certs should exist
|
||||
func (m *Model) GetFolder() string {
|
||||
if m.Type == TypeCustom {
|
||||
return fmt.Sprintf("%s/custom_ssl/npm-%d", config.Configuration.DataFolder, m.ID)
|
||||
}
|
||||
return fmt.Sprintf("%s/npm-%d", config.Configuration.Acmesh.CertHome, m.ID)
|
||||
}
|
||||
|
22
backend/internal/entity/certificate/template.go
Normal file
22
backend/internal/entity/certificate/template.go
Normal file
@ -0,0 +1,22 @@
|
||||
package certificate
|
||||
|
||||
// Template is the model given to the template parser, converted from the Model
|
||||
type Template struct {
|
||||
ID int
|
||||
CreatedOn string
|
||||
ModifiedOn string
|
||||
ExpiresOn string
|
||||
Type string
|
||||
UserID int
|
||||
CertificateAuthorityID int
|
||||
DNSProviderID int
|
||||
Name string
|
||||
DomainNames []string
|
||||
Status string
|
||||
IsECC int
|
||||
// These are helpers for template generation
|
||||
IsCustom bool
|
||||
IsAcme bool // non-custom
|
||||
IsProvided bool
|
||||
Folder string
|
||||
}
|
Reference in New Issue
Block a user