diff --git a/go.mod b/go.mod index 7f8231af..174a557e 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,10 @@ require ( github.com/RoaringBitmap/roaring v1.9.4 github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.1 - github.com/longhorn/backupstore v0.0.0-20241019064138-ef7b22d3fcb0 - github.com/longhorn/go-common-libs v0.0.0-20241018042323-54da24c0807f + github.com/longhorn/backupstore v0.0.0-20241024044224-62c849e1f519 + github.com/longhorn/go-common-libs v0.0.0-20241024003634-9e7505c868e3 github.com/longhorn/longhorn-engine v1.7.2 - github.com/longhorn/sparse-tools v0.0.0-20241018033304-1f5ba953b4cd + github.com/longhorn/sparse-tools v0.0.0-20241023025917-7951cd783270 github.com/longhorn/types v0.0.0-20241007141758-3640f2357238 github.com/pkg/errors v0.9.1 github.com/rancher/go-fibmap v0.0.0-20160418233256-5fc9f8c1ed47 @@ -63,6 +63,7 @@ require ( github.com/shirou/gopsutil/v3 v3.24.5 // indirect github.com/slok/goresilience v0.2.0 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect + golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/sys v0.26.0 // indirect golang.org/x/text v0.19.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect diff --git a/go.sum b/go.sum index 33b232c1..f8a9b3e8 100644 --- a/go.sum +++ b/go.sum @@ -74,16 +74,16 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/longhorn/backupstore v0.0.0-20241019064138-ef7b22d3fcb0 h1:5GvcnLoSIL7re4ACTDtQrvf7Vv1eBtiCTIQK3hLApR0= -github.com/longhorn/backupstore v0.0.0-20241019064138-ef7b22d3fcb0/go.mod h1:4K4Z8zeVXbp5pcozF8fGrZRXatxIreqNH/xWa93odAQ= -github.com/longhorn/go-common-libs v0.0.0-20241018042323-54da24c0807f h1:X0Ty+fnoZ5ExhHdD42TdXd2GAU5sXyaio3AAZlO3fwI= -github.com/longhorn/go-common-libs v0.0.0-20241018042323-54da24c0807f/go.mod h1:ypnoivZeYoZVRqeI2MQHEGA+Vqt8DZVkCbhf/3Ogx7Q= +github.com/longhorn/backupstore v0.0.0-20241024044224-62c849e1f519 h1:cDLRmtKNlMFfhJUN57ZPe/sDveuriy0n+pqDPXkjhz8= +github.com/longhorn/backupstore v0.0.0-20241024044224-62c849e1f519/go.mod h1:4K4Z8zeVXbp5pcozF8fGrZRXatxIreqNH/xWa93odAQ= +github.com/longhorn/go-common-libs v0.0.0-20241024003634-9e7505c868e3 h1:mWgSoMgTYoguJt4TBYSrq3ZweQR11GHPxEth39QiT2o= +github.com/longhorn/go-common-libs v0.0.0-20241024003634-9e7505c868e3/go.mod h1:00v9OlN7rulbJxh7ZM3h0J9UfXQ0EAHzuS2zlJgqno0= github.com/longhorn/go-iscsi-helper v0.0.0-20241006012607-08f5166d1fad h1:AqhTx1s0Ym//9Tdhyo/i+gCpRAJLFwue8QWD5XCRVz8= github.com/longhorn/go-iscsi-helper v0.0.0-20241006012607-08f5166d1fad/go.mod h1:pumnMfyGDTfupyMeT7G3m/Xc15Veo8nKkod5Unv4ff0= github.com/longhorn/longhorn-engine v1.7.2 h1:vinyycvF8zfHQitieUZtcMR6bKjC2dPdiwEm0QVn9YM= github.com/longhorn/longhorn-engine v1.7.2/go.mod h1:WVBJZtUcj3hMoEBJe0PsbdDQ/+9GTu2Tq/mRQc75obQ= -github.com/longhorn/sparse-tools v0.0.0-20241018033304-1f5ba953b4cd h1:wz3WOk+ytSDZInHFLcMWF5DzLtI7wgNNaUC6w2Qa5RE= -github.com/longhorn/sparse-tools v0.0.0-20241018033304-1f5ba953b4cd/go.mod h1:iUJCZtOKG/9xv2rfrUAYZntFTzP5dZtvy4Kwe6dMcUc= +github.com/longhorn/sparse-tools v0.0.0-20241023025917-7951cd783270 h1:F13lddDaeUX8dBwRqOT/aXtb2C1szwqIFgW4KpZgCGw= +github.com/longhorn/sparse-tools v0.0.0-20241023025917-7951cd783270/go.mod h1:iUJCZtOKG/9xv2rfrUAYZntFTzP5dZtvy4Kwe6dMcUc= github.com/longhorn/types v0.0.0-20241007141758-3640f2357238 h1:zo3jTRYbH1KtO2TwgIt3eb4wTLGAfN/SAzWJsOwY+Pc= github.com/longhorn/types v0.0.0-20241007141758-3640f2357238/go.mod h1:IpV+1bctQgBgp3brj0nsHmnBDFkd5IrzTgBtVAloJuw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= diff --git a/vendor/github.com/longhorn/backupstore/backupbackingimage/config.go b/vendor/github.com/longhorn/backupstore/backupbackingimage/config.go index 6af28d23..8fc78d29 100644 --- a/vendor/github.com/longhorn/backupstore/backupbackingimage/config.go +++ b/vendor/github.com/longhorn/backupstore/backupbackingimage/config.go @@ -4,6 +4,7 @@ import ( "fmt" "net/url" "path/filepath" + "strings" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -115,9 +116,27 @@ func getBackingImageBlockPath() string { } func EncodeBackupBackingImageURL(backingImageName, destURL string) string { + if destURL == "" || backingImageName == "" { + return "" + } + + u, err := url.Parse(destURL) + if err != nil { + log := backupstore.GetLog() + log.WithError(err).Errorf("Failed to parse destURL %v", destURL) + return "" + } + if u.Scheme == "" { + return "" + } + v := url.Values{} v.Add("backingImage", backingImageName) - return destURL + "?" + v.Encode() + prefixChar := "?" + if strings.Contains(destURL, "?") { + prefixChar = "&" + } + return destURL + prefixChar + v.Encode() } func DecodeBackupBackingImageURL(backupURL string) (string, string, error) { diff --git a/vendor/github.com/longhorn/go-common-libs/utils/misc.go b/vendor/github.com/longhorn/go-common-libs/utils/misc.go index 69aced9c..dc18368f 100644 --- a/vendor/github.com/longhorn/go-common-libs/utils/misc.go +++ b/vendor/github.com/longhorn/go-common-libs/utils/misc.go @@ -7,11 +7,13 @@ import ( "path/filepath" "reflect" "runtime" + "sort" "strconv" "strings" "github.com/google/uuid" "github.com/pkg/errors" + "golang.org/x/exp/constraints" "github.com/longhorn/go-common-libs/types" ) @@ -119,3 +121,21 @@ func ConvertTypeToString[T any](value T) string { return fmt.Sprintf("Unsupported type: %v", v.Kind()) } } + +// SortKeys sorts the keys of a map in ascending order. +func SortKeys[K constraints.Ordered, V any](mapObj map[K]V) ([]K, error) { + if mapObj == nil { + return nil, fmt.Errorf("input object cannot be nil") + } + + keys := make([]K, 0, len(mapObj)) + for key := range mapObj { + keys = append(keys, key) + } + + sort.Slice(keys, func(i, j int) bool { + return keys[i] < keys[j] + }) + + return keys, nil +} diff --git a/vendor/golang.org/x/exp/LICENSE b/vendor/golang.org/x/exp/LICENSE new file mode 100644 index 00000000..6a66aea5 --- /dev/null +++ b/vendor/golang.org/x/exp/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/exp/PATENTS b/vendor/golang.org/x/exp/PATENTS new file mode 100644 index 00000000..73309904 --- /dev/null +++ b/vendor/golang.org/x/exp/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/exp/constraints/constraints.go b/vendor/golang.org/x/exp/constraints/constraints.go new file mode 100644 index 00000000..2c033dff --- /dev/null +++ b/vendor/golang.org/x/exp/constraints/constraints.go @@ -0,0 +1,50 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package constraints defines a set of useful constraints to be used +// with type parameters. +package constraints + +// Signed is a constraint that permits any signed integer type. +// If future releases of Go add new predeclared signed integer types, +// this constraint will be modified to include them. +type Signed interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 +} + +// Unsigned is a constraint that permits any unsigned integer type. +// If future releases of Go add new predeclared unsigned integer types, +// this constraint will be modified to include them. +type Unsigned interface { + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr +} + +// Integer is a constraint that permits any integer type. +// If future releases of Go add new predeclared integer types, +// this constraint will be modified to include them. +type Integer interface { + Signed | Unsigned +} + +// Float is a constraint that permits any floating-point type. +// If future releases of Go add new predeclared floating-point types, +// this constraint will be modified to include them. +type Float interface { + ~float32 | ~float64 +} + +// Complex is a constraint that permits any complex numeric type. +// If future releases of Go add new predeclared complex numeric types, +// this constraint will be modified to include them. +type Complex interface { + ~complex64 | ~complex128 +} + +// Ordered is a constraint that permits any ordered type: any type +// that supports the operators < <= >= >. +// If future releases of Go add new ordered types, +// this constraint will be modified to include them. +type Ordered interface { + Integer | Float | ~string +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d3af6c93..afe60e21 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -157,7 +157,7 @@ github.com/kr/pretty # github.com/kr/text v0.2.0 ## explicit github.com/kr/text -# github.com/longhorn/backupstore v0.0.0-20241019064138-ef7b22d3fcb0 +# github.com/longhorn/backupstore v0.0.0-20241024044224-62c849e1f519 ## explicit; go 1.22.0 github.com/longhorn/backupstore github.com/longhorn/backupstore/azblob @@ -172,7 +172,7 @@ github.com/longhorn/backupstore/s3 github.com/longhorn/backupstore/types github.com/longhorn/backupstore/util github.com/longhorn/backupstore/vfs -# github.com/longhorn/go-common-libs v0.0.0-20241018042323-54da24c0807f +# github.com/longhorn/go-common-libs v0.0.0-20241024003634-9e7505c868e3 ## explicit; go 1.22.0 github.com/longhorn/go-common-libs/backup github.com/longhorn/go-common-libs/exec @@ -197,7 +197,7 @@ github.com/longhorn/longhorn-engine/pkg/replica/client github.com/longhorn/longhorn-engine/pkg/types github.com/longhorn/longhorn-engine/pkg/util github.com/longhorn/longhorn-engine/pkg/util/disk -# github.com/longhorn/sparse-tools v0.0.0-20241018033304-1f5ba953b4cd +# github.com/longhorn/sparse-tools v0.0.0-20241023025917-7951cd783270 ## explicit; go 1.22.0 github.com/longhorn/sparse-tools/sparse github.com/longhorn/sparse-tools/sparse/rest @@ -287,6 +287,9 @@ github.com/urfave/cli # github.com/yusufpapurcu/wmi v1.2.4 ## explicit; go 1.16 github.com/yusufpapurcu/wmi +# golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc +## explicit; go 1.20 +golang.org/x/exp/constraints # golang.org/x/net v0.30.0 ## explicit; go 1.18 golang.org/x/net/context