Fix cases where /opt/techs doesn't exist
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Adam Štrauch 2022-04-20 14:06:16 +02:00
parent fea1a46a11
commit 29866d0e75
Signed by: cx
GPG Key ID: 018304FFA8988F8D

View File

@ -2,6 +2,7 @@ package containers
import (
"errors"
"fmt"
"log"
"path"
"strings"
@ -340,7 +341,18 @@ func (c *Container) GetTechs() (apps.AppTechs, error) {
driver := c.getDriver()
stdouterr, err := driver.Exec(c.App.Name, []string{"ls", "/opt/techs"}, "", []string{}, true)
stdouterr, err := driver.Exec(c.App.Name, []string{"ls", "/opt"}, "", []string{}, true)
if err != nil {
// in case there is an error just return empty response
return techs, nil
}
// Check if /opt/techs exists
if !strings.Contains(string(*stdouterr), "techs") {
return techs, nil
}
stdouterr, err = driver.Exec(c.App.Name, []string{"ls", "/opt/techs"}, "", []string{}, true)
if err != nil {
// in case there is an error just return empty response
return techs, nil
@ -360,7 +372,7 @@ func (c *Container) GetTechs() (apps.AppTechs, error) {
Version: techParts[1],
})
} else {
return techs, errors.New("one of the tech has wrong number of parts")
return techs, fmt.Errorf("one of the tech has wrong number of parts (%s)", techRaw)
}
}