mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
pkg/rootless: remove GetRootlessKitClient, and move to daemon
This utility was only used in a single location (as part of `docker info`), but the `pkg/rootless` package is imported in various locations, causing rootlesskit to be a dependency for consumers of that package. Move GetRootlessKitClient to the daemon code, which is the only location it was used. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -5,6 +5,7 @@ package daemon // import "github.com/docker/docker/daemon"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
"github.com/docker/docker/pkg/rootless"
|
||||
"github.com/docker/docker/pkg/sysinfo"
|
||||
"github.com/pkg/errors"
|
||||
rkclient "github.com/rootless-containers/rootlesskit/pkg/api/client"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -218,7 +220,7 @@ func (daemon *Daemon) fillRootlessVersion(v *types.Version) {
|
||||
if !rootless.RunningWithRootlessKit() {
|
||||
return
|
||||
}
|
||||
rlc, err := rootless.GetRootlessKitClient()
|
||||
rlc, err := getRootlessKitClient()
|
||||
if err != nil {
|
||||
logrus.Warnf("failed to create RootlessKit client: %v", err)
|
||||
return
|
||||
@@ -268,6 +270,16 @@ func (daemon *Daemon) fillRootlessVersion(v *types.Version) {
|
||||
}
|
||||
}
|
||||
|
||||
// getRootlessKitClient returns RootlessKit client
|
||||
func getRootlessKitClient() (rkclient.Client, error) {
|
||||
stateDir := os.Getenv("ROOTLESSKIT_STATE_DIR")
|
||||
if stateDir == "" {
|
||||
return nil, errors.New("environment variable `ROOTLESSKIT_STATE_DIR` is not set")
|
||||
}
|
||||
apiSock := filepath.Join(stateDir, "api.sock")
|
||||
return rkclient.New(apiSock)
|
||||
}
|
||||
|
||||
func fillDriverWarnings(v *types.Info) {
|
||||
for _, pair := range v.DriverStatus {
|
||||
if pair[0] == "Extended file attributes" && pair[1] == "best-effort" {
|
||||
|
||||
Reference in New Issue
Block a user