works for apply, no tests yet

This commit is contained in:
Kevin Nuckolls 2015-05-06 10:58:42 -05:00 committed by Joseph Anthony Pasquale Holsten
parent 0c3f2a915c
commit f59c71b35a
2 changed files with 15 additions and 3 deletions

View File

@ -39,6 +39,7 @@ func (c *ApplyCommand) Run(args []string) int {
cmdFlags.BoolVar(&destroyForce, "force", false, "force") cmdFlags.BoolVar(&destroyForce, "force", false, "force")
} }
cmdFlags.BoolVar(&refresh, "refresh", true, "refresh") cmdFlags.BoolVar(&refresh, "refresh", true, "refresh")
cmdFlags.IntVar(&c.Meta.parallelism, "parallelism", 0, "parallelism")
cmdFlags.StringVar(&c.Meta.statePath, "state", DefaultStateFilename, "path") cmdFlags.StringVar(&c.Meta.statePath, "state", DefaultStateFilename, "path")
cmdFlags.StringVar(&c.Meta.stateOutPath, "state-out", "", "path") cmdFlags.StringVar(&c.Meta.stateOutPath, "state-out", "", "path")
cmdFlags.StringVar(&c.Meta.backupPath, "backup", "", "path") cmdFlags.StringVar(&c.Meta.backupPath, "backup", "", "path")
@ -97,6 +98,7 @@ func (c *ApplyCommand) Run(args []string) int {
Destroy: c.Destroy, Destroy: c.Destroy,
Path: configPath, Path: configPath,
StatePath: c.Meta.statePath, StatePath: c.Meta.statePath,
Parallelism: c.Meta.parallelism,
}) })
if err != nil { if err != nil {
c.Ui.Error(err.Error()) c.Ui.Error(err.Error())
@ -278,6 +280,8 @@ Options:
-no-color If specified, output won't contain any color. -no-color If specified, output won't contain any color.
-parallelism=# Limit the number of concurrent operations.
-refresh=true Update state prior to checking for differences. This -refresh=true Update state prior to checking for differences. This
has no effect if a plan file is given to apply. has no effect if a plan file is given to apply.

View File

@ -59,9 +59,13 @@ type Meta struct {
// //
// backupPath is used to backup the state file before writing a modified // backupPath is used to backup the state file before writing a modified
// version. It defaults to stateOutPath + DefaultBackupExtension // version. It defaults to stateOutPath + DefaultBackupExtension
//
// parallelism is used to control the number of concurrent operations
// allowed when walking the graph
statePath string statePath string
stateOutPath string stateOutPath string
backupPath string backupPath string
parallelism int
} }
// initStatePaths is used to initialize the default values for // initStatePaths is used to initialize the default values for
@ -151,6 +155,7 @@ func (m *Meta) Context(copts contextOpts) (*terraform.Context, bool, error) {
} }
opts.Module = mod opts.Module = mod
opts.Parallelism = copts.Parallelism
opts.State = state.State() opts.State = state.State()
ctx := terraform.NewContext(opts) ctx := terraform.NewContext(opts)
return ctx, false, nil return ctx, false, nil
@ -430,4 +435,7 @@ type contextOpts struct {
// Set to true when running a destroy plan/apply. // Set to true when running a destroy plan/apply.
Destroy bool Destroy bool
// Number of concurrent operations allowed
Parallelism int
} }