mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-19 14:34:17 +00:00
allow individual backup storage locations to be read-only (#1517)
* allow individual backup storage locations to be read-only Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
committed by
Nolan Brubaker
parent
4e2e4cd5c4
commit
411d44a673
@@ -18,13 +18,14 @@ package backuplocation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/velero/pkg/apis/velero/v1"
|
||||
velerov1api "github.com/heptio/velero/pkg/apis/velero/v1"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/cmd/util/flag"
|
||||
@@ -53,17 +54,23 @@ func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||
}
|
||||
|
||||
type CreateOptions struct {
|
||||
Name string
|
||||
Provider string
|
||||
Bucket string
|
||||
Prefix string
|
||||
Config flag.Map
|
||||
Labels flag.Map
|
||||
Name string
|
||||
Provider string
|
||||
Bucket string
|
||||
Prefix string
|
||||
Config flag.Map
|
||||
Labels flag.Map
|
||||
AccessMode *flag.Enum
|
||||
}
|
||||
|
||||
func NewCreateOptions() *CreateOptions {
|
||||
return &CreateOptions{
|
||||
Config: flag.NewMap(),
|
||||
AccessMode: flag.NewEnum(
|
||||
string(velerov1api.BackupStorageLocationAccessModeReadWrite),
|
||||
string(velerov1api.BackupStorageLocationAccessModeReadWrite),
|
||||
string(velerov1api.BackupStorageLocationAccessModeReadOnly),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +80,11 @@ func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) {
|
||||
flags.StringVar(&o.Prefix, "prefix", o.Prefix, "prefix under which all Velero data should be stored within the bucket. Optional.")
|
||||
flags.Var(&o.Config, "config", "configuration key-value pairs")
|
||||
flags.Var(&o.Labels, "labels", "labels to apply to the backup storage location")
|
||||
flags.Var(
|
||||
o.AccessMode,
|
||||
"access-mode",
|
||||
fmt.Sprintf("access mode for the backup storage location. Valid values are %s", strings.Join(o.AccessMode.AllowedValues(), ",")),
|
||||
)
|
||||
}
|
||||
|
||||
func (o *CreateOptions) Validate(c *cobra.Command, args []string, f client.Factory) error {
|
||||
@@ -97,21 +109,22 @@ func (o *CreateOptions) Complete(args []string, f client.Factory) error {
|
||||
}
|
||||
|
||||
func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
backupStorageLocation := &api.BackupStorageLocation{
|
||||
backupStorageLocation := &velerov1api.BackupStorageLocation{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: f.Namespace(),
|
||||
Name: o.Name,
|
||||
Labels: o.Labels.Data(),
|
||||
},
|
||||
Spec: api.BackupStorageLocationSpec{
|
||||
Spec: velerov1api.BackupStorageLocationSpec{
|
||||
Provider: o.Provider,
|
||||
StorageType: api.StorageType{
|
||||
ObjectStorage: &api.ObjectStorageLocation{
|
||||
StorageType: velerov1api.StorageType{
|
||||
ObjectStorage: &velerov1api.ObjectStorageLocation{
|
||||
Bucket: o.Bucket,
|
||||
Prefix: o.Prefix,
|
||||
},
|
||||
},
|
||||
Config: o.Config.Data(),
|
||||
Config: o.Config.Data(),
|
||||
AccessMode: velerov1api.BackupStorageLocationAccessMode(o.AccessMode.String()),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user