diff --git a/cmd/deploy/main.go b/cmd/deploy/main.go index b94d443..2b015b0 100644 --- a/cmd/deploy/main.go +++ b/cmd/deploy/main.go @@ -5,6 +5,7 @@ import ( "errors" "os/exec" "strings" + "time" "github.com/hashicorp/go-tfe" "github.com/jessevdk/go-flags" @@ -41,7 +42,7 @@ func main() { return } - deployer, err := getDeployer(opts.TFToken, opts.Organization, opts.Workspace, log) + deployer, err := getDeployer(opts.TFToken, opts.Organization, opts.Workspace, log, opts.Timeout) if err != nil { log.Fatal("Could not create deployer", zap.Error(err)) } @@ -52,7 +53,7 @@ func main() { } } -func getDeployer(token, organization, workspace string, log *zap.Logger) (*deployer.Deployer, error) { +func getDeployer(token, organization, workspace string, log *zap.Logger, timeout time.Duration) (*deployer.Deployer, error) { tfc, err := tfe.NewClient(&tfe.Config{ Token: token, }) @@ -64,6 +65,7 @@ func getDeployer(token, organization, workspace string, log *zap.Logger) (*deplo return deployer.NewDeployer(context.Background(), log, tfc, &deployer.Config{ Organization: organization, Workspace: workspace, + WaitTimeout: timeout, }) } diff --git a/pkg/options/options.go b/pkg/options/options.go index 01484e8..61751b8 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -1,12 +1,15 @@ package options +import "time" + type Options struct { - TFToken string `short:"t" long:"terraform-token" env:"TERRAFORM_TOKEN" description:"Terraform API token"` - Workspace string `short:"w" long:"workspace" env:"TERRAFORM_WORKSPACE" description:"Terraform Workspace"` - Organization string `short:"o" long:"org" env:"TERRAFORM_ORGANIZATION" description:"Terraform Organization"` - VariableName string `short:"n" long:"variable-name" env:"TERRAFORM_VARIABLE_NAME" description:"Terraform Variable Name"` - VariableValue string `short:"v" long:"variable-value" env:"TERRAFORM_VARIABLE_VALUE" description:"Value to set for the Terraform Variable named in VariableName"` - RunTitle string `long:"run-title" env:"TERRAFORM_RUN_TITLE" description:"Title for the Terraform Run. Defaults to latest commit message if unset."` - DryRun bool `long:"dry-run" description:"Do not actually run the Terraform Run. Useful for testing."` - VariableValueRequiredPrefix string `long:"variable-value-required-prefix" env:"VARIABLE_VALUE_REQUIRED_PREFIX" description:"If set, the VariableValue must start with this prefix"` + TFToken string `short:"t" long:"terraform-token" env:"TERRAFORM_TOKEN" description:"Terraform API token"` + Workspace string `short:"w" long:"workspace" env:"TERRAFORM_WORKSPACE" description:"Terraform Workspace"` + Organization string `short:"o" long:"org" env:"TERRAFORM_ORGANIZATION" description:"Terraform Organization"` + VariableName string `short:"n" long:"variable-name" env:"TERRAFORM_VARIABLE_NAME" description:"Terraform Variable Name"` + VariableValue string `short:"v" long:"variable-value" env:"TERRAFORM_VARIABLE_VALUE" description:"Value to set for the Terraform Variable named in VariableName"` + RunTitle string `long:"run-title" env:"TERRAFORM_RUN_TITLE" description:"Title for the Terraform Run. Defaults to latest commit message if unset."` + DryRun bool `long:"dry-run" description:"Do not actually run the Terraform Run. Useful for testing."` + VariableValueRequiredPrefix string `long:"variable-value-required-prefix" env:"VARIABLE_VALUE_REQUIRED_PREFIX" description:"If set, the VariableValue must start with this prefix"` + Timeout time.Duration `long:"timeout" description:"Run timeout"` }