From 29866d0e75eb10c0cc3f118e19094ee30abd53cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Wed, 20 Apr 2022 14:06:16 +0200 Subject: [PATCH] Fix cases where /opt/techs doesn't exist --- containers/types.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/containers/types.go b/containers/types.go index 25fc484..3c0454f 100644 --- a/containers/types.go +++ b/containers/types.go @@ -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) } }