Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 5766e6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/util/env.go
Expand Up @@ -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":
Expand Down
5 changes: 5 additions & 0 deletions pkg/util/linux_container.go
Expand Up @@ -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
Expand Down

0 comments on commit 5766e6a

Please sign in to comment.