Documentation ¶
Index ¶
- Constants
- func NewAPIClient(input *NewAPIClientInput) *operations.Client
- func NewAPITokenProvider(token *string) credentials.Provider
- func NewAWSSession(token *string) (*session.Session, error)
- func ParseOptions(s *string) ([]string, 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) ChToConfigDir() (string, string)
- func (u *FileSystemUtil) ChToTmpDir() (string, string)
- func (u *FileSystemUtil) Chdir(path string)
- func (u *FileSystemUtil) CreateConfigDirTree(dceVersion string) error
- func (u *FileSystemUtil) GetArtifactsDir(dceVersion string) string
- func (u *FileSystemUtil) GetCacheDir() string
- func (u *FileSystemUtil) GetConfigDir() string
- func (u *FileSystemUtil) GetConfigFile() string
- func (u *FileSystemUtil) GetHomeDir() string
- func (u *FileSystemUtil) GetLocalMainTFFile() string
- func (u *FileSystemUtil) GetLocalTFModuleDir() string
- func (u *FileSystemUtil) GetLogFile() string
- func (u *FileSystemUtil) GetTerraformBin() string
- func (u *FileSystemUtil) GetTerraformBinDir() string
- func (u *FileSystemUtil) GetTerraformStateFile() string
- func (u *FileSystemUtil) IsExistingFile(path string) bool
- func (u *FileSystemUtil) OpenFileWriter(path string) (*os.File, error)
- 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) error
- func (u *FileSystemUtil) WriteConfig() error
- func (u *FileSystemUtil) WriteFile(fileName string, data string)
- type FileSystemer
- type GithubUtil
- type Githuber
- type MainTFTemplate
- type NewAPIClientInput
- type PromptUtil
- type Prompter
- type Sig4RoundTripper
- type TFTemplater
- type TFVar
- type TerraformBinDownloader
- type TerraformBinFileSystemUtil
- type TerraformBinUtil
- type Terraformer
- 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
func ParseOptions ¶ added in v0.4.0
ParseOptions parses the given options into an array of strings. It provides for any whitespace between the options.
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) DeleteLeasesID(*operations.DeleteLeasesIDParams, runtime.ClientAuthInfoWriter) (*operations.DeleteLeasesIDOK, error) GetAccounts(*operations.GetAccountsParams, runtime.ClientAuthInfoWriter) (*operations.GetAccountsOK, error) GetAccountsID(*operations.GetAccountsIDParams, runtime.ClientAuthInfoWriter) (*operations.GetAccountsIDOK, error) GetAuth(*operations.GetAuthParams) (*operations.GetAuthOK, error) GetAuthFile(*operations.GetAuthFileParams) (*operations.GetAuthFileOK, 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) PostLeasesAuth(*operations.PostLeasesAuthParams, runtime.ClientAuthInfoWriter) (*operations.PostLeasesAuthCreated, error) PostLeasesIDAuth(*operations.PostLeasesIDAuthParams, runtime.ClientAuthInfoWriter) (*operations.PostLeasesIDAuthCreated, error) PutAccountsID(*operations.PutAccountsIDParams, runtime.ClientAuthInfoWriter) (*operations.PutAccountsIDOK, 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 (u *AWSUtil) ConfigureAWSCLICredentials(accessKeyID, secretAccessKey, sessionToken, profile string)
ConfigureAWSCLICredentials sets credential values in the credentials config file used by the aws cli Care should be taken to mitigate CWE-78 (https://cwe.mitre.org/data/definitions/78.html) by ensuring inputs come from a trusted source.
func (*AWSUtil) UpdateLambdasFromS3Assets ¶
func (*AWSUtil) UploadDirectoryToS3 ¶
func (u *AWSUtil) UploadDirectoryToS3(localPath string, bucket string, prefix string) ([]string, []string)
UploadDirectoryToS3 uploads the contents of a directory to S3 Care should be taken when using this function to mitigate CWE-22 (https://cwe.mitre.org/data/definitions/22.html) i.e. ensure `localPath` comes from a trusted source.
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 Durationer interface { ExpandEpochTime(str string) (int64, error) ParseDuration(str string) (time.Duration, error) }
Durationer is an interface for exanding strings into times.
type FileSystemUtil ¶
func (*FileSystemUtil) ChToConfigDir ¶ added in v0.4.0
func (u *FileSystemUtil) ChToConfigDir() (string, string)
func (*FileSystemUtil) ChToTmpDir ¶ added in v0.4.0
func (u *FileSystemUtil) ChToTmpDir() (string, string)
func (*FileSystemUtil) Chdir ¶
func (u *FileSystemUtil) Chdir(path string)
func (*FileSystemUtil) CreateConfigDirTree ¶ added in v0.4.0
func (u *FileSystemUtil) CreateConfigDirTree(dceVersion string) error
CreateConfigDirTree creates all the dirs in the dir specified by GetConfigDir(), including the dir itself.
func (*FileSystemUtil) GetArtifactsDir ¶ added in v0.4.0
func (u *FileSystemUtil) GetArtifactsDir(dceVersion string) string
GetArtifactsDir returns the cached artifacts dir, which by default is `~/.dce/.cache/dce/${DCE_VERSION}/`
func (*FileSystemUtil) GetCacheDir ¶ added in v0.4.0
func (u *FileSystemUtil) GetCacheDir() string
func (*FileSystemUtil) GetConfigDir ¶ added in v0.4.0
func (u *FileSystemUtil) GetConfigDir() string
func (*FileSystemUtil) GetConfigFile ¶
func (u *FileSystemUtil) GetConfigFile() string
func (*FileSystemUtil) GetHomeDir ¶
func (u *FileSystemUtil) GetHomeDir() string
func (*FileSystemUtil) GetLocalMainTFFile ¶ added in v0.4.0
func (u *FileSystemUtil) GetLocalMainTFFile() string
GetLocalBackendFile returns the full path of the local backend file.
func (*FileSystemUtil) GetLocalTFModuleDir ¶ added in v0.4.0
func (u *FileSystemUtil) GetLocalTFModuleDir() string
GetLocalBackendDir returns the dir for the local terraform backend. By default, `~/.dce/.cache/module`
func (*FileSystemUtil) GetLogFile ¶ added in v0.4.0
func (u *FileSystemUtil) GetLogFile() string
GetLogFile returns the full path of the log file for the deployment messages.
func (*FileSystemUtil) GetTerraformBin ¶ added in v0.4.0
func (u *FileSystemUtil) GetTerraformBin() string
GetTerraformBin returns the full path of the terraform binary.
func (*FileSystemUtil) GetTerraformBinDir ¶ added in v0.4.0
func (u *FileSystemUtil) GetTerraformBinDir() string
GetTerraformBinDir returns the dir in which the `terraform` bin is installed, which by default is `~/.dce/.cache/terraform/${TERRAFORM_VERSION}`
func (*FileSystemUtil) GetTerraformStateFile ¶ added in v0.4.0
func (u *FileSystemUtil) GetTerraformStateFile() string
GetTerraformStateFile returns the full path of the terraform state file
func (*FileSystemUtil) IsExistingFile ¶
func (u *FileSystemUtil) IsExistingFile(path string) bool
func (*FileSystemUtil) OpenFileWriter ¶ added in v0.4.0
func (u *FileSystemUtil) OpenFileWriter(path string) (*os.File, error)
OpenFileWriter opens or creates a file in write-only mode. Data is appended to the file when writing. The file permissions are set to 0644, i.e. user-executable and user/group/other-readable.
func (*FileSystemUtil) ReadFromFile ¶
func (u *FileSystemUtil) ReadFromFile(path string) string
ReadFromFile returns the contents of a file as a string Care should be taken when using this function to prevent CWE-22 (https://cwe.mitre.org/data/definitions/22.html) i.e. ensure `path` comes from a trusted source.
func (*FileSystemUtil) ReadInConfig ¶
func (u *FileSystemUtil) ReadInConfig() error
ReadInConfig loads the configuration from the configuration file 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) error
func (*FileSystemUtil) WriteConfig ¶
func (u *FileSystemUtil) WriteConfig() error
WriteConfig writes the Config objects as YAML to the config file location
func (*FileSystemUtil) WriteFile ¶
func (u *FileSystemUtil) WriteFile(fileName string, data string)
type FileSystemer ¶
type FileSystemer interface { WriteConfig() error IsExistingFile(path string) bool ReadFromFile(path string) string ReadInConfig() error Unarchive(source string, destination string) error ChToConfigDir() (string, string) ChToTmpDir() (string, string) RemoveAll(path string) Chdir(path string) ReadDir(path string) []os.FileInfo WriteFile(fileName string, data string) OpenFileWriter(path string) (*os.File, error) // GetHomeDir returns the user home dir. For example, on *nix systems this // be the same as `~` expanded, or the value of `$HOME` GetHomeDir() string // GetConfigDir returns the DCE configuration dir, which on *nix systems // is `~/.dce` GetConfigDir() string // GetCacheDir returns the local cache dir, which bt default is `~/.dce/.cache` GetCacheDir() string // GetArtifactsDir returns the cached artifacts dir, which by default is // `~/.dce/.cache/dce/${DCE_VERSION}/` GetArtifactsDir(dceVersion string) string // GetTerraformBinDir returns the dir in which the `terraform` bin is installed, // which by default is `~/.dce/.cache/terraform/${TERRAFORM_VERSION}` GetTerraformBinDir() string // GetLocalBackendDir returns the dir for the local terraform backend. // By default, `~/.dce/.cache/module` GetLocalTFModuleDir() string // CreateConfigDirTree creates all the dirs in the dir specified by GetConfigDir(), // including the dir itself. CreateConfigDirTree(dceVersion string) error // GetConfigFile returns the full path of the configuration file, such as // `~/.dce/config.yaml` GetConfigFile() string // GetLogFile returns the full path of the log file for the deployment messages. GetLogFile() string // GetLocalBackendFile returns the full path of the local backend file. GetLocalMainTFFile() string // GetTerraformBin returns the full path of the terraform binary. GetTerraformBin() string // GetTerraformStateFile returns the full path of the terraform state file GetTerraformStateFile() string }
type GithubUtil ¶
type GithubUtil struct { Config *configs.Root Observation *observ.ObservationContainer }
func (*GithubUtil) DownloadGithubReleaseAsset ¶
func (u *GithubUtil) DownloadGithubReleaseAsset(assetName string, releaseName string) error
type MainTFTemplate ¶ added in v0.4.0
type MainTFTemplate struct { TFVars []TFVar LocalBackend bool LocalTFStateFilePath string TFWorkspaceDir string // DCE terraform module source location ModuleSource string }
MainTFTemplate is the template for writing the main.tf file
func NewMainTFTemplate ¶ added in v0.4.0
func NewMainTFTemplate(fs FileSystemer) *MainTFTemplate
NewMainTFTemplate creates a new instance of the MainTFTemplate
func (*MainTFTemplate) AddVariable ¶ added in v0.4.0
func (t *MainTFTemplate) AddVariable(name string, vartype string, val string) error
AddVariable adds a variable with the given `name`, variable type (`vartype`), and default value (`vardefault`) to the template
func (*MainTFTemplate) SetModuleSource ¶ added in v0.5.0
func (t *MainTFTemplate) SetModuleSource(source 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 TFTemplater ¶ added in v0.4.0
type TFTemplater interface { // Add a terraform variable to the template AddVariable(name string, vartype string, vardefault string) error // Set the source path to the DCE terraform module SetModuleSource(source string) Write(w io.Writer) error }
TFTemplater is an interface for the templater that generates the main.tf file.
type TerraformBinDownloader ¶ added in v0.4.0
TerraformBinDownloader - interface for the downloader to download the Terraform binary from a URL ans save it locally.
type TerraformBinFileSystemUtil ¶ added in v0.4.0
type TerraformBinFileSystemUtil interface { GetConfigDir() string IsExistingFile(path string) bool OpenFileWriter(path string) (*os.File, error) Unarchive(source string, destination string) error GetTerraformBin() string RemoveAll(path string) GetTerraformBinDir() string GetLocalTFModuleDir() string }
TerraformBinFileSystemUtil - interface for interacting with the file system.
type TerraformBinUtil ¶ added in v0.4.0
type TerraformBinUtil struct { Config *configs.Root Observation *observ.ObservationContainer FileSystem TerraformBinFileSystemUtil Downloader TerraformBinDownloader }
TerraformBinUtil uses the Teraform binary to peform the init and apply
func (*TerraformBinUtil) Apply ¶ added in v0.4.0
func (t *TerraformBinUtil) Apply(ctx context.Context, args []string) error
Apply will call `terraform apply` with the given vars.
type Terraformer ¶
type UtilContainer ¶
type UtilContainer struct { Config *configs.Root // File path location of the configuration 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 TFTemplater }
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) Download ¶ added in v0.4.0
Download will download the file at the given `url` and save it to the `localpath` Care should be taken to mitigate CWE-88 (https://cwe.mitre.org/data/definitions/88.html) by ensuring inputs comes from a trusted source.