This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
cluster.go
98 lines (82 loc) · 2.27 KB
/
cluster.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
package controller
import (
"github.com/giantswarm/apiextensions/v3/pkg/apis/provider/v1alpha1"
"github.com/giantswarm/certs/v3/pkg/certs"
"github.com/giantswarm/k8sclient/v5/pkg/k8sclient"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
"github.com/giantswarm/operatorkit/v5/pkg/controller"
workloadcluster "github.com/giantswarm/tenantcluster/v4/pkg/tenantcluster"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"github.com/giantswarm/kvm-operator/v4/pkg/label"
"github.com/giantswarm/kvm-operator/v4/pkg/project"
)
type ClusterConfig struct {
CertsSearcher certs.Interface
K8sClient k8sclient.Interface
Logger micrologger.Logger
WorkloadCluster workloadcluster.Interface
ClusterRoleGeneral string
ClusterRolePSP string
DNSServers string
IgnitionPath string
NTPServers string
OIDC ClusterConfigOIDC
Proxy Proxy
SSOPublicKey string
DockerhubToken string
RegistryDomain string
RegistryMirrors []string
}
// ClusterConfigOIDC represents the configuration of the OIDC authorization
// provider.
type ClusterConfigOIDC struct {
ClientID string
IssuerURL string
UsernameClaim string
UsernamePrefix string
GroupsClaim string
GroupsPrefix string
}
type Proxy struct {
HTTP string
HTTPS string
NoProxy []string
}
type Cluster struct {
*controller.Controller
}
func NewCluster(config ClusterConfig) (*Cluster, error) {
var err error
if config.K8sClient == nil {
return nil, microerror.Maskf(invalidConfigError, "%T.K8sClient must not be empty", config)
}
resources, err := newClusterResources(config)
if err != nil {
return nil, microerror.Mask(err)
}
var operatorkitController *controller.Controller
{
c := controller.Config{
K8sClient: config.K8sClient,
Logger: config.Logger,
Resources: resources,
NewRuntimeObjectFunc: func() runtime.Object {
return new(v1alpha1.KVMConfig)
},
Selector: labels.SelectorFromSet(map[string]string{
label.OperatorVersion: project.Version(),
}),
Name: project.Name(),
}
operatorkitController, err = controller.New(c)
if err != nil {
return nil, microerror.Mask(err)
}
}
c := &Cluster{
Controller: operatorkitController,
}
return c, nil
}