papigoplug

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AWSGetSession

func AWSGetSession() (sess *session.Session, err error)

AWSGetSession uses credentials sourced from environment variables to establish an AWS session and return it.

func InitLog

func InitLog(level string)

InitLog starts the logrus logger. This should be called exactly one time by the main program before the program uses other functions from papigoplug. A good default level is "info".

func ParseInput

func ParseInput(osArgs []string, allowedParams PluginParams) (providedParams map[string]interface{}, err error)

ParseInput scans the provided arguments list (e.g. CLI args from os.Args). It expects that there is one real arg, i.e. that osArgs has length 2, that osArgs[0] is the file name and that osArgs[1] is a JSON dictionary. It marshals the JSON dictionary into a map and returns it after validating that the provided parameters satisfy the constraints defined by allowedParams (that no Required parameters are missing and that all other provided parameters are part of the Optional list).

func PrintResults

func PrintResults(results map[string]interface{}) (err error)

PrintResults encodes the provided map into a JSON string within key "plugin_results" and prints that. This function must be called at the end of the program.

func S3Download

func S3Download(sess *session.Session, bucket, key, fileName string) (err error)

S3Download creates a local file a blob from s3 and saves it to a local file path, using multipart concurrency. The file is first downloaded to a temporary location on the disk, and then is renamed/moved to the final destination.

func S3SplitBucketKey

func S3SplitBucketKey(s3url string) (bucket string, key string, err error)

S3SplitBucketKey returns the bucket and key components of a s3:// URL.

func S3Upload

func S3Upload(sess *session.Session, bucket, key, fileName string) (err error)

S3Upload creates a blob on s3 by streaming the bytes from a local file path, using multipart concurrency.

Types

type PluginParams

type PluginParams struct {
	Required []string
	Optional []string
}

PluginParams must be instantiated by the program to define/constrain the allowed parameters.

Jump to

Keyboard shortcuts

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