fix: handle case where deploying app image does not exist

This happens if ps:scale is called before a deploy.

Also refactor GetDeployingAppImageName() to return an error as the second return parameter.
This commit is contained in:
Jose Diaz-Gonzalez
2020-11-23 00:11:00 -05:00
parent fceb412fb1
commit 97513dee91
5 changed files with 27 additions and 11 deletions

View File

@@ -145,7 +145,11 @@ func CommandScale(appName string, skipDeploy bool, processTuples []string) error
procfilePath := getProcfilePath(appName)
if !common.FileExists(procfilePath) {
extract := func() error {
image := common.GetDeployingAppImageName(appName, "", "")
image, err := common.GetDeployingAppImageName(appName, "", "")
if err != nil {
return nil
}
return extractProcfile(appName, image)
}

View File

@@ -144,7 +144,11 @@ func TriggerPostStop(appName string) error {
// TriggerPreDeploy ensures an app has an up to date scale file
func TriggerPreDeploy(appName string, imageTag string) error {
image := common.GetDeployingAppImageName(appName, imageTag, "")
image, err := common.GetDeployingAppImageName(appName, imageTag, "")
if err != nil {
return err
}
if err := removeProcfile(appName); err != nil {
return err
}
@@ -183,7 +187,11 @@ func TriggerProcfileGetCommand(appName string, processType string, port int) err
procfilePath := getProcfilePath(appName)
if !common.FileExists(procfilePath) {
extract := func() error {
image := common.GetDeployingAppImageName(appName, "", "")
image, err := common.GetDeployingAppImageName(appName, "", "")
if err != nil {
return err
}
return extractProcfile(appName, image)
}