mirror of
https://github.com/mudler/luet.git
synced 2025-07-01 09:41:50 +00:00
Implement ImageExists in the img backend
This commit is contained in:
parent
8b4b249211
commit
b9f0ef1c55
@ -18,6 +18,7 @@ package backend
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/mudler/luet/pkg/compiler"
|
"github.com/mudler/luet/pkg/compiler"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
@ -106,10 +107,16 @@ func (*SimpleImg) ImageAvailable(imagename string) bool {
|
|||||||
return imageAvailable(imagename)
|
return imageAvailable(imagename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageExists check if the given image is available locally
|
||||||
func (*SimpleImg) ImageExists(imagename string) bool {
|
func (*SimpleImg) ImageExists(imagename string) bool {
|
||||||
// NOOP: not implemented
|
cmd := exec.Command("img", "ls")
|
||||||
// TODO: Since img doesn't have an inspect command,
|
out, err := cmd.Output()
|
||||||
// we need to parse the ls output manually
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if strings.Contains(string(out), imagename) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user