bib/internal/setup: validate container tags early

Check that the container has the expected bootc tags early and fail if
they are missing.
This commit is contained in:
bstrausser 2024-06-13 19:27:45 -04:00 committed by Simon de Vlieger
parent 4fa4ad34a0
commit 2a89cb6739
2 changed files with 25 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strings"
"golang.org/x/sys/unix"
@ -148,3 +149,17 @@ func validateCanRunTargetArch(targetArch string) error {
return nil
}
func ValidateHasContainerTags(imgref string) error {
output, err := exec.Command("podman", "image", "inspect", imgref, "--format", "{{.Labels}}").Output()
if err != nil {
return fmt.Errorf("failed inspect image: %w", util.OutputErr(err))
}
tags := string(output)
if !strings.Contains(tags, "containers.bootc:1") {
return fmt.Errorf("image %s is not a bootc image", imgref)
}
return nil
}