|
|
|
|
@ -16,6 +16,14 @@ type ImportCommand struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *ImportCommand) Run(args []string) int {
|
|
|
|
|
// Get the pwd since its our default -config flag value
|
|
|
|
|
pwd, err := os.Getwd()
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error getting pwd: %s", err))
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var configPath string
|
|
|
|
|
args = c.Meta.process(args, true)
|
|
|
|
|
|
|
|
|
|
cmdFlags := c.Meta.flagSet("import")
|
|
|
|
|
@ -23,6 +31,7 @@ func (c *ImportCommand) Run(args []string) int {
|
|
|
|
|
cmdFlags.StringVar(&c.Meta.statePath, "state", DefaultStateFilename, "path")
|
|
|
|
|
cmdFlags.StringVar(&c.Meta.stateOutPath, "state-out", "", "path")
|
|
|
|
|
cmdFlags.StringVar(&c.Meta.backupPath, "backup", "", "path")
|
|
|
|
|
cmdFlags.StringVar(&configPath, "config", pwd, "path")
|
|
|
|
|
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
|
|
|
|
|
if err := cmdFlags.Parse(args); err != nil {
|
|
|
|
|
return 1
|
|
|
|
|
@ -35,15 +44,9 @@ func (c *ImportCommand) Run(args []string) int {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pwd, err := os.Getwd()
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error getting pwd: %s", err))
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build the context based on the arguments given
|
|
|
|
|
ctx, _, err := c.Context(contextOpts{
|
|
|
|
|
Path: pwd,
|
|
|
|
|
Path: configPath,
|
|
|
|
|
PathEmptyOk: true,
|
|
|
|
|
StatePath: c.Meta.statePath,
|
|
|
|
|
Parallelism: c.Meta.parallelism,
|
|
|
|
|
@ -120,6 +123,11 @@ Options:
|
|
|
|
|
modifying. Defaults to the "-state-out" path with
|
|
|
|
|
".backup" extension. Set to "-" to disable backup.
|
|
|
|
|
|
|
|
|
|
-config=path Path to a directory of Terraform configuration files
|
|
|
|
|
to use to configure the provider. Defaults to pwd.
|
|
|
|
|
If no config files are present, they must be provided
|
|
|
|
|
via the input prompts or env vars.
|
|
|
|
|
|
|
|
|
|
-input=true Ask for input for variables if not directly set.
|
|
|
|
|
|
|
|
|
|
-no-color If specified, output won't contain any color.
|
|
|
|
|
|