Skip to content

Commit 9b3e93d

Browse files
1gtmishtiaqhimel
andauthored
[cherry-pick] Update restic version (#2269) (#2276)
/cherry-pick Signed-off-by: Md. Ishtiaq Islam <ishtiaq@appscode.com> Co-authored-by: Md. Ishtiaq Islam <ishtiaq@appscode.com>
1 parent c8155ef commit 9b3e93d

File tree

7 files changed

+83
-6
lines changed

7 files changed

+83
-6
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ else
4242
endif
4343
endif
4444

45-
RESTIC_VER := 0.13.1
45+
RESTIC_VER := 0.17.3
4646

4747
###
4848
### These variables should not need tweaking.
@@ -281,7 +281,7 @@ lint: $(BUILD_DIRS)
281281
--env GO111MODULE=on \
282282
--env GOFLAGS="-mod=vendor" \
283283
$(BUILD_IMAGE) \
284-
golangci-lint run --enable $(ADDTL_LINTERS) --timeout=30m --skip-files="generated.*\.go$\" --skip-dirs-use-default --skip-dirs=client,vendor
284+
golangci-lint run --enable $(ADDTL_LINTERS) --timeout=30m --exclude-files="generated.*\.go$\" --exclude-dirs-use-default --exclude-dirs=client,vendor
285285

286286
$(BUILD_DIRS):
287287
@mkdir -p $@

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
kmodules.xyz/custom-resources v0.30.0
2222
kmodules.xyz/offshoot-api v0.30.1
2323
kubedb.dev/apimachinery v0.46.0
24-
stash.appscode.dev/apimachinery v0.38.0
24+
stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04
2525
)
2626

2727
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,5 +556,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+s
556556
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
557557
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
558558
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
559-
stash.appscode.dev/apimachinery v0.38.0 h1:tQ4dUdMxm0XZSs4Ieii/DupOjQ3dvpwYnzqC1M8TMCQ=
560-
stash.appscode.dev/apimachinery v0.38.0/go.mod h1:HoMcNxSg7TUHEhbHE+JvdhICrXoEKRvfLuFBKAM40ng=
559+
stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04 h1:NtQeear5dlS9PM6LoPVlfqRflavGvODoxa65RnI+w5Y=
560+
stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04/go.mod h1:HoMcNxSg7TUHEhbHE+JvdhICrXoEKRvfLuFBKAM40ng=

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
824824
## explicit; go 1.12
825825
sigs.k8s.io/yaml
826826
sigs.k8s.io/yaml/goyaml.v2
827-
# stash.appscode.dev/apimachinery v0.38.0
827+
# stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04
828828
## explicit; go 1.22.0
829829
stash.appscode.dev/apimachinery/apis
830830
stash.appscode.dev/apimachinery/apis/repositories

vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,49 @@ func (w *ResticWrapper) unlock() ([]byte, error) {
379379
return w.run(Command{Name: ResticCMD, Args: args})
380380
}
381381

382+
func (w *ResticWrapper) migrateToV2() ([]byte, error) {
383+
klog.Infoln("Migrating repository to v2")
384+
args := w.appendCacheDirFlag([]interface{}{"migrate", "upgrade_repo_v2"})
385+
args = w.appendMaxConnectionsFlag(args)
386+
args = w.appendCaCertFlag(args)
387+
args = w.appendInsecureTLSFlag(args)
388+
389+
return w.run(Command{Name: ResticCMD, Args: args})
390+
}
391+
392+
func (w *ResticWrapper) prune(pruneOpts PruneOptions) ([]byte, error) {
393+
klog.Infoln("Pruning repository")
394+
395+
args := []interface{}{"prune"}
396+
if pruneOpts.DryRun {
397+
args = append(args, "--dry-run")
398+
}
399+
if pruneOpts.RepackCacheableOnly {
400+
args = append(args, "--repack-cacheable-only")
401+
}
402+
if pruneOpts.RepackSmall {
403+
args = append(args, "--repack-small")
404+
}
405+
if pruneOpts.RepackUncompressed {
406+
args = append(args, "--repack-uncompressed")
407+
}
408+
if pruneOpts.MaxUnusedLimit != "" {
409+
args = append(args,
410+
fmt.Sprintf("--max-unused=%s", pruneOpts.MaxUnusedLimit))
411+
}
412+
if pruneOpts.MaxRepackSize != "" {
413+
args = append(args,
414+
fmt.Sprintf("--max-repack-size=%s", pruneOpts.MaxRepackSize))
415+
}
416+
417+
args = w.appendCacheDirFlag(args)
418+
args = w.appendMaxConnectionsFlag(args)
419+
args = w.appendCaCertFlag(args)
420+
args = w.appendInsecureTLSFlag(args)
421+
422+
return w.run(Command{Name: ResticCMD, Args: args})
423+
}
424+
382425
func (w *ResticWrapper) appendCacheDirFlag(args []interface{}) []interface{} {
383426
if w.config.EnableCache {
384427
cacheDir := filepath.Join(w.config.ScratchDir, resticCacheDir)

vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ type DumpOptions struct {
7878
StdoutPipeCommands []Command
7979
}
8080

81+
type PruneOptions struct {
82+
MaxUnusedLimit string
83+
MaxRepackSize string
84+
DryRun bool
85+
RepackUncompressed bool
86+
RepackSmall bool
87+
RepackCacheableOnly bool
88+
}
89+
8190
type SetupOptions struct {
8291
Provider string
8392
Bucket string
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package restic
18+
19+
func (w *ResticWrapper) Prune(pruneOpts PruneOptions) ([]byte, error) {
20+
return w.prune(pruneOpts)
21+
}
22+
23+
func (w *ResticWrapper) MigrateRepoToV2() ([]byte, error) {
24+
return w.migrateToV2()
25+
}

0 commit comments

Comments
 (0)