generated from giantswarm/template-operator
/
resource.go
54 lines (45 loc) · 1.3 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
package clustersecret
import (
"github.com/giantswarm/k8sclient/v7/pkg/k8sclient"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
"github.com/giantswarm/cluster-apps-operator/v2/flag/service/proxy"
)
const (
// Name is the identifier of the resource.
Name = "clustersecret"
)
// Config represents the configuration used to create a new clustersecret
// resource.
type Config struct {
K8sClient k8sclient.Interface
Logger micrologger.Logger
Proxy proxy.Proxy
}
// Resource implements the clustersecret resource.
type Resource struct {
k8sClient k8sclient.Interface
logger micrologger.Logger
proxy proxy.Proxy
}
// New creates a new configured secret state getter resource managing
// cluster secrets.
//
// https://pkg.go.dev/github.com/giantswarm/operatorkit/v4/pkg/resource/k8s/secretresource#StateGetter
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,
proxy: config.Proxy,
}
return r, nil
}
func (r *Resource) Name() string {
return Name
}