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(&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.

View File

@ -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
}