Skip to content
Permalink
Browse files
feat(buildah): $WERF_CONTAINERIZED will override in container detection
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Jun 17, 2022
1 parent 9a0dbe9 commit 5766e6a0fa6bc5400190805e6708d70ae3b3f10a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
@@ -8,6 +8,19 @@ import (
"strings"
)

func GetBoolEnvironment(environmentName string) *bool {
switch os.Getenv(environmentName) {
case "1", "true", "yes":
t := true
return &t
case "0", "false", "no":
f := false
return &f
}

return nil
}

func GetBoolEnvironmentDefaultFalse(environmentName string) bool {
switch os.Getenv(environmentName) {
case "1", "true", "yes":
@@ -38,6 +38,11 @@ func ToLinuxContainerPath(path string) string {
}

func IsInContainer() bool {
werfContainerized := GetBoolEnvironment("WERF_CONTAINERIZED")
if werfContainerized != nil {
return *werfContainerized
}

// Docker-daemon
if isInContainer, err := RegularFileExists("/.dockerenv"); err == nil && isInContainer {
return true

0 comments on commit 5766e6a

Please sign in to comment.