Skip to content

Commit ee66407

Browse files
authored
Fix unlock command for local repository (#177)
Signed-off-by: hmsayem <hmsayem@appscode.com>
1 parent ba3e3b0 commit ee66407

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/unlock.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"k8s.io/cli-runtime/pkg/genericclioptions"
3535
"k8s.io/client-go/kubernetes"
3636
"k8s.io/klog/v2"
37+
v1 "kmodules.xyz/objectstore-api/api/v1"
3738
)
3839

3940
func NewCmdUnlockRepository(clientGetter genericclioptions.RESTClientGetter) *cobra.Command {
@@ -119,7 +120,7 @@ func NewCmdUnlockRepository(clientGetter genericclioptions.RESTClientGetter) *co
119120
}
120121

121122
// run unlock inside docker
122-
if err = runCmdViaDocker(*localDirs, "unlock", extraAgrs); err != nil {
123+
if err = runCmdViaDocker(*localDirs, "unlock", extraAgrs, setupOpt); err != nil {
123124
return err
124125
}
125126
klog.Infof("Repository %s/%s has been unlocked successfully", namespace, repositoryName)
@@ -130,7 +131,7 @@ func NewCmdUnlockRepository(clientGetter genericclioptions.RESTClientGetter) *co
130131
return cmd
131132
}
132133

133-
func runCmdViaDocker(localDirs cliLocalDirectories, command string, extraArgs []string) error {
134+
func runCmdViaDocker(localDirs cliLocalDirectories, command string, extraArgs []string, setupOpt restic.SetupOptions) error {
134135
// get current user
135136
currentUser, err := user.Current()
136137
if err != nil {
@@ -140,15 +141,19 @@ func runCmdViaDocker(localDirs cliLocalDirectories, command string, extraArgs []
140141
"run",
141142
"--rm",
142143
"-u", currentUser.Uid,
143-
"-v", ScratchDir + ":" + ScratchDir,
144144
"--env", "HTTP_PROXY=" + os.Getenv("HTTP_PROXY"),
145145
"--env", "HTTPS_PROXY=" + os.Getenv("HTTPS_PROXY"),
146146
"--env-file", filepath.Join(localDirs.configDir, ResticEnvs),
147-
imgRestic.ToContainerImage(),
148-
command,
147+
"-v", ScratchDir + ":" + ScratchDir,
149148
}
150149

150+
if setupOpt.Provider == v1.ProviderLocal {
151+
args = append(args, "-v", setupOpt.Bucket+":"+setupOpt.Bucket)
152+
}
153+
154+
args = append(args, imgRestic.ToContainerImage(), command)
151155
args = append(args, extraArgs...)
156+
152157
out, err := exec.Command("docker", args...).CombinedOutput()
153158
klog.Infoln("Output:", string(out))
154159
return err

0 commit comments

Comments
 (0)