sync

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SyncTools

func SyncTools(syncContext *SyncContext) error

SyncTools copies the Juju tools tarball from the official bucket or a specified source directory into the user's environment.

Types

type BuildAgentTarballFunc

type BuildAgentTarballFunc func(build bool, forceVersion *version.Number, stream string) (*BuiltAgent, error)

BuildAgentTarballFunc is a function which can build an agent tarball.

var BuildAgentTarball BuildAgentTarballFunc = buildAgentTarball

Override for testing.

type BuiltAgent

type BuiltAgent struct {
	Version     version.Binary
	Official    bool
	Dir         string
	StorageName string
	Sha256Hash  string
	Size        int64
}

BuiltAgent contains metadata for a tools tarball resulting from a call to BundleTools.

type StorageToolsFinder

type StorageToolsFinder struct {
	Storage storage.StorageReader
}

StorageToolsFinder is an implementation of ToolsFinder that searches for tools in the specified storage.

func (StorageToolsFinder) FindTools

func (f StorageToolsFinder) FindTools(major int, stream string) (coretools.List, error)

type StorageToolsUploader

type StorageToolsUploader struct {
	Fetcher       envtools.SimplestreamsFetcher
	Storage       storage.Storage
	WriteMetadata bool
	WriteMirrors  envtools.ShouldWriteMirrors
}

StorageToolsUploader is an implementation of ToolsUploader that writes tools to the provided storage and then writes merged metadata, optionally with mirrors.

func (StorageToolsUploader) UploadTools

func (u StorageToolsUploader) UploadTools(toolsDir, stream string, tools *coretools.Tools, data []byte) error

type SyncContext

type SyncContext struct {
	// TargetToolsFinder is a ToolsFinder provided to find existing
	// tools in the target destination.
	TargetToolsFinder ToolsFinder

	// TargetToolsUploader is a ToolsUploader provided to upload
	// tools to the target destination.
	TargetToolsUploader ToolsUploader

	// AllVersions controls the copy of all versions, not only the latest.
	AllVersions bool

	// Copy tools with major version, if MajorVersion > 0.
	MajorVersion int

	// Copy tools with minor version, if MinorVersion > 0.
	MinorVersion int

	// DryRun controls that nothing is copied. Instead it's logged
	// what would be coppied.
	DryRun bool

	// Stream specifies the simplestreams stream to use (defaults to "Released").
	Stream string

	// Source, if non-empty, specifies a directory in the local file system
	// to use as a source.
	Source string
}

SyncContext describes the context for tool synchronization.

type ToolsFinder

type ToolsFinder interface {
	// FindTools returns a list of tools with the specified major version in the specified stream.
	FindTools(major int, stream string) (coretools.List, error)
}

ToolsFinder provides an interface for finding tools of a specified version.

type ToolsUploader

type ToolsUploader interface {
	// UploadTools uploads the tools with the specified version and tarball contents.
	UploadTools(toolsDir, stream string, tools *coretools.Tools, data []byte) error
}

ToolsUploader provides an interface for uploading tools and associated metadata.

type UploadFunc

type UploadFunc func(envtools.SimplestreamsFetcher, storage.Storage, string, *version.Number) (*coretools.Tools, error)

UploadFunc is the type of Upload, which may be reassigned to control the behaviour of tools uploading.

var Upload UploadFunc = upload

Upload is exported for testing.

Jump to

Keyboard shortcuts

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