forked from joeholley/supergloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_reconciler.sk.go
47 lines (39 loc) · 1.6 KB
/
install_reconciler.sk.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
// Code generated by solo-kit. DO NOT EDIT.
package v1
import (
"github.com/solo-io/go-utils/contextutils"
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
"github.com/solo-io/solo-kit/pkg/api/v1/reconcile"
"github.com/solo-io/solo-kit/pkg/api/v1/resources"
)
// Option to copy anything from the original to the desired before writing. Return value of false means don't update
type TransitionInstallFunc func(original, desired *Install) (bool, error)
type InstallReconciler interface {
Reconcile(namespace string, desiredResources InstallList, transition TransitionInstallFunc, opts clients.ListOpts) error
}
func installsToResources(list InstallList) resources.ResourceList {
var resourceList resources.ResourceList
for _, install := range list {
resourceList = append(resourceList, install)
}
return resourceList
}
func NewInstallReconciler(client InstallClient) InstallReconciler {
return &installReconciler{
base: reconcile.NewReconciler(client.BaseClient()),
}
}
type installReconciler struct {
base reconcile.Reconciler
}
func (r *installReconciler) Reconcile(namespace string, desiredResources InstallList, transition TransitionInstallFunc, opts clients.ListOpts) error {
opts = opts.WithDefaults()
opts.Ctx = contextutils.WithLogger(opts.Ctx, "install_reconciler")
var transitionResources reconcile.TransitionResourcesFunc
if transition != nil {
transitionResources = func(original, desired resources.Resource) (bool, error) {
return transition(original.(*Install), desired.(*Install))
}
}
return r.base.Reconcile(namespace, installsToResources(desiredResources), transitionResources, opts)
}