Documentation
¶
Overview ¶
Package cache provides functionality for working with an on-disk cache of the ECS Agent image.
Index ¶
- type CacheStatus
- type Downloader
- func (d *Downloader) AgentCacheStatus() CacheStatus
- func (d *Downloader) DownloadAgent() error
- func (d *Downloader) IsAgentCached() bool
- func (d *Downloader) LoadCachedAgent() (io.ReadCloser, error)
- func (d *Downloader) LoadDesiredAgent() (io.ReadCloser, error)
- func (d *Downloader) RecordCachedAgent() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheStatus ¶
type CacheStatus uint8
CacheStatus represents the status of the on-disk cache for agent tarballs in the cache directory. This status may be used to determine what the appropriate actions are based on the availability of agent images and communicates advice from the cache's state file.
const ( // StatusUncached indicates that there is not an already downloaded // and cached agent that is suitable for loading. StatusUncached CacheStatus = 0 // StatusCached indicates that there is an agent downloaded and // cached. This should be taken to mean that the image is suitable // for load if agent isn't already loaded. StatusCached CacheStatus = 1 // StatusReloadNeeded indicates that the cached image should take // precedence over the already loaded agent image. This may be // specified by the packaging to cause ecs-init to load a package // distributed cached image on package installation, upgrades, or // downgrades. StatusReloadNeeded CacheStatus = 2 )
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader is responsible for cache operations relating to downloading the agent
func NewDownloader ¶
func NewDownloader() (*Downloader, error)
NewDownloader returns a Downloader with default dependencies
func (*Downloader) AgentCacheStatus ¶
func (d *Downloader) AgentCacheStatus() CacheStatus
AgentCacheStatus inspects the on-disk cache and returns its status. See `CacheStatus` for possible cache statuses and scenarios.
func (*Downloader) DownloadAgent ¶
func (d *Downloader) DownloadAgent() error
DownloadAgent downloads a fresh copy of the Agent and performs an integrity check on the downloaded image
func (*Downloader) IsAgentCached ¶
func (d *Downloader) IsAgentCached() bool
IsAgentCached returns true if there is a cached copy of the Agent present and a cache state file is not empty (no validation is performed on the tarball or cache state file contents)
func (*Downloader) LoadCachedAgent ¶
func (d *Downloader) LoadCachedAgent() (io.ReadCloser, error)
LoadCachedAgent returns an io.ReadCloser of the Agent from the cache
func (*Downloader) LoadDesiredAgent ¶
func (d *Downloader) LoadDesiredAgent() (io.ReadCloser, error)
LoadDesiredAgent returns an io.ReadCloser of the Agent indicated by the desiredImageLocatorFile (/var/cache/ecs/desired-image). The desiredImageLocatorFile must contain as the beginning of the file the name of the file containing the desired image (interpreted as a basename) and ending in a newline. Only the first line is read, with the rest of the file reserved for future use.
func (*Downloader) RecordCachedAgent ¶
func (d *Downloader) RecordCachedAgent() error
RecordCachedAgent writes the StatusCached state to disk to record a newly cached or loaded agent image; this prevents StatusReloadNeeded from being interpreted after the reload.