/
resource.go
101 lines (88 loc) · 2.96 KB
/
resource.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package tccpn
import (
"github.com/giantswarm/k8sclient/v7/pkg/k8sclient"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
"github.com/giantswarm/aws-operator/v16/service/internal/changedetection"
"github.com/giantswarm/aws-operator/v16/service/internal/cloudtags"
"github.com/giantswarm/aws-operator/v16/service/internal/encrypter"
"github.com/giantswarm/aws-operator/v16/service/internal/hamaster"
"github.com/giantswarm/aws-operator/v16/service/internal/images"
event "github.com/giantswarm/aws-operator/v16/service/internal/recorder"
)
const (
// Name is the identifier of the resource.
Name = "tccpn"
)
type Config struct {
CloudTags cloudtags.Interface
Detection *changedetection.TCCPN
Encrypter encrypter.Interface
Event event.Interface
HAMaster hamaster.Interface
Images images.Interface
K8sClient k8sclient.Interface
Logger micrologger.Logger
InstallationName string
Route53Enabled bool
}
// Resource implements the TCCPN resource, which stands for Tenant Cluster
// Control Plane Node. We manage a dedicated Cloud Formation stack for each node
// pool.
type Resource struct {
cloudTags cloudtags.Interface
detection *changedetection.TCCPN
encrypter encrypter.Interface
event event.Interface
haMaster hamaster.Interface
images images.Interface
k8sClient k8sclient.Interface
logger micrologger.Logger
installationName string
route53Enabled bool
}
func New(config Config) (*Resource, error) {
if config.CloudTags == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.CloudTags must not be empty", config)
}
if config.Detection == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.Detection must not be empty", config)
}
if config.Encrypter == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.Encrypter must not be empty", config)
}
if config.Event == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.Event must not be empty", config)
}
if config.HAMaster == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.HAMaster must not be empty", config)
}
if config.Images == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.Images must not be empty", config)
}
if config.K8sClient == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.K8sClient must not be empty", config)
}
if config.Logger == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.Logger must not be empty", config)
}
if config.InstallationName == "" {
return nil, microerror.Maskf(invalidConfigError, "%T.InstallationName must not be empty", config)
}
r := &Resource{
cloudTags: config.CloudTags,
detection: config.Detection,
encrypter: config.Encrypter,
event: config.Event,
haMaster: config.HAMaster,
images: config.Images,
k8sClient: config.K8sClient,
logger: config.Logger,
installationName: config.InstallationName,
route53Enabled: config.Route53Enabled,
}
return r, nil
}
func (r *Resource) Name() string {
return Name
}