From 6f7d7f0d87cd3285a811c2d36c3d1b63defa2cba Mon Sep 17 00:00:00 2001 From: zzzzzzzzzy9 Date: Sat, 11 Oct 2025 11:09:10 +0800 Subject: [PATCH] add storage-isolate path support Signed-off-by: zzzzzzzzzy9 --- .../image-check/daemon/app/main.go | 4 ++++ .../image-check/daemon/commands/commands.go | 2 +- .../image-check/daemon/config/config.go | 24 ++++++++++++------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/image_recover_tool/image-check/daemon/app/main.go b/image_recover_tool/image-check/daemon/app/main.go index 1fb8ba6..f5b0fc1 100644 --- a/image_recover_tool/image-check/daemon/app/main.go +++ b/image_recover_tool/image-check/daemon/app/main.go @@ -58,6 +58,10 @@ docker image check tool Name: "root", Usage: "root directory for docker", }, + cli.StringFlag{ + Name: "storage-isolate", + Usage: "docker storage-isolate path", + }, } app.Commands = append([]cli.Command{ images.Command, diff --git a/image_recover_tool/image-check/daemon/commands/commands.go b/image_recover_tool/image-check/daemon/commands/commands.go index 963ba5b..937989a 100644 --- a/image_recover_tool/image-check/daemon/commands/commands.go +++ b/image_recover_tool/image-check/daemon/commands/commands.go @@ -23,7 +23,7 @@ func NewDaemon(context *cli.Context) (*Daemon, error) { var err error logrus.Info("Start check tool") - d.daemonConfigFile, err = config.GetDockerRoot(context.GlobalString("config"), context.GlobalString("root"), context.GlobalString("driver")) + d.daemonConfigFile, err = config.GetDockerRoot(context.GlobalString("config"), context.GlobalString("root"), context.GlobalString("driver"),context.GlobalString("storage-isolate")) if err != nil { logrus.Errorf("Failed to get the dockerd configuration file: %v", err) return nil, err diff --git a/image_recover_tool/image-check/daemon/config/config.go b/image_recover_tool/image-check/daemon/config/config.go index e1ab009..6e18fa8 100644 --- a/image_recover_tool/image-check/daemon/config/config.go +++ b/image_recover_tool/image-check/daemon/config/config.go @@ -19,12 +19,12 @@ const ( ) type DaemonConfig struct { - Root string `json:"graph,omitempty"` - GraphDriver string `json:"storage-driver,omitempty"` + Root string `json:"graph,omitempty"` + GraphDriver string `json:"storage-driver,omitempty"` StorageIsolate string `json:"storage-isolate,omitempty"` } -func GetDockerRoot(dockerdConfigPath, root, driver string) (*DaemonConfig, error) { +func GetDockerRoot(dockerdConfigPath, root, driver string, storageIsolate string) (*DaemonConfig, error) { dc := &DaemonConfig{} exist, err := dc.checkConfigurationIsExist(dockerdConfigPath) @@ -39,17 +39,13 @@ func GetDockerRoot(dockerdConfigPath, root, driver string) (*DaemonConfig, error } if fileConfig.Root != "" { dc.Root = fileConfig.Root - dc.StorageIsolate = fileConfig.Root - }else { - dc.StorageIsolate = DefaultPath } if fileConfig.GraphDriver != "" { dc.GraphDriver = fileConfig.GraphDriver } - if fileConfig.StorageIsolate != ""{ + if fileConfig.StorageIsolate != "" { dc.StorageIsolate = fileConfig.StorageIsolate } - } else { logrus.Warnf("The docker configuration file not found: %s", dockerdConfigPath) } @@ -60,7 +56,17 @@ func GetDockerRoot(dockerdConfigPath, root, driver string) (*DaemonConfig, error if driver != "" { dc.GraphDriver = driver } - + if storageIsolate != "" { + dc.StorageIsolate = storageIsolate + }else { + if dc.StorageIsolate == ""{ + if dc.Root !=""{ + dc.StorageIsolate = dc.Root + }else { + dc.StorageIsolate = DefaultPath + } + } + } if dc.Root == "" { dc.Root = DefaultPath } -- Gitee