rootless: remove redundant sync.Once
This was added in ec87479b7e
, but it's unclear
why a sync.Once was used just for reading an environment-variable. The
related PR had a lot of review comments, so perhaps an earlier implementation
used something more heavy-weight, or it was just overlooked.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e78f6f9c68
commit
350fadbdd4
|
@ -3,29 +3,17 @@ package rootless // import "github.com/docker/docker/rootless"
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rootless-containers/rootlesskit/pkg/api/client"
|
"github.com/rootless-containers/rootlesskit/pkg/api/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
// RootlessKitDockerProxyBinary is the binary name of rootlesskit-docker-proxy
|
||||||
// RootlessKitDockerProxyBinary is the binary name of rootlesskit-docker-proxy
|
const RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy"
|
||||||
RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
runningWithRootlessKit bool
|
|
||||||
runningWithRootlessKitOnce sync.Once
|
|
||||||
)
|
|
||||||
|
|
||||||
// RunningWithRootlessKit returns true if running under RootlessKit namespaces.
|
// RunningWithRootlessKit returns true if running under RootlessKit namespaces.
|
||||||
func RunningWithRootlessKit() bool {
|
func RunningWithRootlessKit() bool {
|
||||||
runningWithRootlessKitOnce.Do(func() {
|
return os.Getenv("ROOTLESSKIT_STATE_DIR") != ""
|
||||||
u := os.Getenv("ROOTLESSKIT_STATE_DIR")
|
|
||||||
runningWithRootlessKit = u != ""
|
|
||||||
})
|
|
||||||
return runningWithRootlessKit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRootlessKitClient returns RootlessKit client
|
// GetRootlessKitClient returns RootlessKit client
|
||||||
|
|
Loading…
Reference in New Issue