vendors

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricTransferredBytes   = "TransferredBytes"
	MetricTransferredObjects = "TransferredObjects"
	MetricErrorsCount        = "ErrorsCount"
	ActionSync               = "sync"
	ActionSign               = "sign"
	ActionVerify             = "verify"
)
View Source
const (
	SumSuffix = ".SHA256"
)

Variables

View Source
var (
	ErrChecksumGenerate = errors.New("error generate file checksum")
	ErrChecksumValidate = errors.New("error validating file checksum")
	ErrChecksumInvalid  = errors.New("file checksum does not match")
)
View Source
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

func SHA256Checksum(filename string) error

SHA256FileChecksum calculates the sha256 checksum of the given filename and writes a filename.SHA256 file with its checksum value

func SHA256ChecksumValidate

func SHA256ChecksumValidate(filename, checksum string) error

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

func SplitURLPath(httpURL string) (hostPart, pathPart string, err error)

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

func ValidateMD5Checksum(filename, checksum string) bool

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) CopyFile

func (c *Downloader) CopyFile(ctx context.Context, fw *config.Firmware) error

CopyFile copies src firmware in the c.src fs to c.dst fs

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) DstPath

func (c *Downloader) DstPath(fw *config.Firmware) 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) SrcPath

func (c *Downloader) SrcPath(fw *config.Firmware) string

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

func (c *Downloader) VerifyFile(ctx context.Context, fw *config.Firmware) error

type DownloaderStats

type DownloaderStats struct {
	BytesTransferred   int64
	ObjectsTransferred int64
	Errors             int64
}

DownloaderStats includes fields for stats on file/object transfer for Downloader

type LocalFsConfig

type LocalFsConfig struct {
	Root string
}

LocalFsConfig for the 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

func (m *Metrics) AddInt64Value(key string, value int64)

AddInt64Value adds a given string key and int64 value

func (*Metrics) Clear

func (m *Metrics) Clear()

Clear purges all existing key, values

func (*Metrics) FromDownloader

func (m *Metrics) FromDownloader(downloader *Downloader, deviceVendor, actionKind string)

FromDownloader collects metrics from the given downloader object

func (*Metrics) GetAllInt64Values

func (m *Metrics) GetAllInt64Values() map[string]int64

GetAllInt64Values returns a map of metrics that are of type int64

type S3Downloader

type S3Downloader struct {
	// contains filtered or unexported fields
}

func NewS3Downloader

func NewS3Downloader(ctx context.Context, vendor string, srcCfg, dstCfg *config.S3Bucket, logger *logrus.Logger) (*S3Downloader, error)

func (*S3Downloader) CopyFile

func (s *S3Downloader) CopyFile(ctx context.Context, fw *config.Firmware) error

CopyFile wraps rclone CopyFile to copy firmware file from src to dst

func (*S3Downloader) DstBucket

func (s *S3Downloader) DstBucket() string

func (*S3Downloader) DstPath

func (s *S3Downloader) DstPath(fw *config.Firmware) string

func (*S3Downloader) SrcBucket

func (s *S3Downloader) SrcBucket() string

func (*S3Downloader) SrcPath

func (s *S3Downloader) SrcPath(fw *config.Firmware) string

func (*S3Downloader) VerifyFile

func (s *S3Downloader) VerifyFile(ctx context.Context, fw *config.Firmware) error

type Vendor

type Vendor interface {
	Sync(ctx context.Context) error
	Stats() *Metrics
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL