mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-20 15:04:17 +00:00
Rename Ark to Velero!!!
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
committed by
Andy Goldstein
parent
bbc6caf7fe
commit
43714caaec
@@ -19,7 +19,7 @@ package backup
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
@@ -25,13 +25,13 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/flag"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
arkclient "github.com/heptio/ark/pkg/generated/clientset/versioned"
|
||||
"github.com/heptio/ark/pkg/generated/informers/externalversions/ark/v1"
|
||||
api "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"
|
||||
"github.com/heptio/velero/pkg/cmd/util/output"
|
||||
veleroclient "github.com/heptio/velero/pkg/generated/clientset/versioned"
|
||||
v1 "github.com/heptio/velero/pkg/generated/informers/externalversions/velero/v1"
|
||||
)
|
||||
|
||||
func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -71,7 +71,7 @@ type CreateOptions struct {
|
||||
StorageLocation string
|
||||
SnapshotLocations []string
|
||||
|
||||
client arkclient.Interface
|
||||
client veleroclient.Interface
|
||||
}
|
||||
|
||||
func NewCreateOptions() *CreateOptions {
|
||||
@@ -115,13 +115,13 @@ func (o *CreateOptions) Validate(c *cobra.Command, args []string, f client.Facto
|
||||
}
|
||||
|
||||
if o.StorageLocation != "" {
|
||||
if _, err := o.client.ArkV1().BackupStorageLocations(f.Namespace()).Get(o.StorageLocation, metav1.GetOptions{}); err != nil {
|
||||
if _, err := o.client.VeleroV1().BackupStorageLocations(f.Namespace()).Get(o.StorageLocation, metav1.GetOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, loc := range o.SnapshotLocations {
|
||||
if _, err := o.client.ArkV1().VolumeSnapshotLocations(f.Namespace()).Get(loc, metav1.GetOptions{}); err != nil {
|
||||
if _, err := o.client.VeleroV1().VolumeSnapshotLocations(f.Namespace()).Get(loc, metav1.GetOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
go backupInformer.Run(stop)
|
||||
}
|
||||
|
||||
_, err := o.client.ArkV1().Backups(backup.Namespace).Create(backup)
|
||||
_, err := o.client.VeleroV1().Backups(backup.Namespace).Create(backup)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -226,7 +226,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
}
|
||||
|
||||
if backup.Status.Phase != api.BackupPhaseNew && backup.Status.Phase != api.BackupPhaseInProgress {
|
||||
fmt.Printf("\nBackup completed with status: %s. You may check for more information using the commands `ark backup describe %s` and `ark backup logs %s`.\n", backup.Status.Phase, backup.Name, backup.Name)
|
||||
fmt.Printf("\nBackup completed with status: %s. You may check for more information using the commands `velero backup describe %s` and `velero backup logs %s`.\n", backup.Status.Phase, backup.Name, backup.Name)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
|
||||
// Not waiting
|
||||
|
||||
fmt.Printf("Run `ark backup describe %s` or `ark backup logs %s` for more details.\n", backup.Name, backup.Name)
|
||||
fmt.Printf("Run `velero backup describe %s` or `velero backup logs %s` for more details.\n", backup.Name, backup.Name)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ import (
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
kubeerrs "k8s.io/apimachinery/pkg/util/errors"
|
||||
|
||||
arkv1api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/backup"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/cli"
|
||||
velerov1api "github.com/heptio/velero/pkg/apis/velero/v1"
|
||||
"github.com/heptio/velero/pkg/backup"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/cmd/cli"
|
||||
)
|
||||
|
||||
// NewDeleteCommand creates a new command that deletes a backup.
|
||||
@@ -40,19 +40,19 @@ func NewDeleteCommand(f client.Factory, use string) *cobra.Command {
|
||||
Use: fmt.Sprintf("%s [NAMES]", use),
|
||||
Short: "Delete backups",
|
||||
Example: ` # delete a backup named "backup-1"
|
||||
ark backup delete backup-1
|
||||
velero backup delete backup-1
|
||||
|
||||
# delete a backup named "backup-1" without prompting for confirmation
|
||||
ark backup delete backup-1 --confirm
|
||||
velero backup delete backup-1 --confirm
|
||||
|
||||
# delete backups named "backup-1" and "backup-2"
|
||||
ark backup delete backup-1 backup-2
|
||||
velero backup delete backup-1 backup-2
|
||||
|
||||
# delete all backups triggered by schedule "schedule-1"
|
||||
ark backup delete --selector ark-schedule=schedule-1
|
||||
velero backup delete --selector velero.io/schedule-name=schedule-1
|
||||
|
||||
# delete all backups
|
||||
ark backup delete --all
|
||||
velero backup delete --all
|
||||
`,
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
cmd.CheckError(o.Complete(f, args))
|
||||
@@ -74,7 +74,7 @@ func Run(o *cli.DeleteOptions) error {
|
||||
}
|
||||
|
||||
var (
|
||||
backups []*arkv1api.Backup
|
||||
backups []*velerov1api.Backup
|
||||
errs []error
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ func Run(o *cli.DeleteOptions) error {
|
||||
switch {
|
||||
case len(o.Names) > 0:
|
||||
for _, name := range o.Names {
|
||||
backup, err := o.Client.ArkV1().Backups(o.Namespace).Get(name, metav1.GetOptions{})
|
||||
backup, err := o.Client.VeleroV1().Backups(o.Namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
errs = append(errs, errors.WithStack(err))
|
||||
continue
|
||||
@@ -96,7 +96,7 @@ func Run(o *cli.DeleteOptions) error {
|
||||
selector = o.Selector.String()
|
||||
}
|
||||
|
||||
res, err := o.Client.ArkV1().Backups(o.Namespace).List(metav1.ListOptions{LabelSelector: selector})
|
||||
res, err := o.Client.VeleroV1().Backups(o.Namespace).List(metav1.ListOptions{LabelSelector: selector})
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
@@ -114,7 +114,7 @@ func Run(o *cli.DeleteOptions) error {
|
||||
for _, b := range backups {
|
||||
deleteRequest := backup.NewDeleteBackupRequest(b.Name, string(b.UID))
|
||||
|
||||
if _, err := o.Client.ArkV1().DeleteBackupRequests(o.Namespace).Create(deleteRequest); err != nil {
|
||||
if _, err := o.Client.VeleroV1().DeleteBackupRequests(o.Namespace).Create(deleteRequest); err != nil {
|
||||
errs = append(errs, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
pkgbackup "github.com/heptio/ark/pkg/backup"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
"github.com/heptio/ark/pkg/restic"
|
||||
v1 "github.com/heptio/velero/pkg/apis/velero/v1"
|
||||
pkgbackup "github.com/heptio/velero/pkg/backup"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/cmd/util/output"
|
||||
"github.com/heptio/velero/pkg/restic"
|
||||
)
|
||||
|
||||
func NewDescribeCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -41,37 +41,37 @@ func NewDescribeCommand(f client.Factory, use string) *cobra.Command {
|
||||
Use: use + " [NAME1] [NAME2] [NAME...]",
|
||||
Short: "Describe backups",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
var backups *v1.BackupList
|
||||
if len(args) > 0 {
|
||||
backups = new(v1.BackupList)
|
||||
for _, name := range args {
|
||||
backup, err := arkClient.Ark().Backups(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
backup, err := veleroClient.VeleroV1().Backups(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
backups.Items = append(backups.Items, *backup)
|
||||
}
|
||||
} else {
|
||||
backups, err = arkClient.ArkV1().Backups(f.Namespace()).List(listOptions)
|
||||
backups, err = veleroClient.VeleroV1().Backups(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
first := true
|
||||
for _, backup := range backups.Items {
|
||||
deleteRequestListOptions := pkgbackup.NewDeleteBackupRequestListOptions(backup.Name, string(backup.UID))
|
||||
deleteRequestList, err := arkClient.ArkV1().DeleteBackupRequests(f.Namespace()).List(deleteRequestListOptions)
|
||||
deleteRequestList, err := veleroClient.VeleroV1().DeleteBackupRequests(f.Namespace()).List(deleteRequestListOptions)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error getting DeleteBackupRequests for backup %s: %v\n", backup.Name, err)
|
||||
}
|
||||
|
||||
opts := restic.NewPodVolumeBackupListOptions(backup.Name, string(backup.UID))
|
||||
podVolumeBackupList, err := arkClient.ArkV1().PodVolumeBackups(f.Namespace()).List(opts)
|
||||
opts := restic.NewPodVolumeBackupListOptions(backup.Name)
|
||||
podVolumeBackupList, err := veleroClient.VeleroV1().PodVolumeBackups(f.Namespace()).List(opts)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error getting PodVolumeBackups for backup %s: %v\n", backup.Name, err)
|
||||
}
|
||||
|
||||
s := output.DescribeBackup(&backup, deleteRequestList.Items, podVolumeBackupList.Items, details, arkClient)
|
||||
s := output.DescribeBackup(&backup, deleteRequestList.Items, podVolumeBackupList.Items, details, veleroClient)
|
||||
if first {
|
||||
first = false
|
||||
fmt.Print(s)
|
||||
|
||||
@@ -26,10 +26,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/downloadrequest"
|
||||
v1 "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/downloadrequest"
|
||||
)
|
||||
|
||||
func NewDownloadCommand(f client.Factory) *cobra.Command {
|
||||
@@ -94,7 +94,7 @@ func (o *DownloadOptions) Complete(args []string) error {
|
||||
}
|
||||
|
||||
func (o *DownloadOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
backupDest, err := os.OpenFile(o.Output, o.writeOptions, 0600)
|
||||
@@ -103,7 +103,7 @@ func (o *DownloadOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
}
|
||||
defer backupDest.Close()
|
||||
|
||||
err = downloadrequest.Stream(arkClient.ArkV1(), f.Namespace(), o.Name, v1.DownloadTargetKindBackupContents, backupDest, o.Timeout)
|
||||
err = downloadrequest.Stream(veleroClient.VeleroV1(), f.Namespace(), o.Name, v1.DownloadTargetKindBackupContents, backupDest, o.Timeout)
|
||||
if err != nil {
|
||||
os.Remove(o.Output)
|
||||
cmd.CheckError(err)
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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/output"
|
||||
)
|
||||
|
||||
func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -36,19 +36,19 @@ func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
err := output.ValidateFlags(c)
|
||||
cmd.CheckError(err)
|
||||
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
var backups *api.BackupList
|
||||
if len(args) > 0 {
|
||||
backups = new(api.BackupList)
|
||||
for _, name := range args {
|
||||
backup, err := arkClient.Ark().Backups(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
backup, err := veleroClient.VeleroV1().Backups(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
backups.Items = append(backups.Items, *backup)
|
||||
}
|
||||
} else {
|
||||
backups, err = arkClient.ArkV1().Backups(f.Namespace()).List(listOptions)
|
||||
backups, err = veleroClient.VeleroV1().Backups(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/downloadrequest"
|
||||
v1 "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/downloadrequest"
|
||||
)
|
||||
|
||||
func NewLogsCommand(f client.Factory) *cobra.Command {
|
||||
@@ -36,10 +36,10 @@ func NewLogsCommand(f client.Factory) *cobra.Command {
|
||||
Short: "Get backup logs",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
err = downloadrequest.Stream(arkClient.ArkV1(), f.Namespace(), args[0], v1.DownloadTargetKindBackupLog, os.Stdout, timeout)
|
||||
err = downloadrequest.Stream(veleroClient.VeleroV1(), f.Namespace(), args[0], v1.DownloadTargetKindBackupLog, os.Stdout, timeout)
|
||||
cmd.CheckError(err)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package backuplocation
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
@@ -24,11 +24,11 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/flag"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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"
|
||||
"github.com/heptio/velero/pkg/cmd/util/output"
|
||||
)
|
||||
|
||||
func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -70,7 +70,7 @@ func NewCreateOptions() *CreateOptions {
|
||||
func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) {
|
||||
flags.StringVar(&o.Provider, "provider", o.Provider, "name of the backup storage provider (e.g. aws, azure, gcp)")
|
||||
flags.StringVar(&o.Bucket, "bucket", o.Bucket, "name of the object storage bucket where backups should be stored")
|
||||
flags.StringVar(&o.Prefix, "prefix", o.Prefix, "prefix under which all Ark data should be stored within the bucket. Optional.")
|
||||
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")
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := client.ArkV1().BackupStorageLocations(backupStorageLocation.Namespace).Create(backupStorageLocation); err != nil {
|
||||
if _, err := client.VeleroV1().BackupStorageLocations(backupStorageLocation.Namespace).Create(backupStorageLocation); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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/output"
|
||||
)
|
||||
|
||||
func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -36,19 +36,19 @@ func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
err := output.ValidateFlags(c)
|
||||
cmd.CheckError(err)
|
||||
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
var locations *api.BackupStorageLocationList
|
||||
if len(args) > 0 {
|
||||
locations = new(api.BackupStorageLocationList)
|
||||
for _, name := range args {
|
||||
location, err := arkClient.Ark().BackupStorageLocations(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
location, err := veleroClient.VeleroV1().BackupStorageLocations(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
locations.Items = append(locations.Items, *location)
|
||||
}
|
||||
} else {
|
||||
locations, err = arkClient.ArkV1().BackupStorageLocations(f.Namespace()).List(listOptions)
|
||||
locations, err = veleroClient.VeleroV1().BackupStorageLocations(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
|
||||
+21
-21
@@ -30,18 +30,18 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/buildinfo"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/buildinfo"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
)
|
||||
|
||||
const (
|
||||
// kubectlTimeout is how long we wait in seconds for `kubectl version`
|
||||
// before killing the process
|
||||
kubectlTimeout = 5 * time.Second
|
||||
issueURL = "https://github.com/heptio/ark/issues/new"
|
||||
issueURL = "https://github.com/heptio/velero/issues/new"
|
||||
// IssueTemplate is used to generate .github/ISSUE_TEMPLATE/bug_report.md
|
||||
// as well as the initial text that's place in a new Github issue as
|
||||
// the result of running `ark bug`.
|
||||
// the result of running `velero bug`.
|
||||
IssueTemplate = `---
|
||||
name: Bug report
|
||||
about: Tell us about a problem you are experiencing
|
||||
@@ -58,11 +58,11 @@ about: Tell us about a problem you are experiencing
|
||||
**The output of the following commands will help us better understand what's going on**:
|
||||
(Pasting long output into a [GitHub gist](https://gist.github.com) or other pastebin is fine.)
|
||||
|
||||
* ` + "`kubectl logs deployment/ark -n heptio-ark`" + `
|
||||
* ` + "`ark backup describe <backupname>` or `kubectl get backup/<backupname> -n heptio-ark -o yaml`" + `
|
||||
* ` + "`ark backup logs <backupname>`" + `
|
||||
* ` + "`ark restore describe <restorename>` or `kubectl get restore/<restorename> -n heptio-ark -o yaml`" + `
|
||||
* ` + "`ark restore logs <restorename>`" + `
|
||||
* ` + "`kubectl logs deployment/velero -n velero`" + `
|
||||
* ` + "`velero backup describe <backupname>` or `kubectl get backup/<backupname> -n velero -o yaml`" + `
|
||||
* ` + "`velero backup logs <backupname>`" + `
|
||||
* ` + "`velero restore describe <restorename>` or `kubectl get restore/<restorename> -n velero -o yaml`" + `
|
||||
* ` + "`velero restore logs <restorename>`" + `
|
||||
|
||||
|
||||
**Anything else you would like to add:**
|
||||
@@ -71,7 +71,7 @@ about: Tell us about a problem you are experiencing
|
||||
|
||||
**Environment:**
|
||||
|
||||
- Ark version (use ` + "`ark version`" + `):{{.ArkVersion}} {{.GitCommit}}
|
||||
- Velero version (use ` + "`velero version`" + `):{{.VeleroVersion}} {{.GitCommit}}
|
||||
- Kubernetes version (use ` + "`kubectl version`" + `):
|
||||
{{- if .KubectlVersion}}
|
||||
` + "```" + `
|
||||
@@ -89,8 +89,8 @@ about: Tell us about a problem you are experiencing
|
||||
func NewCommand() *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "bug",
|
||||
Short: "Report an Ark bug",
|
||||
Long: "Open a browser window to report an Ark bug",
|
||||
Short: "Report a Velero bug",
|
||||
Long: "Open a browser window to report a Velero bug",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
kubectlVersion, err := getKubectlVersion()
|
||||
if err != nil {
|
||||
@@ -106,8 +106,8 @@ func NewCommand() *cobra.Command {
|
||||
return c
|
||||
}
|
||||
|
||||
type ArkBugInfo struct {
|
||||
ArkVersion string
|
||||
type VeleroBugInfo struct {
|
||||
VeleroVersion string
|
||||
GitCommit string
|
||||
RuntimeOS string
|
||||
RuntimeArch string
|
||||
@@ -158,9 +158,9 @@ func getKubectlVersion() (string, error) {
|
||||
return kubectlVersion, nil
|
||||
}
|
||||
|
||||
func newBugInfo(kubectlVersion string) *ArkBugInfo {
|
||||
return &ArkBugInfo{
|
||||
ArkVersion: buildinfo.Version,
|
||||
func newBugInfo(kubectlVersion string) *VeleroBugInfo {
|
||||
return &VeleroBugInfo{
|
||||
VeleroVersion: buildinfo.Version,
|
||||
GitCommit: buildinfo.FormattedGitSHA(),
|
||||
RuntimeOS: runtime.GOOS,
|
||||
RuntimeArch: runtime.GOARCH,
|
||||
@@ -168,8 +168,8 @@ func newBugInfo(kubectlVersion string) *ArkBugInfo {
|
||||
}
|
||||
|
||||
// renderToString renders IssueTemplate to a string using the
|
||||
// supplied *ArkBugInfo
|
||||
func renderToString(bugInfo *ArkBugInfo) (string, error) {
|
||||
// supplied *VeleroBugInfo
|
||||
func renderToString(bugInfo *VeleroBugInfo) (string, error) {
|
||||
outputTemplate, err := template.New("ghissue").Parse(IssueTemplate)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -193,10 +193,10 @@ func showIssueInBrowser(body string) error {
|
||||
if cmdExistsOnPath("xdg-open") {
|
||||
return exec.Command("xdg-open", url).Start()
|
||||
}
|
||||
return fmt.Errorf("ark can't open a browser window using the command '%s'", "xdg-open")
|
||||
return fmt.Errorf("velero can't open a browser window using the command '%s'", "xdg-open")
|
||||
case "windows":
|
||||
return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
|
||||
default:
|
||||
return fmt.Errorf("ark can't open a browser window on platform %s", runtime.GOOS)
|
||||
return fmt.Errorf("velero can't open a browser window on platform %s", runtime.GOOS)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ package client
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/cmd/cli/client/config"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/client/config"
|
||||
)
|
||||
|
||||
func NewCommand() *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "client",
|
||||
Short: "Ark client related commands",
|
||||
Short: "Velero client related commands",
|
||||
}
|
||||
|
||||
c.AddCommand(
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
)
|
||||
|
||||
func NewGetCommand() *cobra.Command {
|
||||
|
||||
@@ -23,8 +23,8 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
)
|
||||
|
||||
func NewSetCommand() *cobra.Command {
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
kubectlcmd "github.com/heptio/ark/third_party/kubernetes/pkg/kubectl/cmd"
|
||||
kubectlcmd "github.com/heptio/velero/third_party/kubernetes/pkg/kubectl/cmd"
|
||||
)
|
||||
|
||||
func NewCommand() *cobra.Command {
|
||||
@@ -33,11 +33,11 @@ func NewCommand() *cobra.Command {
|
||||
|
||||
Auto completion supports both bash and zsh. Output is to STDOUT.
|
||||
|
||||
Load the ark completion code for bash into the current shell -
|
||||
source <(ark completion bash)
|
||||
Load the velero completion code for bash into the current shell -
|
||||
source <(velero completion bash)
|
||||
|
||||
Load the ark completion code for zsh into the current shell -
|
||||
source <(ark completion zsh)
|
||||
Load the velero completion code for zsh into the current shell -
|
||||
source <(velero completion zsh)
|
||||
`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
ValidArgs: []string{"bash", "zsh"},
|
||||
|
||||
@@ -19,18 +19,18 @@ package create
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/backuplocation"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/restore"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/schedule"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/backuplocation"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/restore"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/schedule"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "create",
|
||||
Short: "Create ark resources",
|
||||
Long: "Create ark resources",
|
||||
Short: "Create velero resources",
|
||||
Long: "Create velero resources",
|
||||
}
|
||||
|
||||
c.AddCommand(
|
||||
|
||||
@@ -19,17 +19,17 @@ package delete
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/restore"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/schedule"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/restore"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/schedule"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "Delete ark resources",
|
||||
Long: "Delete ark resources",
|
||||
Short: "Delete velero resources",
|
||||
Long: "Delete velero resources",
|
||||
}
|
||||
|
||||
backupCommand := backup.NewDeleteCommand(f, "backup")
|
||||
|
||||
@@ -26,9 +26,9 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd/util/flag"
|
||||
clientset "github.com/heptio/ark/pkg/generated/clientset/versioned"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd/util/flag"
|
||||
clientset "github.com/heptio/velero/pkg/generated/clientset/versioned"
|
||||
)
|
||||
|
||||
// DeleteOptions contains parameters used for deleting a restore.
|
||||
@@ -63,7 +63,7 @@ func (o *DeleteOptions) Complete(f client.Factory, args []string) error {
|
||||
// Validate validates the fields of the DeleteOptions struct.
|
||||
func (o *DeleteOptions) Validate(c *cobra.Command, f client.Factory, args []string) error {
|
||||
if o.Client == nil {
|
||||
return errors.New("Ark client is not set; unable to proceed")
|
||||
return errors.New("Velero client is not set; unable to proceed")
|
||||
}
|
||||
var (
|
||||
hasNames = len(o.Names) > 0
|
||||
|
||||
@@ -19,17 +19,17 @@ package describe
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/restore"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/schedule"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/restore"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/schedule"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "describe",
|
||||
Short: "Describe ark resources",
|
||||
Long: "Describe ark resources",
|
||||
Short: "Describe velero resources",
|
||||
Long: "Describe velero resources",
|
||||
}
|
||||
|
||||
backupCommand := backup.NewDescribeCommand(f, "backups")
|
||||
|
||||
@@ -19,19 +19,19 @@ package get
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/backuplocation"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/restore"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/schedule"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/snapshotlocation"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/backuplocation"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/restore"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/schedule"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/snapshotlocation"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "get",
|
||||
Short: "Get ark resources",
|
||||
Long: "Get ark resources",
|
||||
Short: "Get velero resources",
|
||||
Long: "Get velero resources",
|
||||
}
|
||||
|
||||
backupCommand := backup.NewGetCommand(f, "backups")
|
||||
|
||||
+15
-15
@@ -28,15 +28,15 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/flag"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/cmd/util/flag"
|
||||
)
|
||||
|
||||
const (
|
||||
pluginsVolumeName = "plugins"
|
||||
arkDeployment = "ark"
|
||||
arkContainer = "ark"
|
||||
veleroDeployment = "velero"
|
||||
veleroContainer = "velero"
|
||||
)
|
||||
|
||||
func NewAddCommand(f client.Factory) *cobra.Command {
|
||||
@@ -55,17 +55,17 @@ func NewAddCommand(f client.Factory) *cobra.Command {
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
arkDeploy, err := kubeClient.AppsV1beta1().Deployments(f.Namespace()).Get(arkDeployment, metav1.GetOptions{})
|
||||
veleroDeploy, err := kubeClient.AppsV1beta1().Deployments(f.Namespace()).Get(veleroDeployment, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
original, err := json.Marshal(arkDeploy)
|
||||
original, err := json.Marshal(veleroDeploy)
|
||||
cmd.CheckError(err)
|
||||
|
||||
// ensure the plugins volume & mount exist
|
||||
volumeExists := false
|
||||
for _, volume := range arkDeploy.Spec.Template.Spec.Volumes {
|
||||
for _, volume := range veleroDeploy.Spec.Template.Spec.Volumes {
|
||||
if volume.Name == pluginsVolumeName {
|
||||
volumeExists = true
|
||||
break
|
||||
@@ -85,19 +85,19 @@ func NewAddCommand(f client.Factory) *cobra.Command {
|
||||
MountPath: "/plugins",
|
||||
}
|
||||
|
||||
arkDeploy.Spec.Template.Spec.Volumes = append(arkDeploy.Spec.Template.Spec.Volumes, volume)
|
||||
veleroDeploy.Spec.Template.Spec.Volumes = append(veleroDeploy.Spec.Template.Spec.Volumes, volume)
|
||||
|
||||
containers := arkDeploy.Spec.Template.Spec.Containers
|
||||
containers := veleroDeploy.Spec.Template.Spec.Containers
|
||||
containerIndex := -1
|
||||
for x, container := range containers {
|
||||
if container.Name == arkContainer {
|
||||
if container.Name == veleroContainer {
|
||||
containerIndex = x
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if containerIndex < 0 {
|
||||
cmd.CheckError(errors.New("ark container not found in ark deployment"))
|
||||
cmd.CheckError(errors.New("velero container not found in velero deployment"))
|
||||
}
|
||||
|
||||
containers[containerIndex].VolumeMounts = append(containers[containerIndex].VolumeMounts, volumeMount)
|
||||
@@ -116,16 +116,16 @@ func NewAddCommand(f client.Factory) *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
arkDeploy.Spec.Template.Spec.InitContainers = append(arkDeploy.Spec.Template.Spec.InitContainers, plugin)
|
||||
veleroDeploy.Spec.Template.Spec.InitContainers = append(veleroDeploy.Spec.Template.Spec.InitContainers, plugin)
|
||||
|
||||
// create & apply the patch
|
||||
updated, err := json.Marshal(arkDeploy)
|
||||
updated, err := json.Marshal(veleroDeploy)
|
||||
cmd.CheckError(err)
|
||||
|
||||
patchBytes, err := jsonpatch.CreateMergePatch(original, updated)
|
||||
cmd.CheckError(err)
|
||||
|
||||
_, err = kubeClient.AppsV1beta1().Deployments(arkDeploy.Namespace).Patch(arkDeploy.Name, types.MergePatchType, patchBytes)
|
||||
_, err = kubeClient.AppsV1beta1().Deployments(veleroDeploy.Namespace).Patch(veleroDeploy.Name, types.MergePatchType, patchBytes)
|
||||
cmd.CheckError(err)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package plugin
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
)
|
||||
|
||||
func NewRemoveCommand(f client.Factory) *cobra.Command {
|
||||
@@ -40,16 +40,16 @@ func NewRemoveCommand(f client.Factory) *cobra.Command {
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
arkDeploy, err := kubeClient.AppsV1beta1().Deployments(f.Namespace()).Get(arkDeployment, metav1.GetOptions{})
|
||||
veleroDeploy, err := kubeClient.AppsV1beta1().Deployments(f.Namespace()).Get(veleroDeployment, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
original, err := json.Marshal(arkDeploy)
|
||||
original, err := json.Marshal(veleroDeploy)
|
||||
cmd.CheckError(err)
|
||||
|
||||
var (
|
||||
initContainers = arkDeploy.Spec.Template.Spec.InitContainers
|
||||
initContainers = veleroDeploy.Spec.Template.Spec.InitContainers
|
||||
index = -1
|
||||
)
|
||||
|
||||
@@ -61,18 +61,18 @@ func NewRemoveCommand(f client.Factory) *cobra.Command {
|
||||
}
|
||||
|
||||
if index == -1 {
|
||||
cmd.CheckError(errors.Errorf("init container %s not found in Ark server deployment", args[0]))
|
||||
cmd.CheckError(errors.Errorf("init container %s not found in Velero server deployment", args[0]))
|
||||
}
|
||||
|
||||
arkDeploy.Spec.Template.Spec.InitContainers = append(initContainers[0:index], initContainers[index+1:]...)
|
||||
veleroDeploy.Spec.Template.Spec.InitContainers = append(initContainers[0:index], initContainers[index+1:]...)
|
||||
|
||||
updated, err := json.Marshal(arkDeploy)
|
||||
updated, err := json.Marshal(veleroDeploy)
|
||||
cmd.CheckError(err)
|
||||
|
||||
patchBytes, err := jsonpatch.CreateMergePatch(original, updated)
|
||||
cmd.CheckError(err)
|
||||
|
||||
_, err = kubeClient.AppsV1beta1().Deployments(arkDeploy.Namespace).Patch(arkDeploy.Name, types.MergePatchType, patchBytes)
|
||||
_, err = kubeClient.AppsV1beta1().Deployments(veleroDeploy.Namespace).Patch(veleroDeploy.Name, types.MergePatchType, patchBytes)
|
||||
cmd.CheckError(err)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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/output"
|
||||
)
|
||||
|
||||
func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -36,19 +36,19 @@ func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
err := output.ValidateFlags(c)
|
||||
cmd.CheckError(err)
|
||||
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
var repos *api.ResticRepositoryList
|
||||
if len(args) > 0 {
|
||||
repos = new(api.ResticRepositoryList)
|
||||
for _, name := range args {
|
||||
repo, err := arkClient.Ark().ResticRepositories(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
repo, err := veleroClient.VeleroV1().ResticRepositories(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
repos.Items = append(repos.Items, *repo)
|
||||
}
|
||||
} else {
|
||||
repos, err = arkClient.ArkV1().ResticRepositories(f.Namespace()).List(listOptions)
|
||||
repos, err = veleroClient.VeleroV1().ResticRepositories(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package repo
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
)
|
||||
|
||||
func NewRepositoryCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
@@ -19,8 +19,8 @@ package restic
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/restic/repo"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd/cli/restic/repo"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
@@ -31,15 +31,15 @@ import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/heptio/ark/pkg/buildinfo"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/signals"
|
||||
"github.com/heptio/ark/pkg/controller"
|
||||
clientset "github.com/heptio/ark/pkg/generated/clientset/versioned"
|
||||
informers "github.com/heptio/ark/pkg/generated/informers/externalversions"
|
||||
"github.com/heptio/ark/pkg/restic"
|
||||
"github.com/heptio/ark/pkg/util/logging"
|
||||
"github.com/heptio/velero/pkg/buildinfo"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/cmd/util/signals"
|
||||
"github.com/heptio/velero/pkg/controller"
|
||||
clientset "github.com/heptio/velero/pkg/generated/clientset/versioned"
|
||||
informers "github.com/heptio/velero/pkg/generated/informers/externalversions"
|
||||
"github.com/heptio/velero/pkg/restic"
|
||||
"github.com/heptio/velero/pkg/util/logging"
|
||||
)
|
||||
|
||||
func NewServerCommand(f client.Factory) *cobra.Command {
|
||||
@@ -47,14 +47,14 @@ func NewServerCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
command := &cobra.Command{
|
||||
Use: "server",
|
||||
Short: "Run the ark restic server",
|
||||
Long: "Run the ark restic server",
|
||||
Short: "Run the velero restic server",
|
||||
Long: "Run the velero restic server",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
logLevel := logLevelFlag.Parse()
|
||||
logrus.Infof("Setting log-level to %s", strings.ToUpper(logLevel.String()))
|
||||
|
||||
logger := logging.DefaultLogger(logLevel)
|
||||
logger.Infof("Starting Ark restic server %s", buildinfo.FormattedGitSHA())
|
||||
logger.Infof("Starting Velero restic server %s", buildinfo.FormattedGitSHA())
|
||||
|
||||
s, err := newResticServer(logger, fmt.Sprintf("%s-%s", c.Parent().Name(), c.Name()))
|
||||
cmd.CheckError(err)
|
||||
@@ -69,15 +69,15 @@ func NewServerCommand(f client.Factory) *cobra.Command {
|
||||
}
|
||||
|
||||
type resticServer struct {
|
||||
kubeClient kubernetes.Interface
|
||||
arkClient clientset.Interface
|
||||
arkInformerFactory informers.SharedInformerFactory
|
||||
kubeInformerFactory kubeinformers.SharedInformerFactory
|
||||
podInformer cache.SharedIndexInformer
|
||||
secretInformer cache.SharedIndexInformer
|
||||
logger logrus.FieldLogger
|
||||
ctx context.Context
|
||||
cancelFunc context.CancelFunc
|
||||
kubeClient kubernetes.Interface
|
||||
veleroClient clientset.Interface
|
||||
veleroInformerFactory informers.SharedInformerFactory
|
||||
kubeInformerFactory kubeinformers.SharedInformerFactory
|
||||
podInformer cache.SharedIndexInformer
|
||||
secretInformer cache.SharedIndexInformer
|
||||
logger logrus.FieldLogger
|
||||
ctx context.Context
|
||||
cancelFunc context.CancelFunc
|
||||
}
|
||||
|
||||
func newResticServer(logger logrus.FieldLogger, baseName string) (*resticServer, error) {
|
||||
@@ -91,7 +91,7 @@ func newResticServer(logger logrus.FieldLogger, baseName string) (*resticServer,
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
arkClient, err := clientset.NewForConfig(clientConfig)
|
||||
veleroClient, err := clientset.NewForConfig(clientConfig)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
@@ -109,14 +109,14 @@ func newResticServer(logger logrus.FieldLogger, baseName string) (*resticServer,
|
||||
)
|
||||
|
||||
// use a stand-alone secrets informer so we can filter to only the restic credentials
|
||||
// secret(s) within the heptio-ark namespace
|
||||
// secret(s) within the velero namespace
|
||||
//
|
||||
// note: using an informer to access the single secret for all ark-managed
|
||||
// note: using an informer to access the single secret for all velero-managed
|
||||
// restic repositories is overkill for now, but will be useful when we move
|
||||
// to fully-encrypted backups and have unique keys per repository.
|
||||
secretInformer := corev1informers.NewFilteredSecretInformer(
|
||||
kubeClient,
|
||||
os.Getenv("HEPTIO_ARK_NAMESPACE"),
|
||||
os.Getenv("VELERO_NAMESPACE"),
|
||||
0,
|
||||
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
||||
func(opts *metav1.ListOptions) {
|
||||
@@ -127,15 +127,15 @@ func newResticServer(logger logrus.FieldLogger, baseName string) (*resticServer,
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
|
||||
return &resticServer{
|
||||
kubeClient: kubeClient,
|
||||
arkClient: arkClient,
|
||||
arkInformerFactory: informers.NewFilteredSharedInformerFactory(arkClient, 0, os.Getenv("HEPTIO_ARK_NAMESPACE"), nil),
|
||||
kubeInformerFactory: kubeinformers.NewSharedInformerFactory(kubeClient, 0),
|
||||
podInformer: podInformer,
|
||||
secretInformer: secretInformer,
|
||||
logger: logger,
|
||||
ctx: ctx,
|
||||
cancelFunc: cancelFunc,
|
||||
kubeClient: kubeClient,
|
||||
veleroClient: veleroClient,
|
||||
veleroInformerFactory: informers.NewFilteredSharedInformerFactory(veleroClient, 0, os.Getenv("VELERO_NAMESPACE"), nil),
|
||||
kubeInformerFactory: kubeinformers.NewSharedInformerFactory(kubeClient, 0),
|
||||
podInformer: podInformer,
|
||||
secretInformer: secretInformer,
|
||||
logger: logger,
|
||||
ctx: ctx,
|
||||
cancelFunc: cancelFunc,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -148,12 +148,12 @@ func (s *resticServer) run() {
|
||||
|
||||
backupController := controller.NewPodVolumeBackupController(
|
||||
s.logger,
|
||||
s.arkInformerFactory.Ark().V1().PodVolumeBackups(),
|
||||
s.arkClient.ArkV1(),
|
||||
s.veleroInformerFactory.Velero().V1().PodVolumeBackups(),
|
||||
s.veleroClient.VeleroV1(),
|
||||
s.podInformer,
|
||||
s.secretInformer,
|
||||
s.kubeInformerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
s.arkInformerFactory.Ark().V1().BackupStorageLocations(),
|
||||
s.veleroInformerFactory.Velero().V1().BackupStorageLocations(),
|
||||
os.Getenv("NODE_NAME"),
|
||||
)
|
||||
wg.Add(1)
|
||||
@@ -164,12 +164,12 @@ func (s *resticServer) run() {
|
||||
|
||||
restoreController := controller.NewPodVolumeRestoreController(
|
||||
s.logger,
|
||||
s.arkInformerFactory.Ark().V1().PodVolumeRestores(),
|
||||
s.arkClient.ArkV1(),
|
||||
s.veleroInformerFactory.Velero().V1().PodVolumeRestores(),
|
||||
s.veleroClient.VeleroV1(),
|
||||
s.podInformer,
|
||||
s.secretInformer,
|
||||
s.kubeInformerFactory.Core().V1().PersistentVolumeClaims(),
|
||||
s.arkInformerFactory.Ark().V1().BackupStorageLocations(),
|
||||
s.veleroInformerFactory.Velero().V1().BackupStorageLocations(),
|
||||
os.Getenv("NODE_NAME"),
|
||||
)
|
||||
wg.Add(1)
|
||||
@@ -178,7 +178,7 @@ func (s *resticServer) run() {
|
||||
restoreController.Run(s.ctx, 1)
|
||||
}()
|
||||
|
||||
go s.arkInformerFactory.Start(s.ctx.Done())
|
||||
go s.veleroInformerFactory.Start(s.ctx.Done())
|
||||
go s.kubeInformerFactory.Start(s.ctx.Done())
|
||||
go s.podInformer.Run(s.ctx.Done())
|
||||
go s.secretInformer.Run(s.ctx.Done())
|
||||
|
||||
@@ -26,13 +26,13 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/flag"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
arkclient "github.com/heptio/ark/pkg/generated/clientset/versioned"
|
||||
"github.com/heptio/ark/pkg/generated/informers/externalversions/ark/v1"
|
||||
api "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"
|
||||
"github.com/heptio/velero/pkg/cmd/util/output"
|
||||
veleroclient "github.com/heptio/velero/pkg/generated/clientset/versioned"
|
||||
v1 "github.com/heptio/velero/pkg/generated/informers/externalversions/velero/v1"
|
||||
)
|
||||
|
||||
func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -42,13 +42,13 @@ func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||
Use: use + " [RESTORE_NAME] [--from-backup BACKUP_NAME | --from-schedule SCHEDULE_NAME]",
|
||||
Short: "Create a restore",
|
||||
Example: ` # create a restore named "restore-1" from backup "backup-1"
|
||||
ark restore create restore-1 --from-backup backup-1
|
||||
velero restore create restore-1 --from-backup backup-1
|
||||
|
||||
# create a restore with a default name ("backup-1-<timestamp>") from backup "backup-1"
|
||||
ark restore create --from-backup backup-1
|
||||
velero restore create --from-backup backup-1
|
||||
|
||||
# create a restore from the latest successful backup triggered by schedule "schedule-1"
|
||||
ark restore create --from-schedule schedule-1
|
||||
velero restore create --from-schedule schedule-1
|
||||
`,
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
@@ -80,7 +80,7 @@ type CreateOptions struct {
|
||||
IncludeClusterResources flag.OptionalBool
|
||||
Wait bool
|
||||
|
||||
client arkclient.Interface
|
||||
client veleroclient.Interface
|
||||
}
|
||||
|
||||
func NewCreateOptions() *CreateOptions {
|
||||
@@ -150,16 +150,16 @@ func (o *CreateOptions) Validate(c *cobra.Command, args []string, f client.Facto
|
||||
|
||||
if o.client == nil {
|
||||
// This should never happen
|
||||
return errors.New("Ark client is not set; unable to proceed")
|
||||
return errors.New("Velero client is not set; unable to proceed")
|
||||
}
|
||||
|
||||
switch {
|
||||
case o.BackupName != "":
|
||||
if _, err := o.client.ArkV1().Backups(f.Namespace()).Get(o.BackupName, metav1.GetOptions{}); err != nil {
|
||||
if _, err := o.client.VeleroV1().Backups(f.Namespace()).Get(o.BackupName, metav1.GetOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
case o.ScheduleName != "":
|
||||
if _, err := o.client.ArkV1().Schedules(f.Namespace()).Get(o.ScheduleName, metav1.GetOptions{}); err != nil {
|
||||
if _, err := o.client.VeleroV1().Schedules(f.Namespace()).Get(o.ScheduleName, metav1.GetOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ func (o *CreateOptions) Validate(c *cobra.Command, args []string, f client.Facto
|
||||
func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
if o.client == nil {
|
||||
// This should never happen
|
||||
return errors.New("Ark client is not set; unable to proceed")
|
||||
return errors.New("Velero client is not set; unable to proceed")
|
||||
}
|
||||
|
||||
restore := &api.Restore{
|
||||
@@ -237,7 +237,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
go restoreInformer.Run(stop)
|
||||
}
|
||||
|
||||
restore, err := o.client.ArkV1().Restores(restore.Namespace).Create(restore)
|
||||
restore, err := o.client.VeleroV1().Restores(restore.Namespace).Create(restore)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -259,7 +259,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
}
|
||||
|
||||
if restore.Status.Phase != api.RestorePhaseNew && restore.Status.Phase != api.RestorePhaseInProgress {
|
||||
fmt.Printf("\nRestore completed with status: %s. You may check for more information using the commands `ark restore describe %s` and `ark restore logs %s`.\n", restore.Status.Phase, restore.Name, restore.Name)
|
||||
fmt.Printf("\nRestore completed with status: %s. You may check for more information using the commands `velero restore describe %s` and `velero restore logs %s`.\n", restore.Status.Phase, restore.Name, restore.Name)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
|
||||
// Not waiting
|
||||
|
||||
fmt.Printf("Run `ark restore describe %s` or `ark restore logs %s` for more details.\n", restore.Name, restore.Name)
|
||||
fmt.Printf("Run `velero restore describe %s` or `velero restore logs %s` for more details.\n", restore.Name, restore.Name)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ import (
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
kubeerrs "k8s.io/apimachinery/pkg/util/errors"
|
||||
|
||||
arkv1api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/cli"
|
||||
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/cli"
|
||||
)
|
||||
|
||||
// NewDeleteCommand creates and returns a new cobra command for deleting restores.
|
||||
@@ -39,19 +39,19 @@ func NewDeleteCommand(f client.Factory, use string) *cobra.Command {
|
||||
Use: fmt.Sprintf("%s [NAMES]", use),
|
||||
Short: "Delete restores",
|
||||
Example: ` # delete a restore named "restore-1"
|
||||
ark restore delete restore-1
|
||||
velero restore delete restore-1
|
||||
|
||||
# delete a restore named "restore-1" without prompting for confirmation
|
||||
ark restore delete restore-1 --confirm
|
||||
velero restore delete restore-1 --confirm
|
||||
|
||||
# delete restores named "restore-1" and "restore-2"
|
||||
ark restore delete restore-1 restore-2
|
||||
velero restore delete restore-1 restore-2
|
||||
|
||||
# delete all restores labelled with foo=bar"
|
||||
ark restore delete --selector foo=bar
|
||||
velero restore delete --selector foo=bar
|
||||
|
||||
# delete all restores
|
||||
ark restore delete --all`,
|
||||
velero restore delete --all`,
|
||||
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
cmd.CheckError(o.Complete(f, args))
|
||||
@@ -70,14 +70,14 @@ func Run(o *cli.DeleteOptions) error {
|
||||
return nil
|
||||
}
|
||||
var (
|
||||
restores []*arkv1api.Restore
|
||||
restores []*velerov1api.Restore
|
||||
errs []error
|
||||
)
|
||||
|
||||
switch {
|
||||
case len(o.Names) > 0:
|
||||
for _, name := range o.Names {
|
||||
restore, err := o.Client.ArkV1().Restores(o.Namespace).Get(name, metav1.GetOptions{})
|
||||
restore, err := o.Client.VeleroV1().Restores(o.Namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
errs = append(errs, errors.WithStack(err))
|
||||
continue
|
||||
@@ -89,7 +89,7 @@ func Run(o *cli.DeleteOptions) error {
|
||||
if o.Selector.LabelSelector != nil {
|
||||
selector = o.Selector.String()
|
||||
}
|
||||
res, err := o.Client.ArkV1().Restores(o.Namespace).List(metav1.ListOptions{
|
||||
res, err := o.Client.VeleroV1().Restores(o.Namespace).List(metav1.ListOptions{
|
||||
LabelSelector: selector,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -105,7 +105,7 @@ func Run(o *cli.DeleteOptions) error {
|
||||
return nil
|
||||
}
|
||||
for _, r := range restores {
|
||||
err := o.Client.ArkV1().Restores(r.Namespace).Delete(r.Name, nil)
|
||||
err := o.Client.VeleroV1().Restores(r.Namespace).Delete(r.Name, nil)
|
||||
if err != nil {
|
||||
errs = append(errs, errors.WithStack(err))
|
||||
continue
|
||||
|
||||
@@ -23,11 +23,11 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
"github.com/heptio/ark/pkg/restic"
|
||||
api "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/output"
|
||||
"github.com/heptio/velero/pkg/restic"
|
||||
)
|
||||
|
||||
func NewDescribeCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -40,31 +40,31 @@ func NewDescribeCommand(f client.Factory, use string) *cobra.Command {
|
||||
Use: use + " [NAME1] [NAME2] [NAME...]",
|
||||
Short: "Describe restores",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
var restores *api.RestoreList
|
||||
if len(args) > 0 {
|
||||
restores = new(api.RestoreList)
|
||||
for _, name := range args {
|
||||
restore, err := arkClient.Ark().Restores(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
restore, err := veleroClient.VeleroV1().Restores(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
restores.Items = append(restores.Items, *restore)
|
||||
}
|
||||
} else {
|
||||
restores, err = arkClient.ArkV1().Restores(f.Namespace()).List(listOptions)
|
||||
restores, err = veleroClient.VeleroV1().Restores(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
first := true
|
||||
for _, restore := range restores.Items {
|
||||
opts := restic.NewPodVolumeRestoreListOptions(restore.Name, string(restore.UID))
|
||||
podvolumeRestoreList, err := arkClient.ArkV1().PodVolumeRestores(f.Namespace()).List(opts)
|
||||
opts := restic.NewPodVolumeRestoreListOptions(restore.Name)
|
||||
podvolumeRestoreList, err := veleroClient.VeleroV1().PodVolumeRestores(f.Namespace()).List(opts)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error getting PodVolumeRestores for restore %s: %v\n", restore.Name, err)
|
||||
}
|
||||
|
||||
s := output.DescribeRestore(&restore, podvolumeRestoreList.Items, details, arkClient)
|
||||
s := output.DescribeRestore(&restore, podvolumeRestoreList.Items, details, veleroClient)
|
||||
if first {
|
||||
first = false
|
||||
fmt.Print(s)
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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/output"
|
||||
)
|
||||
|
||||
func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -36,19 +36,19 @@ func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
err := output.ValidateFlags(c)
|
||||
cmd.CheckError(err)
|
||||
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
var restores *api.RestoreList
|
||||
if len(args) > 0 {
|
||||
restores = new(api.RestoreList)
|
||||
for _, name := range args {
|
||||
restore, err := arkClient.Ark().Restores(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
restore, err := veleroClient.VeleroV1().Restores(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
restores.Items = append(restores.Items, *restore)
|
||||
}
|
||||
} else {
|
||||
restores, err = arkClient.ArkV1().Restores(f.Namespace()).List(listOptions)
|
||||
restores, err = veleroClient.VeleroV1().Restores(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/downloadrequest"
|
||||
arkclient "github.com/heptio/ark/pkg/generated/clientset/versioned"
|
||||
v1 "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/downloadrequest"
|
||||
veleroclient "github.com/heptio/velero/pkg/generated/clientset/versioned"
|
||||
)
|
||||
|
||||
func NewLogsCommand(f client.Factory) *cobra.Command {
|
||||
@@ -42,9 +42,9 @@ func NewLogsCommand(f client.Factory) *cobra.Command {
|
||||
l := NewLogsOptions()
|
||||
cmd.CheckError(l.Complete(args))
|
||||
cmd.CheckError(l.Validate(f))
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
err = downloadrequest.Stream(arkClient.ArkV1(), f.Namespace(), args[0], v1.DownloadTargetKindRestoreLog, os.Stdout, timeout)
|
||||
err = downloadrequest.Stream(veleroClient.VeleroV1(), f.Namespace(), args[0], v1.DownloadTargetKindRestoreLog, os.Stdout, timeout)
|
||||
cmd.CheckError(err)
|
||||
},
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func NewLogsCommand(f client.Factory) *cobra.Command {
|
||||
type LogsOptions struct {
|
||||
RestoreName string
|
||||
|
||||
client arkclient.Interface
|
||||
client veleroclient.Interface
|
||||
}
|
||||
|
||||
// NewLogsOptions returns a new instance of LogsOptions
|
||||
@@ -82,7 +82,7 @@ func (l *LogsOptions) Validate(f client.Factory) error {
|
||||
}
|
||||
l.client = c
|
||||
|
||||
r, err := l.client.ArkV1().Restores(f.Namespace()).Get(l.RestoreName, metav1.GetOptions{})
|
||||
r, err := l.client.VeleroV1().Restores(f.Namespace()).Get(l.RestoreName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package restore
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
@@ -24,11 +24,11 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/cli/backup"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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/cli/backup"
|
||||
"github.com/heptio/velero/pkg/cmd/util/output"
|
||||
)
|
||||
|
||||
func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -47,7 +47,7 @@ func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||
| 4 | Month | 1-12,* |
|
||||
| 5 | Day of Week | 0-7,* |`,
|
||||
|
||||
Example: `ark create schedule NAME --schedule="0 */6 * * *"`,
|
||||
Example: `velero create schedule NAME --schedule="0 */6 * * *"`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
cmd.CheckError(o.Complete(args, f))
|
||||
@@ -94,7 +94,7 @@ func (o *CreateOptions) Complete(args []string, f client.Factory) error {
|
||||
}
|
||||
|
||||
func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = arkClient.ArkV1().Schedules(schedule.Namespace).Create(schedule)
|
||||
_, err = veleroClient.VeleroV1().Schedules(schedule.Namespace).Create(schedule)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ import (
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
kubeerrs "k8s.io/apimachinery/pkg/util/errors"
|
||||
|
||||
arkv1api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/cli"
|
||||
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/cli"
|
||||
)
|
||||
|
||||
// NewDeleteCommand creates and returns a new cobra command for deleting schedules.
|
||||
@@ -39,19 +39,19 @@ func NewDeleteCommand(f client.Factory, use string) *cobra.Command {
|
||||
Use: fmt.Sprintf("%s [NAMES]", use),
|
||||
Short: "Delete schedules",
|
||||
Example: ` # delete a schedule named "schedule-1"
|
||||
ark schedule delete schedule-1
|
||||
velero schedule delete schedule-1
|
||||
|
||||
# delete a schedule named "schedule-1" without prompting for confirmation
|
||||
ark schedule delete schedule-1 --confirm
|
||||
velero schedule delete schedule-1 --confirm
|
||||
|
||||
# delete schedules named "schedule-1" and "schedule-2"
|
||||
ark schedule delete schedule-1 schedule-2
|
||||
velero schedule delete schedule-1 schedule-2
|
||||
|
||||
# delete all schedules labelled with foo=bar"
|
||||
ark schedule delete --selector foo=bar
|
||||
velero schedule delete --selector foo=bar
|
||||
|
||||
# delete all schedules
|
||||
ark schedule delete --all`,
|
||||
velero schedule delete --all`,
|
||||
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
cmd.CheckError(o.Complete(f, args))
|
||||
@@ -70,13 +70,13 @@ func Run(o *cli.DeleteOptions) error {
|
||||
return nil
|
||||
}
|
||||
var (
|
||||
schedules []*arkv1api.Schedule
|
||||
schedules []*velerov1api.Schedule
|
||||
errs []error
|
||||
)
|
||||
switch {
|
||||
case len(o.Names) > 0:
|
||||
for _, name := range o.Names {
|
||||
schedule, err := o.Client.ArkV1().Schedules(o.Namespace).Get(name, metav1.GetOptions{})
|
||||
schedule, err := o.Client.VeleroV1().Schedules(o.Namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
errs = append(errs, errors.WithStack(err))
|
||||
continue
|
||||
@@ -88,7 +88,7 @@ func Run(o *cli.DeleteOptions) error {
|
||||
if o.Selector.LabelSelector != nil {
|
||||
selector = o.Selector.String()
|
||||
}
|
||||
res, err := o.Client.ArkV1().Schedules(o.Namespace).List(metav1.ListOptions{
|
||||
res, err := o.Client.VeleroV1().Schedules(o.Namespace).List(metav1.ListOptions{
|
||||
LabelSelector: selector,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -105,7 +105,7 @@ func Run(o *cli.DeleteOptions) error {
|
||||
}
|
||||
|
||||
for _, s := range schedules {
|
||||
err := o.Client.ArkV1().Schedules(s.Namespace).Delete(s.Name, nil)
|
||||
err := o.Client.VeleroV1().Schedules(s.Namespace).Delete(s.Name, nil)
|
||||
if err != nil {
|
||||
errs = append(errs, errors.WithStack(err))
|
||||
continue
|
||||
|
||||
@@ -22,10 +22,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
v1 "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/output"
|
||||
)
|
||||
|
||||
func NewDescribeCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -35,19 +35,19 @@ func NewDescribeCommand(f client.Factory, use string) *cobra.Command {
|
||||
Use: use + " [NAME1] [NAME2] [NAME...]",
|
||||
Short: "Describe schedules",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
var schedules *v1.ScheduleList
|
||||
if len(args) > 0 {
|
||||
schedules = new(v1.ScheduleList)
|
||||
for _, name := range args {
|
||||
schedule, err := arkClient.Ark().Schedules(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
schedule, err := veleroClient.VeleroV1().Schedules(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
schedules.Items = append(schedules.Items, *schedule)
|
||||
}
|
||||
} else {
|
||||
schedules, err = arkClient.ArkV1().Schedules(f.Namespace()).List(listOptions)
|
||||
schedules, err = veleroClient.VeleroV1().Schedules(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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/output"
|
||||
)
|
||||
|
||||
func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -36,19 +36,19 @@ func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
err := output.ValidateFlags(c)
|
||||
cmd.CheckError(err)
|
||||
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
|
||||
var schedules *api.ScheduleList
|
||||
if len(args) > 0 {
|
||||
schedules = new(api.ScheduleList)
|
||||
for _, name := range args {
|
||||
schedule, err := arkClient.Ark().Schedules(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
schedule, err := veleroClient.VeleroV1().Schedules(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
schedules.Items = append(schedules.Items, *schedule)
|
||||
}
|
||||
} else {
|
||||
schedules, err = arkClient.ArkV1().Schedules(f.Namespace()).List(listOptions)
|
||||
schedules, err = veleroClient.VeleroV1().Schedules(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package schedule
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
@@ -24,11 +24,11 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/flag"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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"
|
||||
"github.com/heptio/velero/pkg/cmd/util/output"
|
||||
)
|
||||
|
||||
func NewCreateCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -110,7 +110,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := client.ArkV1().VolumeSnapshotLocations(volumeSnapshotLocation.Namespace).Create(volumeSnapshotLocation); err != nil {
|
||||
if _, err := client.VeleroV1().VolumeSnapshotLocations(volumeSnapshotLocation.Namespace).Create(volumeSnapshotLocation); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/output"
|
||||
api "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/output"
|
||||
)
|
||||
|
||||
func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
@@ -34,18 +34,18 @@ func NewGetCommand(f client.Factory, use string) *cobra.Command {
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
err := output.ValidateFlags(c)
|
||||
cmd.CheckError(err)
|
||||
arkClient, err := f.Client()
|
||||
veleroClient, err := f.Client()
|
||||
cmd.CheckError(err)
|
||||
var locations *api.VolumeSnapshotLocationList
|
||||
if len(args) > 0 {
|
||||
locations = new(api.VolumeSnapshotLocationList)
|
||||
for _, name := range args {
|
||||
location, err := arkClient.Ark().VolumeSnapshotLocations(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
location, err := veleroClient.VeleroV1().VolumeSnapshotLocations(f.Namespace()).Get(name, metav1.GetOptions{})
|
||||
cmd.CheckError(err)
|
||||
locations.Items = append(locations.Items, *location)
|
||||
}
|
||||
} else {
|
||||
locations, err = arkClient.ArkV1().VolumeSnapshotLocations(f.Namespace()).List(listOptions)
|
||||
locations, err = veleroClient.VeleroV1().VolumeSnapshotLocations(f.Namespace()).List(listOptions)
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
_, err = output.PrintWithFormat(c, locations)
|
||||
|
||||
@@ -19,7 +19,7 @@ package snapshotlocation
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
Reference in New Issue
Block a user