s3Plugin

package
v0.0.0-...-900fa13 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	MaxS3GetAttempts = 10
	S3GetSleep       = 5 * 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"`

	// 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"`
}

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) Configure

func (self *S3Plugin) Configure(map[string]interface{}) error

func (*S3Plugin) GetAPIHandler

func (self *S3Plugin) GetAPIHandler() http.Handler

func (*S3Plugin) GetPanelConfig

func (self *S3Plugin) GetPanelConfig() (*plugin.PanelConfig, error)

GetPanelConfig fulfills the Plugin interface. This plugin does not need to register any UI hooks.

func (*S3Plugin) GetUIHandler

func (self *S3Plugin) GetUIHandler() http.Handler

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"`

	// RemoteFile is the filepath to store the file to,
	// within an s3 bucket
	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
	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"`
}

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

func (*S3PutCommand) AttachTaskFiles

func (self *S3PutCommand) AttachTaskFiles(pluginLogger plugin.Logger,
	pluginCom plugin.PluginCommunicator) error

AttachTaskFiles is responsible for sending the specified file to the API Server

func (*S3PutCommand) Execute

func (self *S3PutCommand) Execute(pluginLogger plugin.Logger,
	pluginCom 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 (self *S3PutCommand) Name() string

func (*S3PutCommand) ParseParams

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

S3PutCommand-specific implementation of ParseParams.

func (*S3PutCommand) Plugin

func (self *S3PutCommand) Plugin() string

func (*S3PutCommand) Put

func (self *S3PutCommand) Put() error

Put the specified resource to s3.

func (*S3PutCommand) PutWithRetry

func (self *S3PutCommand) PutWithRetry(pluginLogger plugin.Logger,
	pluginComm 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