-
Notifications
You must be signed in to change notification settings - Fork 22
/
resource.go
55 lines (43 loc) · 1.38 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
package tccpoutputs
import (
"context"
infrastructurev1alpha3 "github.com/giantswarm/apiextensions/v6/pkg/apis/infrastructure/v1alpha3"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
)
const (
Name = "tccpoutputs"
)
type Config struct {
Logger micrologger.Logger
Route53Enabled bool
ToClusterFunc func(ctx context.Context, v interface{}) (infrastructurev1alpha3.AWSCluster, error)
}
// Resource implements an operatorkit resource and provides a mechanism to fetch
// information from Cloud Formation stack outputs of the Tenant Cluster Control
// Plane stack.
//
// The TCCP manages the VPC Peering Connection. The peering connection ID is
// added to the controller context and used in the CPF stack.
type Resource struct {
logger micrologger.Logger
route53Enabled bool
toClusterFunc func(ctx context.Context, v interface{}) (infrastructurev1alpha3.AWSCluster, error)
}
func New(config Config) (*Resource, error) {
if config.Logger == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.Logger must not be empty", config)
}
if config.ToClusterFunc == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.ToClusterFunc must not be empty", config)
}
r := &Resource{
logger: config.Logger,
route53Enabled: config.Route53Enabled,
toClusterFunc: config.ToClusterFunc,
}
return r, nil
}
func (r *Resource) Name() string {
return Name
}