provider

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: LGPL-2.1 Imports: 14 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProviderUnavaiable is a generic error when a provider is not avaiable
	ErrProviderUnavaiable = errors.New("provider not avaiable")
	// ErrFileNotFound is a generic error when a file is not found
	ErrFileNotFound = errors.New("file not found")
)

Functions

This section is empty.

Types

type AccessProvider

type AccessProvider interface {
	GetLatestVersion() (string, error) // Get the latest version (Should be accessible even if Open() was not called)
	Walk(walkFn WalkFunc) error
	Retrieve(srcPath string, destPath string) error
}

AccessProvider describes the access methods of a Provider This methods shouldn't change the state of the provider

type FileInfo

type FileInfo struct {
	Path string
	Mode os.FileMode
}

A FileInfo describes a file given by a provider

type Github

type Github struct {
	RepositoryURL string // Repository URL, example github.com/mouuff/go-rocket-update
	ZipName       string // Zip name (the zip you upload for a release on github), example: binaries.zip
	// contains filtered or unexported fields
}

Github provider finds a zip file in the repository's releases to provide files

func (*Github) Close

func (c *Github) Close() error

Close closes the provider

func (*Github) GetLatestVersion

func (c *Github) GetLatestVersion() (string, error)

GetLatestVersion gets the latest version

func (*Github) Open

func (c *Github) Open() (err error)

Open opens the provider

func (*Github) Retrieve

func (c *Github) Retrieve(src string, dest string) error

Retrieve file relative to "provider" to destination

func (*Github) Walk

func (c *Github) Walk(walkFn WalkFunc) error

Walk walks all the files provided

type Local

type Local struct {
	Path string // Path of the folder
}

A Local provider use a local directory to provide files This provider is mainly here for mocking and testing but it could be used on a shared network folder

func (*Local) Close

func (c *Local) Close() error

Close closes the provider

func (*Local) GetLatestVersion

func (c *Local) GetLatestVersion() (string, error)

GetLatestVersion gets the latest version

func (*Local) Open

func (c *Local) Open() error

Open opens the provider

func (*Local) Retrieve

func (c *Local) Retrieve(src string, dest string) error

Retrieve file relative to "provider" to destination

func (*Local) Walk

func (c *Local) Walk(walkFn WalkFunc) error

Walk walks all the files provided

type Provider

type Provider interface {
	AccessProvider
	Open() error
	Close() error
}

A Provider describes an interface for providing files

type Secure

type Secure struct {
	BackendProvider Provider
	PublicKeyPEM    []byte
	PublicKey       *rsa.PublicKey
	// contains filtered or unexported fields
}

Secure is a provider which uses another provider and verifies the signatures when Retrieve() is called If you pass a nil PublicKey, then it will try to load the PublicKeyPEM. PublicKeyPEM must be a public key in the PEM format

func (*Secure) Close

func (c *Secure) Close() error

Close the provider

func (*Secure) GetLatestVersion

func (c *Secure) GetLatestVersion() (string, error)

GetLatestVersion gets the latest version

func (*Secure) Open

func (c *Secure) Open() (err error)

Open the provider

func (*Secure) Retrieve

func (c *Secure) Retrieve(src string, dest string) error

Retrieve file and verifies the signature

func (*Secure) Walk

func (c *Secure) Walk(walkFn WalkFunc) error

Walk all the files provided

type WalkFunc

type WalkFunc func(info *FileInfo) error

WalkFunc is the type of the function called for each file or directory visited by Walk. path is relative

type Zip

type Zip struct {
	Path string // Path of the zip file
	// contains filtered or unexported fields
}

Zip provider

func (*Zip) Close

func (c *Zip) Close() error

Close closes the provider

func (*Zip) GetLatestVersion

func (c *Zip) GetLatestVersion() (string, error)

GetLatestVersion gets the latest version

func (*Zip) Open

func (c *Zip) Open() error

Open opens the provider

func (*Zip) Retrieve

func (c *Zip) Retrieve(src string, dest string) error

Retrieve file relative to "provider" to destination

func (*Zip) Walk

func (c *Zip) Walk(walkFn WalkFunc) error

Walk walks all the files provided

Jump to

Keyboard shortcuts

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