import: move bib files to correct path
Moves the files imported from `bootc-image-builder` to the appropriate path under `pkg/` so they can be imported reverse. Also fix up the import paths that are in these files to refer to their new locations. Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
parent
441d408aee
commit
6d0927c2f9
6 changed files with 4 additions and 4 deletions
38
pkg/podmanutil/podmanutils.go
Normal file
38
pkg/podmanutil/podmanutils.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package podmanutil
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
)
|
||||
|
||||
// envPath is written by podman
|
||||
const envPath = "/run/.containerenv"
|
||||
|
||||
// rootlessKey is set when we are rootless
|
||||
const rootlessKey = "rootless=1"
|
||||
|
||||
// IsRootless detects if we are running rootless in podman;
|
||||
// other situations (e.g. docker) will successfuly return false.
|
||||
func IsRootless() (bool, error) {
|
||||
buf, err := os.ReadFile(envPath)
|
||||
if err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
scanner := bufio.NewScanner(bytes.NewReader(buf))
|
||||
for scanner.Scan() {
|
||||
if scanner.Text() == rootlessKey {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return false, fmt.Errorf("parsing %s: %w", envPath, err)
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue