/
certificate.entity.go
41 lines (33 loc) · 1.09 KB
/
certificate.entity.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package certificate
import (
"time"
"github.com/cloudslit/deca/internal/schema"
"github.com/cloudslit/deca/pkg/util/structure"
)
type SchemaCertificate schema.Certificate
func (a SchemaCertificate) ToCertificate() *Certificate {
item := new(Certificate)
structure.Copy(a, item)
return item
}
type Certificate struct {
SerialNumber string `json:"serial_number"`
AuthorityKeyIdentifier string `json:"authority_key_identifier"`
CertPem string `json:"cert_pem"`
NotBefore time.Time `json:"not_before"`
NotAfter time.Time `json:"not_after"`
MetaData map[string]interface{} `json:"meta_data"`
}
func (a Certificate) ToSchemaCertificate() *schema.Certificate {
item := new(schema.Certificate)
structure.Copy(a, item)
return item
}
type Certificates []*Certificate
func (a Certificates) ToSchemaCertificates() []*schema.Certificate {
list := make([]*schema.Certificate, len(a))
for i, item := range a {
list[i] = item.ToSchemaCertificate()
}
return list
}