Documentation ¶
Index ¶
- Constants
- Variables
- func SHA256Checksum(filename string) error
- func SHA256ChecksumValidate(filename, checksum string) error
- func SplitURLPath(httpURL string) (hostPart, pathPart string, err error)
- func ValidateMD5Checksum(filename, checksum string) bool
- type Downloader
- func (c *Downloader) CopyFile(ctx context.Context, fw *config.Firmware) error
- func (c *Downloader) Dst() rcloneFs.Fs
- func (c *Downloader) DstBucket() string
- func (c *Downloader) DstPath(fw *config.Firmware) string
- func (c *Downloader) DstURL() string
- func (c *Downloader) SrcName() string
- func (c *Downloader) SrcPath(fw *config.Firmware) string
- func (c *Downloader) SrcURL() string
- func (c *Downloader) Stats() *DownloaderStats
- func (c *Downloader) Tmp() rcloneFs.Fs
- func (c *Downloader) VerifyFile(ctx context.Context, fw *config.Firmware) error
- type DownloaderStats
- type LocalFsConfig
- type Metrics
- type S3Downloader
- func (s *S3Downloader) CopyFile(ctx context.Context, fw *config.Firmware) error
- func (s *S3Downloader) DstBucket() string
- func (s *S3Downloader) DstPath(fw *config.Firmware) string
- func (s *S3Downloader) SrcBucket() string
- func (s *S3Downloader) SrcPath(fw *config.Firmware) string
- func (s *S3Downloader) VerifyFile(ctx context.Context, fw *config.Firmware) error
- type Vendor
Constants ¶
const ( MetricTransferredBytes = "TransferredBytes" MetricTransferredObjects = "TransferredObjects" MetricErrorsCount = "ErrorsCount" ActionSync = "sync" ActionSign = "sign" ActionVerify = "verify" )
const (
SumSuffix = ".SHA256"
)
Variables ¶
var ( ErrChecksumGenerate = errors.New("error generate file checksum") ErrChecksumValidate = errors.New("error validating file checksum") ErrChecksumInvalid = errors.New("file checksum does not match") )
var ( ErrDestPathUndefined = errors.New("destination path is not specified") ErrCopy = errors.New("error copying files") ErrSync = errors.New("error syncing files") ErrInitS3Downloader = errors.New("error intializing s3 downloader") ErrInitHTTPDownloader = errors.New("error initializing http downloader") ErrInitFSDownloader = errors.New("error initializing filesystem downloader") ErrFileStoreConfig = errors.New("filestore configuration invalid") ErrRootDirUndefined = errors.New("expected a root directory path to mount") ErrInitS3Fs = errors.New("error initializing s3 vfs") ErrUnsupportedFileStore = errors.New("unsupported file store") ErrSourceURL = errors.New("invalid/unsupported source URL") ErrStoreConfig = errors.New("error in/invalid FileStore configuration") ErrURLUnsupported = errors.New("error URL scheme/format unsupported") ErrFileNotFound = errors.New("file not found") ErrCheckFileExists = errors.New("error checking file exists") ErrListingFiles = errors.New("error listing files in directory") ErrDirEmpty = errors.New("directory empty") ErrModTimeFile = errors.New("error retrieving file mod time") ErrCreatingTmpDir = errors.New("error creating tmp dir") )
Functions ¶
func SHA256Checksum ¶
SHA256FileChecksum calculates the sha256 checksum of the given filename and writes a filename.SHA256 file with its checksum value
func SHA256ChecksumValidate ¶
SHA256FileChecksumValidate verifies the sha256 checksum of the given filename
If a checksum parameter is provided, the method compares the file checksum with the one provided. If no checksum parameter was given, the method looks for 'filename.SHA256' to read the checksum to validate. when the checksum does not match the expected, an error is returned
func SplitURLPath ¶
SplitURLPath returns the URL host and Path parts while including the URL scheme, user info and fragments if any
func ValidateMD5Checksum ¶ added in v0.0.9
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader wraps src and dst rclone Fs interface types to enable copying objects
func NewDownloader ¶
func NewDownloader(ctx context.Context, vendor, srcURL string, dstCfg *config.S3Bucket, logger *logrus.Logger) (*Downloader, error)
NewDownloader initializes a downloader object based on the srcURL and the given dstCfg
func (*Downloader) Dst ¶ added in v0.0.9
func (c *Downloader) Dst() rcloneFs.Fs
maybe just export the fields directly
func (*Downloader) DstBucket ¶
func (c *Downloader) DstBucket() string
func (*Downloader) DstURL ¶
func (c *Downloader) DstURL() string
DstURL returns the destination URL configured when initializing the downloader
func (*Downloader) SrcName ¶
func (c *Downloader) SrcName() string
SrcName returns the name of the source fs - set in the init*Fs methods
func (*Downloader) SrcURL ¶
func (c *Downloader) SrcURL() string
SrcURL returns the destination URL configured when initializing the downloader
func (*Downloader) Stats ¶
func (c *Downloader) Stats() *DownloaderStats
Stats returns bytes, file transfer stats on the downloader
func (*Downloader) Tmp ¶ added in v0.0.9
func (c *Downloader) Tmp() rcloneFs.Fs
maybe just export the fields directly
func (*Downloader) VerifyFile ¶
type DownloaderStats ¶
DownloaderStats includes fields for stats on file/object transfer for Downloader
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics is a struct with a key value map under an RWMutex to collect file transfer metrics in a provider syncer context
func NewMetrics ¶
func NewMetrics() *Metrics
func (*Metrics) AddInt64Value ¶
AddInt64Value adds a given string key and int64 value
func (*Metrics) FromDownloader ¶
func (m *Metrics) FromDownloader(downloader *Downloader, deviceVendor, actionKind string)
FromDownloader collects metrics from the given downloader object
func (*Metrics) GetAllInt64Values ¶
GetAllInt64Values returns a map of metrics that are of type int64
type S3Downloader ¶
type S3Downloader struct {
// contains filtered or unexported fields
}
func NewS3Downloader ¶
func (*S3Downloader) CopyFile ¶
CopyFile wraps rclone CopyFile to copy firmware file from src to dst
func (*S3Downloader) DstBucket ¶
func (s *S3Downloader) DstBucket() string
func (*S3Downloader) SrcBucket ¶
func (s *S3Downloader) SrcBucket() string