From a0af98c25a1aa91a6bb6b31537cc85cb837c4ad5 Mon Sep 17 00:00:00 2001 From: "Md. Ishtiaq Islam" Date: Tue, 4 Feb 2025 17:24:43 +0600 Subject: [PATCH] Update restic version (#2269) /cherry-pick Signed-off-by: Md. Ishtiaq Islam --- Makefile | 4 +- go.mod | 2 +- go.sum | 4 +- vendor/modules.txt | 2 +- .../apimachinery/pkg/restic/commands.go | 43 +++++++++++++++++++ .../apimachinery/pkg/restic/config.go | 9 ++++ .../apimachinery/pkg/restic/migrate.go | 25 +++++++++++ 7 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 vendor/stash.appscode.dev/apimachinery/pkg/restic/migrate.go diff --git a/Makefile b/Makefile index b9d4bf885..46af063f8 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ else endif endif -RESTIC_VER := 0.13.1 +RESTIC_VER := 0.17.3 ### ### These variables should not need tweaking. @@ -281,7 +281,7 @@ lint: $(BUILD_DIRS) --env GO111MODULE=on \ --env GOFLAGS="-mod=vendor" \ $(BUILD_IMAGE) \ - golangci-lint run --enable $(ADDTL_LINTERS) --timeout=30m --skip-files="generated.*\.go$\" --skip-dirs-use-default --skip-dirs=client,vendor + golangci-lint run --enable $(ADDTL_LINTERS) --timeout=30m --exclude-files="generated.*\.go$\" --exclude-dirs-use-default --exclude-dirs=client,vendor $(BUILD_DIRS): @mkdir -p $@ diff --git a/go.mod b/go.mod index 37dbc8313..21f5e7123 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( kmodules.xyz/custom-resources v0.30.0 kmodules.xyz/offshoot-api v0.30.1 kubedb.dev/apimachinery v0.46.0 - stash.appscode.dev/apimachinery v0.38.0 + stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04 ) require ( diff --git a/go.sum b/go.sum index 15c30f074..b51fcbf9b 100644 --- a/go.sum +++ b/go.sum @@ -556,5 +556,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+s sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= -stash.appscode.dev/apimachinery v0.38.0 h1:tQ4dUdMxm0XZSs4Ieii/DupOjQ3dvpwYnzqC1M8TMCQ= -stash.appscode.dev/apimachinery v0.38.0/go.mod h1:HoMcNxSg7TUHEhbHE+JvdhICrXoEKRvfLuFBKAM40ng= +stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04 h1:NtQeear5dlS9PM6LoPVlfqRflavGvODoxa65RnI+w5Y= +stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04/go.mod h1:HoMcNxSg7TUHEhbHE+JvdhICrXoEKRvfLuFBKAM40ng= diff --git a/vendor/modules.txt b/vendor/modules.txt index 1ed82dc17..bed5c5711 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -824,7 +824,7 @@ sigs.k8s.io/structured-merge-diff/v4/value ## explicit; go 1.12 sigs.k8s.io/yaml sigs.k8s.io/yaml/goyaml.v2 -# stash.appscode.dev/apimachinery v0.38.0 +# stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04 ## explicit; go 1.22.0 stash.appscode.dev/apimachinery/apis stash.appscode.dev/apimachinery/apis/repositories diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go index 7f39f8f73..f36100ded 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go @@ -379,6 +379,49 @@ func (w *ResticWrapper) unlock() ([]byte, error) { return w.run(Command{Name: ResticCMD, Args: args}) } +func (w *ResticWrapper) migrateToV2() ([]byte, error) { + klog.Infoln("Migrating repository to v2") + args := w.appendCacheDirFlag([]interface{}{"migrate", "upgrade_repo_v2"}) + args = w.appendMaxConnectionsFlag(args) + args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) + + return w.run(Command{Name: ResticCMD, Args: args}) +} + +func (w *ResticWrapper) prune(pruneOpts PruneOptions) ([]byte, error) { + klog.Infoln("Pruning repository") + + args := []interface{}{"prune"} + if pruneOpts.DryRun { + args = append(args, "--dry-run") + } + if pruneOpts.RepackCacheableOnly { + args = append(args, "--repack-cacheable-only") + } + if pruneOpts.RepackSmall { + args = append(args, "--repack-small") + } + if pruneOpts.RepackUncompressed { + args = append(args, "--repack-uncompressed") + } + if pruneOpts.MaxUnusedLimit != "" { + args = append(args, + fmt.Sprintf("--max-unused=%s", pruneOpts.MaxUnusedLimit)) + } + if pruneOpts.MaxRepackSize != "" { + args = append(args, + fmt.Sprintf("--max-repack-size=%s", pruneOpts.MaxRepackSize)) + } + + args = w.appendCacheDirFlag(args) + args = w.appendMaxConnectionsFlag(args) + args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) + + return w.run(Command{Name: ResticCMD, Args: args}) +} + func (w *ResticWrapper) appendCacheDirFlag(args []interface{}) []interface{} { if w.config.EnableCache { cacheDir := filepath.Join(w.config.ScratchDir, resticCacheDir) diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go index 11b295fab..170a34fa9 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go @@ -78,6 +78,15 @@ type DumpOptions struct { StdoutPipeCommands []Command } +type PruneOptions struct { + MaxUnusedLimit string + MaxRepackSize string + DryRun bool + RepackUncompressed bool + RepackSmall bool + RepackCacheableOnly bool +} + type SetupOptions struct { Provider string Bucket string diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/migrate.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/migrate.go new file mode 100644 index 000000000..d0de4a789 --- /dev/null +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/migrate.go @@ -0,0 +1,25 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package restic + +func (w *ResticWrapper) Prune(pruneOpts PruneOptions) ([]byte, error) { + return w.prune(pruneOpts) +} + +func (w *ResticWrapper) MigrateRepoToV2() ([]byte, error) { + return w.migrateToV2() +}