util

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: Apache-2.0 Imports: 38 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const APITokenProviderName = "APITokenProvider"
View Source
const (
	EmptyDuration time.Duration = time.Duration(0)
)

Variables

This section is empty.

Functions

func NewAPIClient

func NewAPIClient(input *NewAPIClientInput) *operations.Client

func NewAPITokenProvider

func NewAPITokenProvider(token *string) credentials.Provider

func NewAWSSession

func NewAWSSession(token *string) (*session.Session, error)

Types

type APITokenProvider

type APITokenProvider struct {
	// contains filtered or unexported fields
}

APITokenProvider is a custom AWS Credentials provider which uses a base64 encoded token containing a STS credentials as JSON See https://docs.aws.amazon.com/sdk-for-go/api/aws/credentials/#hdr-Custom_Provider

Using a custom Provider does a few things for us: - Allows chaining credentials, so we can fall back to env vars, creds fil - The `Retrieve` method is cached by the client, so we don't need to re-parse our API token at every call - Provides a mechanism for handling expired creds

func (*APITokenProvider) IsExpired

func (t *APITokenProvider) IsExpired() bool

func (*APITokenProvider) Retrieve

func (t *APITokenProvider) Retrieve() (credentials.Value, error)

type APITokenValue

type APITokenValue struct {
	AccessKeyID     string `json:"accessKeyId"`
	SecretAccessKey string `json:"secretAccessKey"`
	SessionToken    string `json:"sessionToken"`
	Expiration      int64  `json:"expireTime"`
}

type AWSUtil

type AWSUtil struct {
	Config      *configs.Root
	Observation *observ.ObservationContainer
	Session     *awsSession.Session
}

func (*AWSUtil) ConfigureAWSCLICredentials

func (u *AWSUtil) ConfigureAWSCLICredentials(accessKeyID, secretAccessKey, sessionToken, profile string)

func (*AWSUtil) UpdateLambdasFromS3Assets

func (u *AWSUtil) UpdateLambdasFromS3Assets(lambdaNames []string, bucket string, namespace string)

func (*AWSUtil) UploadDirectoryToS3

func (u *AWSUtil) UploadDirectoryToS3(localPath string, bucket string, prefix string) ([]string, []string)

type AWSer

type AWSer interface {
	UploadDirectoryToS3(localPath string, bucket string, prefix string) ([]string, []string)
	UpdateLambdasFromS3Assets(lambdaNames []string, bucket string, namespace string)
	ConfigureAWSCLICredentials(accessKeyID, secretAccessKey, sessionToken, profile string)
}

type DurationUtil

type DurationUtil struct {
	DayFormatExp      *regexp.Regexp
	TimeUnitFormatExp *regexp.Regexp
}

DurationUtil has the

func NewDurationUtil

func NewDurationUtil() *DurationUtil

NewDurationUtil creates a new `DuractionUtil`

func (*DurationUtil) ExpandEpochTime

func (d *DurationUtil) ExpandEpochTime(str string) (int64, error)

ExpandEpochTime "expands" the given time from a string. If it is an int64, it assumes the time is a UNIX epoch time and is "absolute" and so refers the time. If it is a string, it assumes the time is "relative" to now and returns the UNIX epoch time with the duration added.

func (*DurationUtil) ParseDuration

func (d *DurationUtil) ParseDuration(str string) (time.Duration, error)

ParseDuration accepts a string to parse and return a `time.Duration`. This is used because the default time.Duration in go only supports up to the hour, and for lease expirations we want to support days,

type Durationer

type Durationer interface {
	ExpandEpochTime(str string) (int64, error)
	ParseDuration(str string) (time.Duration, error)
}

type FileSystemUtil

type FileSystemUtil struct {
	Config     *configs.Root
	ConfigFile string
}

func (*FileSystemUtil) Chdir

func (u *FileSystemUtil) Chdir(path string)

func (*FileSystemUtil) GetConfigFile

func (u *FileSystemUtil) GetConfigFile() string

func (*FileSystemUtil) GetHomeDir

func (u *FileSystemUtil) GetHomeDir() string

func (*FileSystemUtil) IsExistingFile

func (u *FileSystemUtil) IsExistingFile(path string) bool

func (*FileSystemUtil) MvToTempDir

func (u *FileSystemUtil) MvToTempDir(prefix string) (string, string)

func (*FileSystemUtil) ReadDir

func (u *FileSystemUtil) ReadDir(path string) []os.FileInfo

func (*FileSystemUtil) ReadFromFile

