Documentation
¶
Index ¶
- Constants
- func NewAPIClient(input *NewAPIClientInput) *operations.Client
- func NewAPITokenProvider(token *string) credentials.Provider
- func NewAWSSession(token *string) (*session.Session, error)
- type APITokenProvider
- type APITokenValue
- type APIer
- type AWSUtil
- func (u *AWSUtil) ConfigureAWSCLICredentials(accessKeyID, secretAccessKey, sessionToken, profile string)
- func (u *AWSUtil) UpdateLambdasFromS3Assets(lambdaNames []string, bucket string, namespace string)
- func (u *AWSUtil) UploadDirectoryToS3(localPath string, bucket string, prefix string) ([]string, []string)
- type AWSer
- type DurationUtil
- type Durationer
- type FileSystemUtil
- func (u *FileSystemUtil) Chdir(path string)
- func (u *FileSystemUtil) GetConfigFile() string
- func (u *FileSystemUtil) GetHomeDir() string
- func (u *FileSystemUtil) IsExistingFile(path string) bool
- func (u *FileSystemUtil) MvToTempDir(prefix string) (string, string)
- func (u *FileSystemUtil) ReadDir(path string) []os.FileInfo
- func (u *FileSystemUtil) ReadFromFile(path string) string
- func (u *FileSystemUtil) ReadInConfig() error
- func (u *FileSystemUtil) RemoveAll(path string)
- func (u *FileSystemUtil) Unarchive(source string, destination string)
- func (u *FileSystemUtil) WriteConfig() error
- func (u *FileSystemUtil) WriteFile(fileName string, data string)
- type FileSystemer
- type GithubUtil
- type Githuber
- type NewAPIClientInput
- type PromptUtil
- type Prompter
- type Sig4RoundTripper
- type TerraformUtil
- type Terraformer
- type UIOutputCaptor
- type UtilContainer
- type WebUtil
- type Weber
Constants ¶
const APITokenProviderName = "APITokenProvider"
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
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 APIer ¶
type APIer interface {
DeleteAccountsID(*operations.DeleteAccountsIDParams, runtime.ClientAuthInfoWriter) (*operations.DeleteAccountsIDNoContent, error)
DeleteLeases(*operations.DeleteLeasesParams, runtime.ClientAuthInfoWriter) (*operations.DeleteLeasesOK, error)
GetAccounts(*operations.GetAccountsParams, runtime.ClientAuthInfoWriter) (*operations.GetAccountsOK, error)
GetAccountsID(*operations.GetAccountsIDParams, runtime.ClientAuthInfoWriter) (*operations.GetAccountsIDOK, error)
GetLeases(*operations.GetLeasesParams, runtime.ClientAuthInfoWriter) (*operations.GetLeasesOK, error)
GetLeasesID(*operations.GetLeasesIDParams, runtime.ClientAuthInfoWriter) (*operations.GetLeasesIDOK, error)
GetUsage(*operations.GetUsageParams, runtime.ClientAuthInfoWriter) (*operations.GetUsageOK, error)
PostAccounts(*operations.PostAccountsParams, runtime.ClientAuthInfoWriter) (*operations.PostAccountsCreated, error)
PostLeases(*operations.PostLeasesParams, runtime.ClientAuthInfoWriter) (*operations.PostLeasesCreated, error)
PostLeasesIDAuth(*operations.PostLeasesIDAuthParams, runtime.ClientAuthInfoWriter) (*operations.PostLeasesIDAuthCreated, error)
SetTransport(runtime.ClientTransport)
}
APIer is an interface generated for "github.com/Optum/dce-cli/client/operations.Client".
type AWSUtil ¶
type AWSUtil struct {
Config *configs.Root
Observation *observ.ObservationContainer
Session *awsSession.Session
}
func (*AWSUtil) ConfigureAWSCLICredentials ¶
func (*AWSUtil) UpdateLambdasFromS3Assets ¶
type DurationUtil ¶
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 FileSystemUtil ¶
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) 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 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 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
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 UIOutputCaptor ¶
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
}