Support data coming from the panel better
This commit is contained in:
@@ -1,9 +1,35 @@
|
||||
package backup
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/pterodactyl/wings/api"
|
||||
)
|
||||
|
||||
const (
|
||||
LocalBackupAdapter = "local"
|
||||
S3BackupAdapter = "s3"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
Adapter string `json:"adapter"`
|
||||
Uuid string `json:"uuid"`
|
||||
IgnoredFiles []string `json:"ignored_files"`
|
||||
PresignedUrl string `json:"presigned_url"`
|
||||
}
|
||||
|
||||
// Generates a new local backup struct.
|
||||
func (r *Request) NewLocalBackup() (*LocalBackup, error) {
|
||||
if r.Adapter != LocalBackupAdapter {
|
||||
return nil, errors.New(fmt.Sprintf("cannot create local backup using [%s] adapter", r.Adapter))
|
||||
}
|
||||
|
||||
return &LocalBackup{
|
||||
Uuid: r.Uuid,
|
||||
IgnoredFiles: r.IgnoredFiles,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type Backup interface {
|
||||
// Returns the UUID of this backup as tracked by the panel instance.
|
||||
Identifier() string
|
||||
@@ -39,4 +65,4 @@ func (ad *ArchiveDetails) ToRequest(successful bool) api.BackupRequest {
|
||||
Size: ad.Size,
|
||||
Successful: successful,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user