From f59c71b35a3c671208bf2ceaa84e9be5a48929aa Mon Sep 17 00:00:00 2001 From: Kevin Nuckolls Date: Wed, 6 May 2015 10:58:42 -0500 Subject: [PATCH] works for apply, no tests yet --- command/apply.go | 10 +++++++--- command/meta.go | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/command/apply.go b/command/apply.go index f924c65ca..232b44b82 100644 --- a/command/apply.go +++ b/command/apply.go @@ -39,6 +39,7 @@ func (c *ApplyCommand) Run(args []string) int { cmdFlags.BoolVar(&destroyForce, "force", false, "force") } 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.stateOutPath, "state-out", "", "path") cmdFlags.StringVar(&c.Meta.backupPath, "backup", "", "path") @@ -94,9 +95,10 @@ func (c *ApplyCommand) Run(args []string) int { // Build the context based on the arguments given ctx, planned, err := c.Context(contextOpts{ - Destroy: c.Destroy, - Path: configPath, - StatePath: c.Meta.statePath, + Destroy: c.Destroy, + Path: configPath, + StatePath: c.Meta.statePath, + Parallelism: c.Meta.parallelism, }) if err != nil { c.Ui.Error(err.Error()) @@ -278,6 +280,8 @@ Options: -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 has no effect if a plan file is given to apply. diff --git a/command/meta.go b/command/meta.go index 4c1c09afe..af4a52302 100644 --- a/command/meta.go +++ b/command/meta.go @@ -59,9 +59,13 @@ type Meta struct { // // backupPath is used to backup the state file before writing a modified // version. It defaults to stateOutPath + DefaultBackupExtension + // + // parallelism is used to control the number of concurrent operations + // allowed when walking the graph statePath string stateOutPath string backupPath string + parallelism int } // 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.Parallelism = copts.Parallelism opts.State = state.State() ctx := terraform.NewContext(opts) return ctx, false, nil @@ -430,4 +435,7 @@ type contextOpts struct { // Set to true when running a destroy plan/apply. Destroy bool + + // Number of concurrent operations allowed + Parallelism int }