forked from fluxcd/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.go
30 lines (26 loc) · 760 Bytes
/
sync.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
package sync
import (
"github.com/fluxcd/flux/cluster"
"github.com/fluxcd/flux/resource"
)
// Syncer has the methods we need to be able to compile and run a sync
type Syncer interface {
Sync(cluster.SyncSet) error
}
// Sync synchronises the cluster to the files under a directory.
func Sync(setName string, repoResources map[string]resource.Resource, clus Syncer) error {
set := makeSet(setName, repoResources)
if err := clus.Sync(set); err != nil {
return err
}
return nil
}
func makeSet(name string, repoResources map[string]resource.Resource) cluster.SyncSet {
s := cluster.SyncSet{Name: name}
var resources []resource.Resource
for _, res := range repoResources {
resources = append(resources, res)
}
s.Resources = resources
return s
}