mirror of
https://github.com/helm/helm.git
synced 2026-04-22 14:47:41 -04:00
batch perform function by resource kind (Deployment, Pod, etc)
Signed-off-by: Charlie Getzen <charlie.getzen@procore.com>
This commit is contained in:
parent
f7a05ba018
commit
4c39d2b63f
1 changed files with 23 additions and 5 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue