Documentation
¶
Overview ¶
Package plugingetter defines means to download and install plugins.
Index ¶
- type BinaryInstallationOptions
- type Checksum
- type ChecksumError
- type ChecksumFileEntry
- type Checksummer
- func (c *Checksummer) Checksum(expected []byte, f io.Reader) error
- func (c *Checksummer) ChecksumFile(expected []byte, filePath string) error
- func (c *Checksummer) FileExt() string
- func (c *Checksummer) GetCacheChecksumOfFile(filePath string) ([]byte, error)
- func (c *Checksummer) ParseChecksum(f io.Reader) (Checksum, error)
- func (c *Checksummer) Sum(f io.Reader) ([]byte, error)
- type FileChecksum
- type GetOptions
- type Getter
- type InstallList
- type InstallOptions
- type Installation
- type ListInstallationsOptions
- type Release
- type Requirement
- type Requirements
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryInstallationOptions ¶
type BinaryInstallationOptions struct {
//
APIVersionMajor, APIVersionMinor string
// OS and ARCH usually should be runtime.GOOS and runtime.ARCH, they allow
// to pick the correct binary.
OS, ARCH string
// Ext is ".exe" on windows
Ext string
Checksummers []Checksummer
}
func (*BinaryInstallationOptions) CheckProtocolVersion ¶
func (binOpts *BinaryInstallationOptions) CheckProtocolVersion(remoteProt string) error
type ChecksumError ¶
A ChecksumError is returned when a checksum differs
func (*ChecksumError) Error ¶
func (cerr *ChecksumError) Error() string
type ChecksumFileEntry ¶
type ChecksumFileEntry struct {
Filename string `json:"filename"`
Checksum string `json:"checksum"`
// contains filtered or unexported fields
}
func ParseChecksumFileEntries ¶
func ParseChecksumFileEntries(f io.Reader) ([]ChecksumFileEntry, error)
func (ChecksumFileEntry) Arch ¶
func (e ChecksumFileEntry) Arch() string
func (ChecksumFileEntry) BinVersion ¶
func (e ChecksumFileEntry) BinVersion() string
func (ChecksumFileEntry) Ext ¶
func (e ChecksumFileEntry) Ext() string
func (ChecksumFileEntry) Os ¶
func (e ChecksumFileEntry) Os() string
func (ChecksumFileEntry) ProtVersion ¶
func (e ChecksumFileEntry) ProtVersion() string
type Checksummer ¶
func (*Checksummer) ChecksumFile ¶
func (c *Checksummer) ChecksumFile(expected []byte, filePath string) error
ChecksumFile compares the expected checksum to the checksum of the file in filePath using the hash function.
func (*Checksummer) FileExt ¶
func (c *Checksummer) FileExt() string
func (*Checksummer) GetCacheChecksumOfFile ¶
func (c *Checksummer) GetCacheChecksumOfFile(filePath string) ([]byte, error)
GetCacheChecksumOfFile will extract the checksum from file `filePath + c.FileExt()`. It expects the checksum file to only contains the checksum and nothing else.
func (*Checksummer) ParseChecksum ¶
func (c *Checksummer) ParseChecksum(f io.Reader) (Checksum, error)
ParseChecksum expects the checksum reader to only contain the checksum and nothing else.
type FileChecksum ¶
type FileChecksum struct {
Filename string
Expected Checksum
Checksummer
}
type GetOptions ¶
type GetOptions struct {
PluginRequirement *Requirement
BinaryInstallationOptions
// contains filtered or unexported fields
}
func (*GetOptions) ExpectedZipFilename ¶
func (gp *GetOptions) ExpectedZipFilename() string
ExpectedZipFilename is the filename of the zip we expect to find, the value is known only after parsing the checksum file file.
func (*GetOptions) Version ¶
func (gp *GetOptions) Version() string
type Getter ¶
type Getter interface {
// Get:
// * 'releases'
// * 'sha256'
// * 'binary'
Get(what string, opts GetOptions) (io.ReadCloser, error)
}
A Getter helps get the appropriate files to download a binary.
type InstallList ¶
type InstallList []*Installation
InstallList is a list of installed plugins (binaries) with their versions, ListInstallations should be used to get an InstallList.
ListInstallations sorts binaries by version and one binary per version is returned.
func (*InstallList) InsertSortedUniq ¶
func (l *InstallList) InsertSortedUniq(install *Installation)
InsertSortedUniq inserts the installation in the right spot in the list by comparing the version lexicographically. A Duplicate version will replace any already present version.
func (InstallList) String ¶
func (l InstallList) String() string
type InstallOptions ¶
type InstallOptions struct {
// Different means to get releases, sha256 and binary files.
Getters []Getter
// Any downloaded binary and checksum file will be put in the last possible
// folder of this list.
InFolders []string
BinaryInstallationOptions
}
InstallOptions describes the possible options for installing the plugin that fits the plugin Requirement.
type Installation ¶
type Installation struct {
// path to where binary is installed, if installed.
// Ex: /usr/azr/.packer.d/plugins/github.com/hashicorp/packer-plugin-amazon/packer-plugin-amazon_v1.2.3_darwin_amd64
BinaryPath string
// Version of this plugin, if installed and versionned. Ex:
// * v1.2.3 for packer-plugin-amazon_v1.2.3_darwin_x5
// * empty for packer-plugin-amazon
Version string
}
Installation describes a plugin installation
type ListInstallationsOptions ¶
type ListInstallationsOptions struct {
// FromFolders where plugins could be installed. Paths should be absolute for
// safety but can also be relative.
FromFolders []string
BinaryInstallationOptions
}
type Release ¶
type Release struct {
Version string `json:"version"`
}
func ParseReleases ¶
func ParseReleases(f io.ReadCloser) ([]Release, error)
type Requirement ¶
type Requirement struct {
// Plugin accessor as defined in the config file.
// For Packer, using :
// required_plugins { amazon = {...} }
// Will set Accessor to `amazon`.
Accessor string
// Something like github.com/hashicorp/packer-plugin-amazon, from the
// previous example.
Identifier *addrs.Plugin
// VersionConstraints as defined by user. Empty ( to be avoided ) means
// highest found version.
VersionConstraints version.Constraints
// was this require implicitly guessed ?
Implicit bool
}
Requirement describes a required plugin and how it is installed. Usually a list of required plugins is generated from a config file. From it we check what is actually installed and what needs to happen to get in the desired state.
func (Requirement) FilenamePrefix ¶
func (pr Requirement) FilenamePrefix() string
func (*Requirement) InstallLatest ¶
func (pr *Requirement) InstallLatest(opts InstallOptions) (*Installation, error)
func (Requirement) ListInstallations ¶
func (pr Requirement) ListInstallations(opts ListInstallationsOptions) (InstallList, error)
ListInstallations lists unique installed versions of plugin Requirement pr with opts as a filter.
Installations are sorted by version and one binary per version is returned. Last binary detected takes precedence: in the order 'FromFolders' option.
At least one opts.Checksumers must be given for a binary to be even considered.
type Requirements ¶
type Requirements []*Requirement