@@ -34,6 +34,7 @@ import (
34
34
"k8s.io/cli-runtime/pkg/genericclioptions"
35
35
"k8s.io/client-go/kubernetes"
36
36
"k8s.io/klog/v2"
37
+ v1 "kmodules.xyz/objectstore-api/api/v1"
37
38
)
38
39
39
40
func NewCmdUnlockRepository (clientGetter genericclioptions.RESTClientGetter ) * cobra.Command {
@@ -119,7 +120,7 @@ func NewCmdUnlockRepository(clientGetter genericclioptions.RESTClientGetter) *co
119
120
}
120
121
121
122
// run unlock inside docker
122
- if err = runCmdViaDocker (* localDirs , "unlock" , extraAgrs ); err != nil {
123
+ if err = runCmdViaDocker (* localDirs , "unlock" , extraAgrs , setupOpt ); err != nil {
123
124
return err
124
125
}
125
126
klog .Infof ("Repository %s/%s has been unlocked successfully" , namespace , repositoryName )
@@ -130,7 +131,7 @@ func NewCmdUnlockRepository(clientGetter genericclioptions.RESTClientGetter) *co
130
131
return cmd
131
132
}
132
133
133
- func runCmdViaDocker (localDirs cliLocalDirectories , command string , extraArgs []string ) error {
134
+ func runCmdViaDocker (localDirs cliLocalDirectories , command string , extraArgs []string , setupOpt restic. SetupOptions ) error {
134
135
// get current user
135
136
currentUser , err := user .Current ()
136
137
if err != nil {
@@ -140,15 +141,19 @@ func runCmdViaDocker(localDirs cliLocalDirectories, command string, extraArgs []
140
141
"run" ,
141
142
"--rm" ,
142
143
"-u" , currentUser .Uid ,
143
- "-v" , ScratchDir + ":" + ScratchDir ,
144
144
"--env" , "HTTP_PROXY=" + os .Getenv ("HTTP_PROXY" ),
145
145
"--env" , "HTTPS_PROXY=" + os .Getenv ("HTTPS_PROXY" ),
146
146
"--env-file" , filepath .Join (localDirs .configDir , ResticEnvs ),
147
- imgRestic .ToContainerImage (),
148
- command ,
147
+ "-v" , ScratchDir + ":" + ScratchDir ,
149
148
}
150
149
150
+ if setupOpt .Provider == v1 .ProviderLocal {
151
+ args = append (args , "-v" , setupOpt .Bucket + ":" + setupOpt .Bucket )
152
+ }
153
+
154
+ args = append (args , imgRestic .ToContainerImage (), command )
151
155
args = append (args , extraArgs ... )
156
+
152
157
out , err := exec .Command ("docker" , args ... ).CombinedOutput ()
153
158
klog .Infoln ("Output:" , string (out ))
154
159
return err
0 commit comments