feat: use error group to fetch the deploying app image
This is a fairly slow operation currently done serially, making ps:scale output brutally slow. Using an error group to parallelize the output is also pleasing to the eyes :)
This commit is contained in:
@@ -112,23 +112,38 @@ func GetGlobalScheduler() string {
|
|||||||
|
|
||||||
// GetDeployingAppImageName returns deploying image identifier for a given app, tag tuple. validate if tag is presented
|
// GetDeployingAppImageName returns deploying image identifier for a given app, tag tuple. validate if tag is presented
|
||||||
func GetDeployingAppImageName(appName, imageTag, imageRepo string) (string, error) {
|
func GetDeployingAppImageName(appName, imageTag, imageRepo string) (string, error) {
|
||||||
b, err := PlugnTriggerOutput("deployed-app-repository", []string{appName}...)
|
imageRemoteRepository := ""
|
||||||
if err != nil {
|
newImageTag := ""
|
||||||
return "", err
|
newImageRepo := ""
|
||||||
}
|
|
||||||
imageRemoteRepository := strings.TrimSpace(string(b[:]))
|
|
||||||
|
|
||||||
b, err = PlugnTriggerOutput("deployed-app-image-tag", []string{appName}...)
|
ctx := context.Background()
|
||||||
if err != nil {
|
errs, ctx := errgroup.WithContext(ctx)
|
||||||
return "", err
|
errs.Go(func() error {
|
||||||
}
|
b, err := PlugnTriggerOutput("deployed-app-repository", []string{appName}...)
|
||||||
newImageTag := strings.TrimSpace(string(b[:]))
|
if err == nil {
|
||||||
|
imageRemoteRepository = strings.TrimSpace(string(b[:]))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
errs.Go(func() error {
|
||||||
|
b, err := PlugnTriggerOutput("deployed-app-image-tag", []string{appName}...)
|
||||||
|
if err == nil {
|
||||||
|
newImageTag = strings.TrimSpace(string(b[:]))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
|
||||||
b, err = PlugnTriggerOutput("deployed-app-image-repo", []string{appName}...)
|
errs.Go(func() error {
|
||||||
if err != nil {
|
b, err := PlugnTriggerOutput("deployed-app-image-repo", []string{appName}...)
|
||||||
|
if err == nil {
|
||||||
|
newImageTag = strings.TrimSpace(string(b[:]))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := errs.Wait(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
newImageRepo := strings.TrimSpace(string(b[:]))
|
|
||||||
|
|
||||||
if newImageRepo != "" {
|
if newImageRepo != "" {
|
||||||
imageRepo = newImageRepo
|
imageRepo = newImageRepo
|
||||||
|
|||||||
Reference in New Issue
Block a user