/
resource.go
49 lines (41 loc) · 1.13 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
package updateg8scontrolplanes
import (
"github.com/giantswarm/k8sclient"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
)
const (
Name = "updateg8scontrolplanes"
)
type Config struct {
K8sClient k8sclient.Interface
Logger micrologger.Logger
}
// Resource implements the operatorkit resource interface to propagate the
// following version labels from Cluster CRs to G8sControlPlane CRs.
//
// cluster-operator.giantswarm.io/version
// release.giantswarm.io/version
//
// This process ensures to distribute the right version labels among CAPI CRs
// during Tenant Cluster upgrades.
type Resource struct {
k8sClient k8sclient.Interface
logger micrologger.Logger
}
func New(config Config) (*Resource, error) {
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)
}
r := &Resource{
k8sClient: config.K8sClient,
logger: config.Logger,
}
return r, nil
}
func (r *Resource) Name() string {
return Name
}