Skip to content

Commit d381b46

Browse files
committed
bib: drop inContainerOrUnknown() and use setup.IsContainer()
We have a shared helper now in ibcli, lets drop duplicated code. Thanks to Ondrej for writing the new (and better) helper.
1 parent 52032f2 commit d381b46

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

bib/cmd/bootc-image-builder/main.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"io/fs"
99
"log"
1010
"os"
11-
"os/exec"
1211
"path/filepath"
1312
"runtime/debug"
1413
"strconv"
@@ -47,16 +46,6 @@ var (
4746
osStderr = os.Stderr
4847
)
4948

50-
func inContainerOrUnknown() bool {
51-
// no systemd-detect-virt, err on the side of container
52-
if _, err := exec.LookPath("systemd-detect-virt"); err != nil {
53-
return true
54-
}
55-
// exit code "0" means the container is detected
56-
err := exec.Command("systemd-detect-virt", "-c", "-q").Run()
57-
return err == nil
58-
}
59-
6049
func saveManifest(ms manifest.OSBuildManifest, fpath string) (err error) {
6150
b, err := json.MarshalIndent(ms, "", " ")
6251
if err != nil {
@@ -278,7 +267,7 @@ func cmdBuild(cmd *cobra.Command, args []string) error {
278267
return fmt.Errorf("cannot validate the setup: %w", err)
279268
}
280269
logrus.Debug("Ensuring environment setup")
281-
switch inContainerOrUnknown() {
270+
switch setup.IsContainer() {
282271
case false:
283272
fmt.Fprintf(os.Stderr, "WARNING: running outside a container, this is an unsupported configuration\n")
284273
case true:

0 commit comments

Comments
 (0)