forked from joeholley/supergloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmesh_reconciler.sk.go
47 lines (39 loc) · 1.54 KB
/
mesh_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 TransitionMeshFunc func(original, desired *Mesh) (bool, error)
type MeshReconciler interface {
Reconcile(namespace string, desiredResources MeshList, transition TransitionMeshFunc, opts clients.ListOpts) error
}
func meshsToResources(list MeshList) resources.ResourceList {
var resourceList resources.ResourceList
for _, mesh := range list {
resourceList = append(resourceList, mesh)
}
return resourceList
}
func NewMeshReconciler(client MeshClient) MeshReconciler {
return &meshReconciler{
base: reconcile.NewReconciler(client.BaseClient()),
}
}
type meshReconciler struct {
base reconcile.Reconciler
}
func (r *meshReconciler) Reconcile(namespace string, desiredResources MeshList, transition TransitionMeshFunc, opts clients.ListOpts) error {
opts = opts.WithDefaults()
opts.Ctx = contextutils.WithLogger(opts.Ctx, "mesh_reconciler")
var transitionResources reconcile.TransitionResourcesFunc
if transition != nil {
transitionResources = func(original, desired resources.Resource) (bool, error) {
return transition(original.(*Mesh), desired.(*Mesh))
}
}
return r.base.Reconcile(namespace, meshsToResources(desiredResources), transitionResources, opts)
}