|
|
@ -23,6 +23,7 @@ import (
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
jsonpatch "github.com/evanphx/json-patch"
|
|
|
|
jsonpatch "github.com/evanphx/json-patch"
|
|
|
@ -273,14 +274,35 @@ func perform(infos ResourceList, fn func(*resource.Info) error) error {
|
|
|
|
return ErrNoObjectsVisited
|
|
|
|
return ErrNoObjectsVisited
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, info := range infos {
|
|
|
|
errs := make(chan error)
|
|
|
|
if err := fn(info); err != nil {
|
|
|
|
go batchPerform(infos, fn, errs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for range infos {
|
|
|
|
|
|
|
|
err := <-errs
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func batchPerform(infos ResourceList, fn func(*resource.Info) error, errs chan<- error) {
|
|
|
|
|
|
|
|
var kind string
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
|
|
|
for _, info := range infos {
|
|
|
|
|
|
|
|
currentKind := info.Object.GetObjectKind().GroupVersionKind().Kind
|
|
|
|
|
|
|
|
if kind != currentKind {
|
|
|
|
|
|
|
|
wg.Wait()
|
|
|
|
|
|
|
|
kind = currentKind
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
|
|
|
|
go func(i *resource.Info) {
|
|
|
|
|
|
|
|
errs <- fn(i)
|
|
|
|
|
|
|
|
wg.Done()
|
|
|
|
|
|
|
|
}(info)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func createResource(info *resource.Info) error {
|
|
|
|
func createResource(info *resource.Info) error {
|
|
|
|
obj, err := resource.NewHelper(info.Client, info.Mapping).Create(info.Namespace, true, info.Object, nil)
|
|
|
|
obj, err := resource.NewHelper(info.Client, info.Mapping).Create(info.Namespace, true, info.Object, nil)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|