mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Check modification time before deploying manifests
This commit is contained in:
parent
553517e194
commit
fec2c271c2
@ -41,6 +41,7 @@ func WatchFiles(ctx context.Context, apply apply.Apply, addons v1.AddonControlle
|
||||
addons: addons,
|
||||
bases: bases,
|
||||
disables: disables,
|
||||
modTime: map[string]time.Time{},
|
||||
}
|
||||
|
||||
addons.Enqueue("", startKey)
|
||||
@ -60,6 +61,7 @@ type watcher struct {
|
||||
addons v1.AddonClient
|
||||
bases []string
|
||||
disables map[string]bool
|
||||
modTime map[string]time.Time
|
||||
}
|
||||
|
||||
func (w *watcher) start(ctx context.Context) {
|
||||
@ -84,7 +86,6 @@ func (w *watcher) listFiles(force bool) error {
|
||||
if err := w.listFilesIn(base, force); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
}
|
||||
return merr.NewErrors(errs...)
|
||||
}
|
||||
@ -124,8 +125,14 @@ func (w *watcher) listFilesIn(base string, force bool) error {
|
||||
if skipFile(files[path].Name(), skips) {
|
||||
continue
|
||||
}
|
||||
modTime := files[path].ModTime()
|
||||
if !force && modTime.Equal(w.modTime[path]) {
|
||||
continue
|
||||
}
|
||||
if err := w.deploy(path, !force); err != nil {
|
||||
errs = append(errs, errors2.Wrapf(err, "failed to process %s", path))
|
||||
} else {
|
||||
w.modTime[path] = modTime
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user