diff --git a/go.mod b/go.mod index 9b17bbcbb..d9c0e706b 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,10 @@ require ( github.com/google/uuid v1.6.0 github.com/gorilla/handlers v1.5.2 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/go-iscsi-helper v0.0.0-20241018035016-4f89087f131a - github.com/longhorn/sparse-tools v0.0.0-20241018033304-1f5ba953b4cd + github.com/longhorn/backupstore v0.0.0-20241024044224-62c849e1f519 + github.com/longhorn/go-common-libs v0.0.0-20241024003634-9e7505c868e3 + github.com/longhorn/go-iscsi-helper v0.0.0-20241023025940-5ac6a9a21034 + github.com/longhorn/sparse-tools v0.0.0-20241023025917-7951cd783270 github.com/longhorn/types v0.0.0-20241007141758-3640f2357238 github.com/moby/moby v26.1.5+incompatible github.com/pkg/errors v0.9.1 @@ -25,7 +25,7 @@ require ( google.golang.org/protobuf v1.35.1 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c gopkg.in/cheggaaa/pb.v2 v2.0.7 - k8s.io/mount-utils v0.31.1 + k8s.io/mount-utils v0.31.2 ) require ( @@ -68,6 +68,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/text v0.19.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect gopkg.in/VividCortex/ewma.v1 v1.1.1 // indirect diff --git a/go.sum b/go.sum index f7238a78f..01cec72ac 100644 --- a/go.sum +++ b/go.sum @@ -79,14 +79,14 @@ 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/go-iscsi-helper v0.0.0-20241018035016-4f89087f131a h1:TarAvaVXy2+gLUvCAaVovr8BR9cvfvQALAxPly61bhg= -github.com/longhorn/go-iscsi-helper v0.0.0-20241018035016-4f89087f131a/go.mod h1:oWdfPL2qthHBLT+Gc+F+74hjCuVg3u9Ra/lj2s7rBKQ= -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/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-20241023025940-5ac6a9a21034 h1:WaqkKVEIZo/LJI5wtdBmysdtE3WctqiC6lb/UecNoyA= +github.com/longhorn/go-iscsi-helper v0.0.0-20241023025940-5ac6a9a21034/go.mod h1:su/M2NoR5ULmchuEG4DlihSyhaVwF7szia0L3GZ886A= +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/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -242,7 +242,7 @@ k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/mount-utils v0.31.1 h1:f8UrH9kRynljmdNGM6BaCvFUON5ZPKDgE+ltmYqI4wA= -k8s.io/mount-utils v0.31.1/go.mod h1:HV/VYBUGqYUj4vt82YltzpWvgv8FPg0G9ItyInT3NPU= +k8s.io/mount-utils v0.31.2 h1:Q0ygX92Lj9d1wcObAzj+JZ4oE7CNKZrqSOn1XcIS+y4= +k8s.io/mount-utils v0.31.2/go.mod h1:HV/VYBUGqYUj4vt82YltzpWvgv8FPg0G9ItyInT3NPU= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= diff --git a/vendor/github.com/longhorn/backupstore/backupbackingimage/config.go b/vendor/github.com/longhorn/backupstore/backupbackingimage/config.go index 6af28d23f..8fc78d291 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 69aced9ce..dc18368fe 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 000000000..6a66aea5e --- /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 000000000..733099041 --- /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 000000000..2c033dff4 --- /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 8b3dcaea0..89acdf21f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -161,7 +161,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 @@ -178,7 +178,7 @@ github.com/longhorn/backupstore/systembackup 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 @@ -190,14 +190,14 @@ github.com/longhorn/go-common-libs/sync github.com/longhorn/go-common-libs/sys github.com/longhorn/go-common-libs/types github.com/longhorn/go-common-libs/utils -# github.com/longhorn/go-iscsi-helper v0.0.0-20241018035016-4f89087f131a +# github.com/longhorn/go-iscsi-helper v0.0.0-20241023025940-5ac6a9a21034 ## explicit; go 1.22.0 github.com/longhorn/go-iscsi-helper/iscsi github.com/longhorn/go-iscsi-helper/iscsidev github.com/longhorn/go-iscsi-helper/longhorndev github.com/longhorn/go-iscsi-helper/types github.com/longhorn/go-iscsi-helper/util -# 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/cli/ssync github.com/longhorn/sparse-tools/sparse @@ -299,6 +299,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 @@ -463,7 +466,7 @@ k8s.io/klog/v2/internal/dbg k8s.io/klog/v2/internal/serialize k8s.io/klog/v2/internal/severity k8s.io/klog/v2/internal/sloghandler -# k8s.io/mount-utils v0.31.1 +# k8s.io/mount-utils v0.31.2 ## explicit; go 1.22.0 k8s.io/mount-utils # k8s.io/utils v0.0.0-20240711033017-18e509b52bc8