Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick] Update restic version (#168) #170

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ else
endif
endif

RESTIC_VER := 0.13.1
RESTIC_VER := 0.17.3
NATS_CLI_VER := 0.0.32
###
### These variables should not need tweaking.
Expand Down Expand Up @@ -282,7 +282,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 $@
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
kmodules.xyz/client-go v0.30.44
kmodules.xyz/custom-resources v0.30.0
kmodules.xyz/offshoot-api v0.30.1
stash.appscode.dev/apimachinery v0.38.0
stash.appscode.dev/apimachinery v0.38.1-0.20250114050236-cca8469a4c04
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -554,5 +554,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=
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,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
Expand Down
43 changes: 43 additions & 0 deletions vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions vendor/stash.appscode.dev/apimachinery/pkg/restic/migrate.go
Original file line number Diff line number Diff line change
@@ -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()
}
Loading