Skip to content

Commit

Permalink
Merge pull request #45729 from thaJeztah/remove_rootlesskit_dep
Browse files Browse the repository at this point in the history
pkg/rootless: remove GetRootlessKitClient, and move to daemon
  • Loading branch information
thaJeztah committed Jun 12, 2023
2 parents ed798d6 + 59b5c60 commit 4bef3e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
14 changes: 13 additions & 1 deletion daemon/info_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package daemon // import "github.com/docker/docker/daemon"
import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand Down
18 changes: 1 addition & 17 deletions pkg/rootless/rootless.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package rootless // import "github.com/docker/docker/pkg/rootless"

import (
"os"
"path/filepath"

"github.com/pkg/errors"
"github.com/rootless-containers/rootlesskit/pkg/api/client"
)
import "os"

// RootlessKitDockerProxyBinary is the binary name of rootlesskit-docker-proxy
const RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy"
Expand All @@ -15,13 +9,3 @@ const RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy"
func RunningWithRootlessKit() bool {
return os.Getenv("ROOTLESSKIT_STATE_DIR") != ""
}

// GetRootlessKitClient returns RootlessKit client
func GetRootlessKitClient() (client.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 client.New(apiSock)
}

0 comments on commit 4bef3e9

Please sign in to comment.