etcd-backup-operator/controller: add handleBackup
package controller
import (
- "fmt"
-
api "github.com/coreos/etcd-operator/pkg/apis/etcd/v1beta2"
+
+ "github.com/sirupsen/logrus"
)
const (
@@ -61,10 +61,7 @@ func (b *Backup) processItem(key string) error {
}
eb := obj.(*api.EtcdBackup)
- // Remove fmt.Println(eb) when implementing handle backup logic.
- fmt.Println(eb)
- // TODO: handle backup
- return nil
+ return b.handleBackup(&eb.Spec)
}
func (b *Backup) handleErr(err error, key interface{}) {
@@ -90,3 +87,13 @@ func (b *Backup) handleErr(err error, key interface{}) {
// Report that, even after several retries, we could not successfully process this key
b.logger.Infof("Dropping Backup (%v) out of the queue: %v", key, err)
}
+
+func (b *Backup) handleBackup(spec *api.EtcdBackupSpec) error {
+ switch spec.StorageType {
+ case api.BackupStorageTypeS3:
+ return handleS3(b.kubecli, spec.S3, b.namespace, spec.ClusterName)
+ default:
+ logrus.Fatalf("unknown StorageType: %v", spec.StorageType)
+ }
+ return nil
+}
