forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
certificate_manager.go
46 lines (37 loc) · 1.34 KB
/
certificate_manager.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
42
43
44
45
46
package iam
type CertificateManager struct {
certificateUploader certificateUploader
certificateDescriber certificateDescriber
certificateDeleter certificateDeleter
}
type Certificate struct {
Name string
Body string
ARN string
Chain string
}
type certificateUploader interface {
Upload(certificatePath, privateKeyPath, chainPath, certificateName string) error
}
type certificateDescriber interface {
Describe(certificateName string) (Certificate, error)
}
type certificateDeleter interface {
Delete(certificateName string) error
}
func NewCertificateManager(certificateUploader certificateUploader, certificateDescriber certificateDescriber, certificateDeleter certificateDeleter) CertificateManager {
return CertificateManager{
certificateUploader: certificateUploader,
certificateDescriber: certificateDescriber,
certificateDeleter: certificateDeleter,
}
}
func (c CertificateManager) Create(certificatePath, privateKeyPath, chainPath, certificateName string) error {
return c.certificateUploader.Upload(certificatePath, privateKeyPath, chainPath, certificateName)
}
func (c CertificateManager) Delete(certificateName string) error {
return c.certificateDeleter.Delete(certificateName)
}
func (c CertificateManager) Describe(certificateName string) (Certificate, error) {
return c.certificateDescriber.Describe(certificateName)
}