Documentation ¶
Overview ¶
Copyright 2017 HootSuite Media Inc.
Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.
Package terraform handles the actual running of terraform commands.
Index ¶
- Variables
- func MustConstraint(v string) version.Constraints
- type Client
- type DefaultClient
- func NewClient(log logging.SimpleLogging, binDir string, cacheDir string, tfeToken string, ...) (*DefaultClient, error)
- func NewClientWithDefaultVersion(log logging.SimpleLogging, binDir string, cacheDir string, tfeToken string, ...) (*DefaultClient, error)
- func NewTestClient(log logging.SimpleLogging, binDir string, cacheDir string, tfeToken string, ...) (*DefaultClient, error)
- func (c *DefaultClient) DefaultVersion() *version.Version
- func (c *DefaultClient) DetectVersion(log logging.SimpleLogging, projectDirectory string) *version.Version
- func (c *DefaultClient) EnsureVersion(log logging.SimpleLogging, v *version.Version) error
- func (c *DefaultClient) ListAvailableVersions(log logging.SimpleLogging) ([]string, error)
- func (c *DefaultClient) RunCommandAsync(ctx command.ProjectContext, path string, args []string, ...) (chan<- string, <-chan models.Line)
- func (c *DefaultClient) RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, ...) (string, error)
- func (c *DefaultClient) TerraformBinDir() string
- type DefaultDownloader
- type Downloader
Constants ¶
This section is empty.
Variables ¶
var LogStreamingValidCmds = [...]string{"init", "plan", "apply"}
Functions ¶
func MustConstraint ¶
func MustConstraint(v string) version.Constraints
MustConstraint will parse one or more constraints from the given constraint string. The string must be a comma-separated list of constraints. It panics if there is an error.
Types ¶
type Client ¶
type Client interface { // RunCommandWithVersion executes terraform with args in path. If v is nil, // it will use the default Terraform version. workspace is the Terraform // workspace which should be set as an environment variable. RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (string, error) // EnsureVersion makes sure that terraform version `v` is available to use EnsureVersion(log logging.SimpleLogging, v *version.Version) error // ListAvailableVersions returns all available version of Terraform, if available; otherwise this will return an empty list. ListAvailableVersions(log logging.SimpleLogging) ([]string, error) // DetectVersion Extracts required_version from Terraform configuration in the specified project directory. Returns nil if unable to determine the version. DetectVersion(log logging.SimpleLogging, projectDirectory string) *version.Version }
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient( log logging.SimpleLogging, binDir string, cacheDir string, tfeToken string, tfeHostname string, defaultVersionStr string, defaultVersionFlagName string, tfDownloadURL string, tfDownloader Downloader, tfDownloadAllowed bool, usePluginCache bool, projectCmdOutputHandler jobs.ProjectCommandOutputHandler, ) (*DefaultClient, error)
NewClient constructs a terraform client. tfeToken is an optional terraform enterprise token. defaultVersionStr is an optional default terraform version to use unless a specific version is set. defaultVersionFlagName is the name of the flag that sets the default terraform version. tfDownloader is used to download terraform versions. Will asynchronously download the required version if it doesn't exist already.
func NewClientWithDefaultVersion ¶
func NewClientWithDefaultVersion( log logging.SimpleLogging, binDir string, cacheDir string, tfeToken string, tfeHostname string, defaultVersionStr string, defaultVersionFlagName string, tfDownloadURL string, tfDownloader Downloader, tfDownloadAllowed bool, usePluginCache bool, fetchAsync bool, projectCmdOutputHandler jobs.ProjectCommandOutputHandler, ) (*DefaultClient, error)
NewClientWithDefaultVersion creates a new terraform client and pre-fetches the default version
func NewTestClient ¶
func NewTestClient( log logging.SimpleLogging, binDir string, cacheDir string, tfeToken string, tfeHostname string, defaultVersionStr string, defaultVersionFlagName string, tfDownloadURL string, tfDownloader Downloader, tfDownloadAllowed bool, usePluginCache bool, projectCmdOutputHandler jobs.ProjectCommandOutputHandler, ) (*DefaultClient, error)
func (*DefaultClient) DefaultVersion ¶
func (c *DefaultClient) DefaultVersion() *version.Version
Version returns the default version of Terraform we use if no other version is defined.
func (*DefaultClient) DetectVersion ¶ added in v0.22.0
func (c *DefaultClient) DetectVersion(log logging.SimpleLogging, projectDirectory string) *version.Version
DetectVersion Extracts required_version from Terraform configuration in the specified project directory. Returns nil if unable to determine the version. This will also try to intelligently evaluate non-exact matches by listing the available versions of Terraform and picking the best match.
func (*DefaultClient) EnsureVersion ¶
func (c *DefaultClient) EnsureVersion(log logging.SimpleLogging, v *version.Version) error
See Client.EnsureVersion.
func (*DefaultClient) ListAvailableVersions ¶ added in v0.22.0
func (c *DefaultClient) ListAvailableVersions(log logging.SimpleLogging) ([]string, error)
ListAvailableVersions returns all available version of Terraform. If downloads are not allowed, this will return an empty list.
func (*DefaultClient) RunCommandAsync ¶
func (c *DefaultClient) RunCommandAsync(ctx command.ProjectContext, path string, args []string, customEnvVars map[string]string, v *version.Version, workspace string) (chan<- string, <-chan models.Line)
RunCommandAsync runs terraform with args. It immediately returns an input and output channel. Callers can use the output channel to get the realtime output from the command. Callers can use the input channel to pass stdin input to the command. If any error is passed on the out channel, there will be no further output (so callers are free to exit).
func (*DefaultClient) RunCommandWithVersion ¶
func (c *DefaultClient) RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, customEnvVars map[string]string, v *version.Version, workspace string) (string, error)
See Client.RunCommandWithVersion.
func (*DefaultClient) TerraformBinDir ¶
func (c *DefaultClient) TerraformBinDir() string
TerraformBinDir returns the directory where we download Terraform binaries.
type DefaultDownloader ¶
type DefaultDownloader struct{}
func (*DefaultDownloader) GetAny ¶
func (d *DefaultDownloader) GetAny(dst, src string) error
See go-getter.GetFile.
func (*DefaultDownloader) GetFile ¶
func (d *DefaultDownloader) GetFile(dst, src string) error
See go-getter.GetFile.