func (u *FileSystemUtil) ReadFromFile(path string) string

func (*FileSystemUtil) ReadInConfig

func (u *FileSystemUtil) ReadInConfig() error

ReadInConfig loads the configuration from `dce.yml` and unmarshals it into the config object

func (*FileSystemUtil) RemoveAll

func (u *FileSystemUtil) RemoveAll(path string)

func (*FileSystemUtil) Unarchive

func (u *FileSystemUtil) Unarchive(source string, destination string)

func (*FileSystemUtil) WriteConfig

func (u *FileSystemUtil) WriteConfig() error

WriteConfig writes the Config objects as YAML to the config file location (dce.yml)

func (*FileSystemUtil) WriteFile

func (u *FileSystemUtil) WriteFile(fileName string, data string)

type FileSystemer

type FileSystemer interface {
	WriteConfig() error
	GetConfigFile() string
	GetHomeDir() string
	IsExistingFile(path string) bool
	ReadFromFile(path string) string
	ReadInConfig() error
	Unarchive(source string, destination string)
	MvToTempDir(prefix string) (string, string)
	RemoveAll(path string)
	Chdir(path string)
	ReadDir(path string) []os.FileInfo
	WriteFile(fileName string, data string)
}

type GithubUtil

type GithubUtil struct {
	Config      *configs.Root
	Observation *observ.ObservationContainer
}

func (*GithubUtil) DownloadGithubReleaseAsset

func (u *GithubUtil) DownloadGithubReleaseAsset(assetName string)

type Githuber

type Githuber interface {
	DownloadGithubReleaseAsset(assetName string)
}

type NewAPIClientInput

type NewAPIClientInput struct {
	// contains filtered or unexported fields
}

type PromptUtil

type PromptUtil struct {
	Config      *configs.Root
	Observation *observ.ObservationContainer
}

func (*PromptUtil) PromptBasic

func (u *PromptUtil) PromptBasic(label string, validator func(input string) error) *string

func (*PromptUtil) PromptSelect

func (u *PromptUtil) PromptSelect(label string, items []string) *string

type Prompter

type Prompter interface {
	PromptBasic(label string, validator func(input string) error) *string
	PromptSelect(label string, items []string) *string
}

type Sig4RoundTripper

type Sig4RoundTripper struct {
	Proxied http.RoundTripper
	Creds   *credentials.Credentials
	Region  string
	Logger  observation.Logger
}

Adapted from https://stackoverflow.com/questions/39527847/is-there-middleware-for-go-http-client

func (Sig4RoundTripper) RoundTrip

func (srt Sig4RoundTripper) RoundTrip(req *http.Request) (res *http.Response, e error)

type TerraformUtil

type TerraformUtil struct {
	Config      *configs.Root
	Observation *observ.ObservationContainer
}

func (*TerraformUtil) Apply

func (u *TerraformUtil) Apply(tfVars []string)

Apply applies terraform template with given namespace

func (*TerraformUtil) GetOutput

func (u *TerraformUtil) GetOutput(key string) string

GetOutput gets terraform output value for provided key

func (*TerraformUtil) Init

func (u *TerraformUtil) Init(args []string)

Init initialized a terraform working directory

type Terraformer

type Terraformer interface {
	Init(args []string)
	Apply(tfVars []string)
	GetOutput(key string) string
}

type UIOutputCaptor

type UIOutputCaptor struct {
	Captor *string
	*cli.BasicUi
}

UIOutputCaptor effectively extends cli.BasicUi and overrides Output method to capture output string.

func (*UIOutputCaptor) Output

func (u *UIOutputCaptor) Output(message string)

Output overrides cli.BasicUi Output method in UIOutputCaptor

type UtilContainer

type UtilContainer struct {
	Config *configs.Root
	// File path location of the dce.yaml file, from which this config was parsed
	// Useful if we want to reload or modify the file later
	ConfigFile  string
	Observation *observ.ObservationContainer
	AWSSession  *session.Session
	AWSer
	APIer
	Terraformer
	Githuber
	Prompter
	FileSystemer
	Weber
	Durationer
}

func New

func New(config *configs.Root, configFile string, observation *observ.ObservationContainer) *UtilContainer

New returns a new Util given config

type WebUtil

type WebUtil struct {
	Observation *observ.ObservationContainer
}

func (*WebUtil) OpenURL

func (w *WebUtil) OpenURL(url string)

type Weber

type Weber interface {
	OpenURL(url string)
}

Jump to

Keyboard shortcuts

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