|
|
|
@ -274,11 +274,7 @@ func perform(infos ResourceList, fn func(*resource.Info) error) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
errs := make(chan error)
|
|
|
|
|
for _, info := range infos {
|
|
|
|
|
go func(i *resource.Info) {
|
|
|
|
|
errs <- fn(i)
|
|
|
|
|
}(info)
|
|
|
|
|
}
|
|
|
|
|
go batchPerform(infos, fn, errs)
|
|
|
|
|
|
|
|
|
|
for range infos {
|
|
|
|
|
err := <-errs
|
|
|
|
@ -289,6 +285,28 @@ func perform(infos ResourceList, fn func(*resource.Info) error) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func batchPerform(infos Result, fn ResourceActorFunc, errs chan<- error) {
|
|
|
|
|
finished := make(chan bool, 10000)
|
|
|
|
|
kind := infos[0].Object.GetObjectKind().GroupVersionKind().Kind
|
|
|
|
|
counter := 0
|
|
|
|
|
for _, info := range infos {
|
|
|
|
|
currentKind := info.Object.GetObjectKind().GroupVersionKind().Kind
|
|
|
|
|
if kind != currentKind {
|
|
|
|
|
// Wait until the previous kind has finished
|
|
|
|
|
for i := 0; i < counter; i++ {
|
|
|
|
|
<-finished
|
|
|
|
|
}
|
|
|
|
|
counter = 0
|
|
|
|
|
kind = currentKind
|
|
|
|
|
}
|
|
|
|
|
counter = counter + 1
|
|
|
|
|
go func(i *resource.Info) {
|
|
|
|
|
errs <- fn(i)
|
|
|
|
|
finished <- true
|
|
|
|
|
}(info)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func createResource(info *resource.Info) error {
|
|
|
|
|
obj, err := resource.NewHelper(info.Client, info.Mapping).Create(info.Namespace, true, info.Object, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|