package storage import ( "context" "fmt" "git.misaka.ren/M1saka/docker_backup/internal/config" ) // Backend is the interface for uploading backups to remote storage. type Backend interface { Upload(ctx context.Context, projectName, localPath string) error } // FromConfig creates storage backends from the config. // Returns an error only if a backend is configured but fails to initialize. func FromConfig(cfg *config.RemoteConfig) ([]Backend, error) { var backends []Backend if cfg.S3 != nil { s3, err := NewS3Backend(cfg.S3) if err != nil { return nil, fmt.Errorf("s3: %w", err) } backends = append(backends, s3) } if cfg.WebDAV != nil { backends = append(backends, NewWebDAVBackend(cfg.WebDAV)) } return backends, nil }