From 350fadbdd4acaa40e5c0f92189db42b430dd755d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 25 Apr 2022 13:53:32 +0200 Subject: [PATCH] rootless: remove redundant sync.Once This was added in ec87479b7e2bf6f1b5bcc657a377c6e6a847574f, 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 --- rootless/rootless.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/rootless/rootless.go b/rootless/rootless.go index b7b0ff544f..4cda7cf6fd 100644 --- a/rootless/rootless.go +++ b/rootless/rootless.go @@ -3,29 +3,17 @@ package rootless // import "github.com/docker/docker/rootless" import ( "os" "path/filepath" - "sync" "github.com/pkg/errors" "github.com/rootless-containers/rootlesskit/pkg/api/client" ) -const ( - // RootlessKitDockerProxyBinary is the binary name of rootlesskit-docker-proxy - RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy" -) - -var ( - runningWithRootlessKit bool - runningWithRootlessKitOnce sync.Once -) +// RootlessKitDockerProxyBinary is the binary name of rootlesskit-docker-proxy +const RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy" // RunningWithRootlessKit returns true if running under RootlessKit namespaces. func RunningWithRootlessKit() bool { - runningWithRootlessKitOnce.Do(func() { - u := os.Getenv("ROOTLESSKIT_STATE_DIR") - runningWithRootlessKit = u != "" - }) - return runningWithRootlessKit + return os.Getenv("ROOTLESSKIT_STATE_DIR") != "" } // GetRootlessKitClient returns RootlessKit client