Skip to content

Commit

Permalink
libct/userns: change RunningInUserNS to a wrapper instead of an alias
Browse files Browse the repository at this point in the history
This was a poor decision on my side; ab29593
moved this utility to a separate package, and split the exported function
from the implementation (and stubs). Out of convenience, I used an alias
for the latter part, but there's two downsides to that;

- `RunningInUserNS` being an exported var means that (technically) it can
  be replaced by other code; perhaps that's a "feature", but not one we
  intended it to be used for.
- `RunningInUserNS` being implemented through a var / alias means it's
  also documented as such on [pkg.go.dev], which is confusing.

This patch changes it to a regular function, acting as a wrapper for
the underlying implementations. While at it, also slightly touching
up the GoDoc to describe its functionality / behavior.

[pkg.go.dev]: https://pkg.go.dev/github.com/opencontainers/[email protected]/libcontainer/userns#RunningInUserNS

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Jul 24, 2024
1 parent bb72464 commit 333fe31
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions user/userns/userns.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package userns

// RunningInUserNS detects whether we are currently running in a user namespace.
var RunningInUserNS = runningInUserNS
// RunningInUserNS detects whether we are currently running in a Linux
// user namespace and memoizes the result. It returns false on non-Linux
// platforms.
func RunningInUserNS() bool {
return runningInUserNS()
}

0 comments on commit 333fe31

Please sign in to comment.