gcsupload

package
v0.0.0-...-97238d6 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package gcsupload uploads artifacts to a GCS path resolved from job configuration

Index

Constants

View Source
const (
	// JSONConfigEnvVar is the environment variable that
	// utilities expect to find a full JSON configuration
	// in when run.
	JSONConfigEnvVar = "GCSUPLOAD_OPTIONS"
)

Variables

This section is empty.

Functions

func Encode

func Encode(options Options) (string, error)

Encode will encode the set of options in the format that is expected for the configuration environment variable.

func PathsForJob

func PathsForJob(options *kube.GCSConfiguration, spec *downwardapi.JobSpec, subdir string) (string, string, gcs.RepoPathBuilder)

PathsForJob determines the following for a job:

  • path in GCS under the bucket where job artifacts will be uploaded for:
  • the job
  • this specific run of the job (if any subdir is present)

The builder for the job is also returned for use in other path resolution.

Types

type Options

type Options struct {
	// Items are files or directories to upload.
	Items []string `json:"items,omitempty"`

	// SubDir is appended to the GCS path.
	SubDir string `json:"sub_dir,omitempty"`

	*kube.GCSConfiguration

	// GcsCredentialsFile is the path to the JSON
	// credentials for pushing to GCS.
	GcsCredentialsFile string `json:"gcs_credentials_file,omitempty"`
	DryRun             bool   `json:"dry_run"`
	// contains filtered or unexported fields
}

Options exposes the configuration necessary for defining where in GCS an upload will land.

func NewOptions

func NewOptions() *Options

NewOptions returns an empty Options with no nil fields.

func (*Options) AddFlags

func (o *Options) AddFlags(fs *flag.FlagSet)

AddFlags adds flags to the FlagSet that populate the GCS upload options struct given.

func (*Options) Complete

func (o *Options) Complete(args []string)

Complete internalizes command line arguments

func (*Options) ConfigVar

func (o *Options) ConfigVar() string

ConfigVar exposes the environment variable used to store serialized configuration.

func (*Options) LoadConfig

func (o *Options) LoadConfig(config string) error

LoadConfig loads options from serialized config

func (Options) Run

func (o Options) Run(spec *downwardapi.JobSpec, extra map[string]gcs.UploadFunc) error

Run will upload files to GCS as prescribed by the options. Any extra files can be passed as a parameter and will have the prefix prepended to their destination in GCS, so the caller can operate relative to the base of the GCS dir.

func (*Options) Validate

func (o *Options) Validate() error

Validate ensures that the set of options are self-consistent and valid.

Jump to

Keyboard shortcuts

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