diff --git a/go.mod b/go.mod index b705e402d..b77d07c6b 100644 --- a/go.mod +++ b/go.mod @@ -11,15 +11,15 @@ require ( gomodules.xyz/logs v0.0.7 gomodules.xyz/pointer v0.1.0 gomodules.xyz/x v0.0.15 - k8s.io/api v0.25.3 - k8s.io/apimachinery v0.25.3 - k8s.io/client-go v0.25.3 - k8s.io/klog/v2 v2.80.1 - kmodules.xyz/client-go v0.25.37 - kmodules.xyz/custom-resources v0.25.2 - kmodules.xyz/offshoot-api v0.25.4 - kubedb.dev/apimachinery v0.33.1 - stash.appscode.dev/apimachinery v0.32.0 + k8s.io/api v0.29.0 + k8s.io/apimachinery v0.29.0 + k8s.io/client-go v0.29.0 + k8s.io/klog/v2 v2.110.1 + kmodules.xyz/client-go v0.29.5 + kmodules.xyz/custom-resources v0.29.0 + kmodules.xyz/offshoot-api v0.29.0 + kubedb.dev/apimachinery v0.40.1-0.20240101000103-032b27211164 + stash.appscode.dev/apimachinery v0.32.1-0.20240202121916-8f4a855a72c8 ) require github.com/onsi/gomega v1.20.1 // indirect diff --git a/go.sum b/go.sum index de47af920..1ea56f3d9 100644 --- a/go.sum +++ b/go.sum @@ -897,15 +897,11 @@ kmodules.xyz/prober v0.25.0/go.mod h1:z4RTnjaajNQa/vPltsiOnO3xI716I/ziD2ac2Exm+1 kubedb.dev/apimachinery v0.33.1 h1:tZCe6hHslSsiV+nvhzIrFt01WLDqQjMc/DYxyH8DVWA= kubedb.dev/apimachinery v0.33.1/go.mod h1:NeUOOmIS8E0TdDCSJcyYrbbs7wvebSXGO9ddredvgRs= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/controller-runtime v0.13.1 h1:tUsRCSJVM1QQOOeViGeX3GMT3dQF1eePPw6sEE3xSlg= -sigs.k8s.io/controller-runtime v0.13.1/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= -stash.appscode.dev/apimachinery v0.32.0 h1:WgbZi/In8GCV/r5zx6KD9onDMQviQ74RpCjUbZBm6vs= -stash.appscode.dev/apimachinery v0.32.0/go.mod h1:sRMQDbHN5AH9Ntz2HfixcepaP0L0HWFNAqGN22GrBzc= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +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.32.1-0.20240202121916-8f4a855a72c8 h1:p3kd1saM5Ehz9mkqJhVrcFDhY0Bjv8S0XYuq2dZb3KI= +stash.appscode.dev/apimachinery v0.32.1-0.20240202121916-8f4a855a72c8/go.mod h1:cPdkM9Upe5hxgxrV+WlIQCq7K0Tpx//VUwFs0NKB7ek= diff --git a/pkg/backup.go b/pkg/backup.go index c9bdcffb2..8c3ebe39b 100644 --- a/pkg/backup.go +++ b/pkg/backup.go @@ -178,6 +178,7 @@ func NewCmdBackup() *cobra.Command { cmd.Flags().StringVar(&opt.setupOptions.Provider, "provider", opt.setupOptions.Provider, "Backend provider (i.e. gcs, s3, azure etc)") cmd.Flags().StringVar(&opt.setupOptions.Bucket, "bucket", opt.setupOptions.Bucket, "Name of the cloud bucket/container (keep empty for local backend)") cmd.Flags().StringVar(&opt.setupOptions.Endpoint, "endpoint", opt.setupOptions.Endpoint, "Endpoint for s3/s3 compatible backend or REST server URL") + cmd.Flags().BoolVar(&opt.setupOptions.InsecureTLS, "insecure-tls", opt.setupOptions.InsecureTLS, "InsecureTLS for TLS secure s3/s3 compatible backend") cmd.Flags().StringVar(&opt.setupOptions.Region, "region", opt.setupOptions.Region, "Region for s3/s3 compatible backend") cmd.Flags().StringVar(&opt.setupOptions.Path, "path", opt.setupOptions.Path, "Directory inside the bucket where backup will be stored") cmd.Flags().StringVar(&opt.setupOptions.ScratchDir, "scratch-dir", opt.setupOptions.ScratchDir, "Temporary directory") diff --git a/pkg/restore.go b/pkg/restore.go index db27d0a8d..3bc9cbc45 100644 --- a/pkg/restore.go +++ b/pkg/restore.go @@ -134,6 +134,7 @@ func NewCmdRestore() *cobra.Command { cmd.Flags().StringVar(&opt.setupOptions.Provider, "provider", opt.setupOptions.Provider, "Backend provider (i.e. gcs, s3, azure etc)") cmd.Flags().StringVar(&opt.setupOptions.Bucket, "bucket", opt.setupOptions.Bucket, "Name of the cloud bucket/container (keep empty for local backend)") cmd.Flags().StringVar(&opt.setupOptions.Endpoint, "endpoint", opt.setupOptions.Endpoint, "Endpoint for s3/s3 compatible backend or REST server URL") + cmd.Flags().BoolVar(&opt.setupOptions.InsecureTLS, "insecure-tls", opt.setupOptions.InsecureTLS, "InsecureTLS for TLS secure s3/s3 compatible backend") cmd.Flags().StringVar(&opt.setupOptions.Region, "region", opt.setupOptions.Region, "Region for s3/s3 compatible backend") cmd.Flags().StringVar(&opt.setupOptions.Path, "path", opt.setupOptions.Path, "Directory inside the bucket where backup will be stored") cmd.Flags().StringVar(&opt.setupOptions.ScratchDir, "scratch-dir", opt.setupOptions.ScratchDir, "Temporary directory") diff --git a/vendor/modules.txt b/vendor/modules.txt index 0ba129dca..536366ad8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -706,8 +706,9 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.3.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# stash.appscode.dev/apimachinery v0.32.0 -## explicit; go 1.18 +sigs.k8s.io/yaml/goyaml.v2 +# stash.appscode.dev/apimachinery v0.32.1-0.20240202121916-8f4a855a72c8 +## explicit; go 1.21.5 stash.appscode.dev/apimachinery/apis stash.appscode.dev/apimachinery/apis/repositories stash.appscode.dev/apimachinery/apis/repositories/v1alpha1 diff --git a/vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go b/vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go index 999cc8701..76bddcfb2 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/repositories/v1alpha1/openapi_generated.go @@ -18716,6 +18716,12 @@ func schema_kmodulesxyz_objectstore_api_api_v1_S3Spec(ref common.ReferenceCallba Format: "", }, }, + "insecureTLS": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, }, Required: []string{"endpoint", "bucket"}, }, diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go index 7c7b7d3dc..fb76a15eb 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1alpha1/openapi_generated.go @@ -18721,6 +18721,12 @@ func schema_kmodulesxyz_objectstore_api_api_v1_S3Spec(ref common.ReferenceCallba Format: "", }, }, + "insecureTLS": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, }, Required: []string{"endpoint", "bucket"}, }, diff --git a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/openapi_generated.go b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/openapi_generated.go index 3e86e3326..8ea9c02c7 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/openapi_generated.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/stash/v1beta1/openapi_generated.go @@ -18767,6 +18767,12 @@ func schema_kmodulesxyz_objectstore_api_api_v1_S3Spec(ref common.ReferenceCallba Format: "", }, }, + "insecureTLS": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, }, Required: []string{"endpoint", "bucket"}, }, diff --git a/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/openapi_generated.go b/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/openapi_generated.go index bc4d50112..1bfc432b8 100644 --- a/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/openapi_generated.go +++ b/vendor/stash.appscode.dev/apimachinery/apis/ui/v1alpha1/openapi_generated.go @@ -18716,6 +18716,12 @@ func schema_kmodulesxyz_objectstore_api_api_v1_S3Spec(ref common.ReferenceCallba Format: "", }, }, + "insecureTLS": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, }, Required: []string{"endpoint", "bucket"}, }, diff --git a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupblueprints.yaml b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupblueprints.yaml index 4e17b3ed7..9b23a4221 100644 --- a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupblueprints.yaml +++ b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_backupblueprints.yaml @@ -1652,6 +1652,8 @@ spec: type: string endpoint: type: string + insecureTLS: + type: boolean prefix: type: string region: diff --git a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_repositories.yaml b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_repositories.yaml index 3cdd5ce08..6da19d24d 100644 --- a/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_repositories.yaml +++ b/vendor/stash.appscode.dev/apimachinery/crds/stash.appscode.com_repositories.yaml @@ -1659,6 +1659,8 @@ spec: type: string endpoint: type: string + insecureTLS: + type: boolean prefix: type: string region: diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go index 2723ec351..fd4a83774 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go @@ -80,6 +80,7 @@ func (w *ResticWrapper) listSnapshots(snapshotIDs []string) ([]Snapshot, error) result := make([]Snapshot, 0) args := w.appendCacheDirFlag([]interface{}{"snapshots", "--json", "--quiet", "--no-lock"}) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) for _, id := range snapshotIDs { args = append(args, id) @@ -95,6 +96,7 @@ func (w *ResticWrapper) listSnapshots(snapshotIDs []string) ([]Snapshot, error) func (w *ResticWrapper) deleteSnapshots(snapshotIDs []string) ([]byte, error) { args := w.appendCacheDirFlag([]interface{}{"forget", "--quiet", "--prune"}) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) for _, id := range snapshotIDs { args = append(args, id) @@ -107,6 +109,7 @@ func (w *ResticWrapper) repositoryExist() bool { klog.Infoln("Checking whether the backend repository exist or not....") args := w.appendCacheDirFlag([]interface{}{"snapshots", "--json", "--no-lock"}) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) if _, err := w.run(Command{Name: ResticCMD, Args: args}); err == nil { return true @@ -122,6 +125,7 @@ func (w *ResticWrapper) initRepository() error { args := w.appendCacheDirFlag([]interface{}{"init"}) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) _, err := w.run(Command{Name: ResticCMD, Args: args}) return err @@ -151,6 +155,7 @@ func (w *ResticWrapper) backup(params backupParams) ([]byte, error) { args = w.appendCacheDirFlag(args) args = w.appendCleanupCacheFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) @@ -174,6 +179,7 @@ func (w *ResticWrapper) backupFromStdin(options BackupOptions) ([]byte, error) { args = w.appendCacheDirFlag(args) args = w.appendCleanupCacheFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) commands = append(commands, Command{Name: ResticCMD, Args: args}) @@ -248,6 +254,7 @@ func (w *ResticWrapper) tryCleanup(retentionPolicy v1alpha1.RetentionPolicy, hos if len(args) > 1 { args = w.appendCacheDirFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) @@ -294,6 +301,7 @@ func (w *ResticWrapper) restore(params restoreParams) ([]byte, error) { } args = w.appendCacheDirFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) @@ -325,6 +333,7 @@ func (w *ResticWrapper) DumpOnce(dumpOptions DumpOptions) ([]byte, error) { args = w.appendCacheDirFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) // first add restic command, then add StdoutPipeCommands @@ -339,6 +348,7 @@ func (w *ResticWrapper) check() ([]byte, error) { klog.Infoln("Checking integrity of repository") args := w.appendCacheDirFlag([]interface{}{"check", "--no-lock"}) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) @@ -353,6 +363,7 @@ func (w *ResticWrapper) stats(snapshotID string) ([]byte, error) { args = w.appendMaxConnectionsFlag(args) args = append(args, "--quiet", "--json", "--mode", "raw-data", "--no-lock") args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) } @@ -362,6 +373,7 @@ func (w *ResticWrapper) unlock() ([]byte, error) { args := w.appendCacheDirFlag([]interface{}{"unlock", "--remove-all"}) args = w.appendMaxConnectionsFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) } @@ -515,6 +527,7 @@ func (w *ResticWrapper) addKey(params keyParams) ([]byte, error) { args = w.appendCacheDirFlag(args) args = w.appendMaxConnectionsFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) } @@ -527,6 +540,7 @@ func (w *ResticWrapper) listKey() ([]byte, error) { args = w.appendCacheDirFlag(args) args = w.appendMaxConnectionsFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) } @@ -543,6 +557,7 @@ func (w *ResticWrapper) updateKey(params keyParams) ([]byte, error) { args = w.appendCacheDirFlag(args) args = w.appendMaxConnectionsFlag(args) args = w.appendCaCertFlag(args) + args = w.appendInsecureTLSFlag(args) return w.run(Command{Name: ResticCMD, Args: args}) } @@ -555,6 +570,14 @@ func (w *ResticWrapper) removeKey(params keyParams) ([]byte, error) { 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) appendInsecureTLSFlag(args []interface{}) []interface{} { + if w.config.InsecureTLS { + return append(args, "--insecure-tls") + } + return args +} diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go index a070db441..11b295fab 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/config.go @@ -87,6 +87,7 @@ type SetupOptions struct { CacertFile string ScratchDir string EnableCache bool + InsecureTLS bool MaxConnections int64 StorageSecret *core.Secret Nice *ofst.NiceSettings diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/util/addon.go b/vendor/stash.appscode.dev/apimachinery/pkg/util/addon.go index cff35cbf4..bb8d762c4 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/util/addon.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/util/addon.go @@ -60,8 +60,8 @@ func ExtractAddonInfo(appClient appcatalog_cs.Interface, task v1beta1.TaskRef, t addon.RestoreTask.Name = task.Name } if len(task.Params) != 0 { - addon.BackupTask.Params = getTaskParams(task) - addon.RestoreTask.Params = getTaskParams(task) + addon.BackupTask.Params = upsertParams(addon.BackupTask.Params, getTaskParams(task)) + addon.RestoreTask.Params = upsertParams(addon.BackupTask.Params, getTaskParams(task)) } return &addon, nil @@ -75,3 +75,24 @@ func getTaskParams(task v1beta1.TaskRef) []appcat.Param { } return params } + +func upsertParams(oldParams, newParams []appcat.Param) []appcat.Param { + paramMap := make(map[string]appcat.Param) + + for _, newParam := range newParams { + paramMap[newParam.Name] = newParam + } + + for _, oldParam := range oldParams { + if _, found := paramMap[oldParam.Name]; !found { + paramMap[oldParam.Name] = oldParam + } + } + + var updatedParams []appcat.Param + for _, param := range paramMap { + updatedParams = append(updatedParams, param) + } + + return updatedParams +}