archive

package
v0.0.0-...-bd9d91d Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

archive is package that helps create archives in a format that Atlas expects with its various upload endpoints.

Index

Constants

View Source
const (
	// ExtraEntryDir just creates the Extra key as a directory entry.
	ExtraEntryDir = ""
)

Constants related to setting special values for Extra in ArchiveOpts.

Variables

View Source
var VCSList = []*VCS{
	&VCS{
		Name:      "git",
		Detect:    []string{".git/"},
		Preflight: gitPreflight,
		Files:     vcsFilesCmd("git", "ls-files"),
		Metadata:  gitMetadata,
	},
	&VCS{
		Name:   "hg",
		Detect: []string{".hg/"},
		Files:  vcsTrimCmd(vcsFilesCmd("hg", "locate", "-f", "--include", ".")),
	},
	&VCS{
		Name:   "svn",
		Detect: []string{".svn/"},
		Files:  vcsFilesCmd("svn", "ls"),
	},
}

VCSList is the list of VCS we recognize.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	io.ReadCloser

	Size     int64
	Metadata map[string]string
}

Archive is the resulting archive. The archive data is generally streamed so the io.ReadCloser can be used to backpressure the archive progress and avoid memory pressure.

func CreateArchive

func CreateArchive(path string, opts *ArchiveOpts) (*Archive, error)

CreateArchive takes the given path and ArchiveOpts and archives it.

The archive will be fully completed and put into a temporary file. This must be done to retrieve the content length of the archive which is needed for almost all operations involving archives with Atlas. Because of this, sufficient disk space will be required to buffer the archive.

type ArchiveOpts

type ArchiveOpts struct {
	// Exclude and Include are filters of files to include/exclude in
	// the archive when creating it from a directory. These filters should
	// be relative to the packaging directory and should be basic glob
	// patterns.
	Exclude []string
	Include []string

	// Extra is a mapping of extra files to include within the archive. The
	// key should be the path within the archive and the value should be
	// an absolute path to the file to put into the archive. These extra
	// files will override any other files in the archive.
	Extra map[string]string

	// VCS, if true, will detect and use a VCS system to determine what
	// files to include the archive.
	VCS bool
}

ArchiveOpts are the options for defining how the archive will be built.

func (*ArchiveOpts) IsSet

func (o *ArchiveOpts) IsSet() bool

IsSet says whether any options were set.

type VCS

type VCS struct {
	Name string

	// Detect is a list of files/folders that if they exist, signal that
	// this VCS is the VCS in use.
	Detect []string

	// Files returns the files that are under version control for the
	// given path.
	Files VCSFilesFunc

	// Metadata returns arbitrary metadata about the underlying VCS for the
	// given path.
	Metadata VCSMetadataFunc

	// Preflight is a function to run before looking for VCS files.
	Preflight VCSPreflightFunc
}

VCS is a struct that explains how to get the file list for a given VCS.

type VCSFilesFunc

type VCSFilesFunc func(string) ([]string, error)

VCSFilesFunc is the callback invoked to return the files in the VCS.

The return value should be paths relative to the given path.

type VCSMetadataFunc

type VCSMetadataFunc func(string) (map[string]string, error)

VCSMetadataFunc is the callback invoked to get arbitrary information about the current VCS.

The return value should be a map of key-value pairs.

type VCSPreflightFunc

type VCSPreflightFunc func(string) error

VCSPreflightFunc is a function that runs before VCS detection to be configured by the user. It may be used to check if pre-requisites (like the actual VCS) are installed or that a program is at the correct version. If an error is returned, the VCS will not be processed and the error will be returned up the stack.

The given argument is the path where the VCS is running.

Jump to

Keyboard shortcuts

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