s3

package
v0.0.0-...-1d50e38 Latest Latest
Warning

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

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	S3GetCmd     = "get"
	S3PutCmd     = "put"
	S3PluginName = "s3"
)

Variables

View Source
var (
	MaxS3GetAttempts = 10
	S3GetSleep       = 2 * time.Second
)
View Source
var (
	// Regular expression for validating S3 bucket names
	BucketNameRegex = regexp.MustCompile(`^[A-Za-z0-9_\-.]+$`)
)

Functions

This section is empty.

Types

type S3GetCommand

type S3GetCommand struct {
	// AwsKey and AwsSecret are the user's credentials for
	// authenticating interactions with s3.
	AwsKey    string `mapstructure:"aws_key" plugin:"expand"`
	AwsSecret string `mapstructure:"aws_secret" plugin:"expand"`

	// RemoteFile is the filepath of the file to get, within its bucket
	RemoteFile string `mapstructure:"remote_file" plugin:"expand"`

	// Bucket is the s3 bucket holding the desired file
	Bucket string `mapstructure:"bucket" plugin:"expand"`

	// BuildVariants stores a list of MCI build variants to run the command for.
	// If the list is empty, it runs for all build variants.
	BuildVariants []string `mapstructure:"build_variants" plugin:"expand"`

	// Only one of these two should be specified. local_file indicates that the
	// s3 resource should be downloaded as-is to the specified file, and
	// extract_to indicates that the remote resource is a .tgz file to be
	// downloaded to the specified directory.
	LocalFile string `mapstructure:"local_file" plugin:"expand"`
	ExtractTo string `mapstructure:"extract_to" plugin:"expand"`
}

A plugin command to fetch a resource from an s3 bucket and download it to the local machine.

func (*S3GetCommand) Execute

func (self *S3GetCommand) Execute(pluginLogger plugin.Logger,
	pluginCom plugin.PluginCommunicator, conf *model.TaskConfig,
	stop chan bool) error

Implementation of Execute. Expands the parameters, and then fetches the resource from s3.

func (*S3GetCommand) Get

func (self *S3GetCommand) Get() error

Fetch the specified resource from s3.

func (*S3GetCommand) GetWithRetry

func (self *S3GetCommand) GetWithRetry(pluginLogger plugin.Logger) error

Wrapper around the Get() function to retry it

func (*S3GetCommand) Name

func (self *S3GetCommand) Name() string

func (*S3GetCommand) ParseParams

func (self *S3GetCommand) ParseParams(params map[string]interface{}) error

S3GetCommand-specific implementation of ParseParams.

func (*S3GetCommand) Plugin

func (self *S3GetCommand) Plugin() string

type S3Plugin

type S3Plugin struct {
}

S3Plugin handles uploading and downloading from Amazon's S3 service

func (*S3Plugin) Name

func (self *S3Plugin) Name() string

Name returns the name of the plugin. Fulfills Plugin interface.

func (*S3Plugin) NewCommand

func (self *S3Plugin) NewCommand(cmdName string) (plugin.Command, error)

NewCommand returns commands of the given name. Fulfills Plugin interface.

type S3PutCommand

type S3PutCommand struct {
	// AwsKey and AwsSecret are the user's credentials for
	// authenticating interactions with s3.
	AwsKey    string `mapstructure:"aws_key" plugin:"expand"`
	AwsSecret string `mapstructure:"aws_secret" plugin:"expand"`

	// LocalFile is the local filepath to the file the user
	// wishes to store in s3
	LocalFile string `mapstructure:"local_file" plugin:"expand"`

	// LocalFilesIncludeFilter is an array of expressions that specify what files should be
	// included in this upload.
	LocalFilesIncludeFilter []string `mapstructure:"local_files_include_filter" plugin:"expand"`

	// RemoteFile is the filepath to store the file to,
	// within an s3 bucket. Is a prefix when multiple files are uploaded via LocalFilesIncludeFilter.
	RemoteFile string `mapstructure:"remote_file" plugin:"expand"`

	// Bucket is the s3 bucket to use when storing the desired file
	Bucket string `mapstructure:"bucket" plugin:"expand"`

	// Permission is the ACL to apply to the uploaded file. See:
	//  http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
	// for some examples.
	Permissions string `mapstructure:"permissions"`

	// ContentType is the MIME type of the uploaded file.
	//  E.g. text/html, application/pdf, image/jpeg, ...
	ContentType string `mapstructure:"content_type" plugin:"expand"`

	// BuildVariants stores a list of MCI build variants to run the command for.
	// If the list is empty, it runs for all build variants.
	BuildVariants []string `mapstructure:"build_variants"`

	// DisplayName stores the name of the file that is linked. Is a prefix when
	// to the matched file name when multiple files are uploaded.
	DisplayName string `mapstructure:"display_name" plugin:"expand"`

	// Visibility determines who can see file links in the UI.
	// Visibility can be set to either
	//  "private", which allows logged-in users to see the file;
	//  "public", which allows anyone to see the file; or
	//  "none", which hides the file from the UI for everybody.
	// If unset, the file will be public.
	Visibility string `mapstructure:"visibility" plugin:"expand"`

	// Optional, when set to true, causes this command to be skipped over without an error when
	// the path specified in local_file does not exist. Defaults to false, which triggers errors
	// for missing files.
	Optional bool `mapstructure:"optional"`
}

A plugin command to put a resource to an s3 bucket and download it to the local machine.

func (*S3PutCommand) AttachTaskFiles

func (s3pc *S3PutCommand) AttachTaskFiles(log plugin.Logger,
	com plugin.PluginCommunicator, localFile, remoteFile string) error

AttachTaskFiles is responsible for sending the specified file to the API Server. Does not support multiple file putting.

func (*S3PutCommand) Execute

func (s3pc *S3PutCommand) Execute(log plugin.Logger,
	com plugin.PluginCommunicator, conf *model.TaskConfig,
	stop chan bool) error

Implementation of Execute. Expands the parameters, and then puts the resource to s3.

func (*S3PutCommand) Name

func (s3pc *S3PutCommand) Name() string

func (*S3PutCommand) ParseParams

func (s3pc *S3PutCommand) ParseParams(params map[string]interface{}) error

S3PutCommand-specific implementation of ParseParams.

func (*S3PutCommand) Plugin

func (s3pc *S3PutCommand) Plugin() string

func (*S3PutCommand) Put

func (s3pc *S3PutCommand) Put() ([]string, error)

Put the specified resource to s3.

func (*S3PutCommand) PutWithRetry

func (s3pc *S3PutCommand) PutWithRetry(log plugin.Logger, com plugin.PluginCommunicator) error

Wrapper around the Put() function to retry it.

Jump to

Keyboard shortcuts

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