-
Notifications
You must be signed in to change notification settings - Fork 3
/
runner.go
40 lines (32 loc) · 857 Bytes
/
runner.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
package k8s
import (
"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes"
"github.com/spigell/pulumi-hcloud-kube-hetzner/internal/k8s/addons"
manager "github.com/spigell/pulumi-hcloud-kube-hetzner/internal/k8s/cluster-manager"
"github.com/spigell/pulumi-hcloud-kube-hetzner/internal/program"
)
type Runner struct {
ctx *program.Context
addons []addons.Addon
manager *manager.ClusterManager
}
func NewRunner(ctx *program.Context, addons []addons.Addon) *Runner {
return &Runner{
ctx: ctx,
addons: addons,
}
}
func (r *Runner) WithClusterManager(m *manager.ClusterManager) *Runner {
r.manager = m
return r
}
func (r *Runner) Run(prov *kubernetes.Provider) error {
for _, addon := range r.addons {
if addon.Enabled() {
if err := addon.Manage(r.ctx, prov, r.manager); err != nil {
return err
}
}
}
return nil
}