2022-08-01 09:00:32 +00:00
/ *
2022-08-16 05:50:28 +00:00
Copyright the Velero contributors .
2022-08-01 09:00:32 +00:00
Licensed under the Apache License , Version 2.0 ( the "License" ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
2022-08-16 05:50:28 +00:00
2022-08-01 09:00:32 +00:00
http : //www.apache.org/licenses/LICENSE-2.0
2022-08-16 05:50:28 +00:00
2022-08-01 09:00:32 +00:00
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an "AS IS" BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
* /
package uploader
2022-08-16 05:50:28 +00:00
import (
"fmt"
"strings"
)
2022-08-01 09:00:32 +00:00
const (
2023-04-27 03:19:03 +00:00
ResticType = "restic"
KopiaType = "kopia"
2023-06-15 02:34:18 +00:00
SnapshotRequesterTag = "snapshot-requester"
2023-05-23 07:16:57 +00:00
SnapshotUploaderTag = "snapshot-uploader"
2022-08-01 09:00:32 +00:00
)
2023-08-02 16:26:01 +00:00
type PersistentVolumeMode string
const (
// PersistentVolumeBlock means the volume will not be formatted with a filesystem and will remain a raw block device.
PersistentVolumeBlock PersistentVolumeMode = "Block"
// PersistentVolumeFilesystem means the volume will be or is formatted with a filesystem.
PersistentVolumeFilesystem PersistentVolumeMode = "Filesystem"
)
2022-08-16 05:50:28 +00:00
// ValidateUploaderType validates if the input param is a valid uploader type.
// It will return an error if it's invalid.
2024-08-07 09:06:48 +00:00
func ValidateUploaderType ( t string ) ( string , error ) {
2022-08-16 05:50:28 +00:00
t = strings . TrimSpace ( t )
if t != ResticType && t != KopiaType {
2024-08-07 09:06:48 +00:00
return "" , fmt . Errorf ( "invalid uploader type '%s', valid upload types are: '%s', '%s'" , t , ResticType , KopiaType )
2022-08-16 05:50:28 +00:00
}
2024-08-07 09:06:48 +00:00
if t == ResticType {
return fmt . Sprintf ( "Uploader '%s' is deprecated, don't use it for new backups, otherwise the backups won't be available for restore when this functionality is removed in a future version of Velero" , t ) , nil
}
return "" , nil
2022-08-16 05:50:28 +00:00
}
2022-08-01 09:00:32 +00:00
type SnapshotInfo struct {
ID string ` json:"id" `
Size int64 ` json:"Size" `
}
2022-08-19 06:45:28 +00:00
2023-04-24 07:29:20 +00:00
// Progress which defined two variables to record progress
type Progress struct {
2022-08-19 06:45:28 +00:00
TotalBytes int64 ` json:"totalBytes,omitempty" `
BytesDone int64 ` json:"doneBytes,omitempty" `
}
2023-03-24 04:15:08 +00:00
// UploaderProgress which defined generic interface to update progress
2022-08-19 06:45:28 +00:00
type ProgressUpdater interface {
2023-04-24 07:29:20 +00:00
UpdateProgress ( p * Progress )
2022-08-19 06:45:28 +00:00
}