mirror of
https://github.com/mudler/luet.git
synced 2025-09-15 23:00:04 +00:00
🔧 Extract common func into api function, also set sane defaults
This commit is contained in:
@@ -18,7 +18,6 @@ package backend
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
"github.com/google/go-containerregistry/pkg/crane"
|
||||
"github.com/mudler/luet/pkg/api/core/types"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -28,13 +27,6 @@ const (
|
||||
DockerBackend = "docker"
|
||||
)
|
||||
|
||||
func imageAvailable(image string) bool {
|
||||
// We use crane.insecure as we just check if the image is available
|
||||
// It's the daemon duty to use it or not based on the host settings
|
||||
_, err := crane.Digest(image, crane.Insecure)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
ImageName string
|
||||
SourcePath string
|
||||
|
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/google/go-containerregistry/pkg/v1/daemon"
|
||||
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||
bus "github.com/mudler/luet/pkg/api/core/bus"
|
||||
"github.com/mudler/luet/pkg/api/core/image"
|
||||
"github.com/mudler/luet/pkg/api/core/types"
|
||||
|
||||
v1 "github.com/google/go-containerregistry/pkg/v1"
|
||||
@@ -118,7 +119,7 @@ func (s *SimpleDocker) ImageExists(imagename string) bool {
|
||||
}
|
||||
|
||||
func (*SimpleDocker) ImageAvailable(imagename string) bool {
|
||||
return imageAvailable(imagename)
|
||||
return image.Available(imagename)
|
||||
}
|
||||
|
||||
func (s *SimpleDocker) RemoveImage(opts Options) error {
|
||||
|
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/google/go-containerregistry/pkg/crane"
|
||||
v1 "github.com/google/go-containerregistry/pkg/v1"
|
||||
bus "github.com/mudler/luet/pkg/api/core/bus"
|
||||
"github.com/mudler/luet/pkg/api/core/image"
|
||||
"github.com/mudler/luet/pkg/api/core/types"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -135,7 +136,7 @@ func (s *SimpleImg) CopyImage(src, dst string) error {
|
||||
}
|
||||
|
||||
func (s *SimpleImg) ImageAvailable(imagename string) bool {
|
||||
return imageAvailable(imagename)
|
||||
return image.Available(imagename)
|
||||
}
|
||||
|
||||
// ImageExists check if the given image is available locally
|
||||
|
Reference in New Issue
Block a user