func()

in cmd/migrate_command.go [44:89]


func (c *MigrateCommand) Run(args []string) int {
	// AzureRM provider will honor env.var "AZURE_HTTP_USER_AGENT" when constructing for HTTP "User-Agent" header.
	// #nosec G104
	_ = os.Setenv("AZURE_HTTP_USER_AGENT", "mig")
	// The following env.vars are used to disable enhanced validation and skip provider registration, to speed up the process.
	// #nosec G104
	_ = os.Setenv("ARM_PROVIDER_ENHANCED_VALIDATION", "false")
	// #nosec G104
	_ = os.Setenv("ARM_SKIP_PROVIDER_REGISTRATION", "true")
	f := c.flags()
	if err := f.Parse(args); err != nil {
		c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s", err))
		return 1
	}

	if c.TargetProvider == "" {
		c.TargetProvider = "azurerm"
	}
	if c.TargetProvider != "azapi" && c.TargetProvider != "azurerm" {
		c.Ui.Error("Invalid target provider. The allowed values are: azurerm and azapi.")
		return 1
	}

	if c.workingDir == "" {
		c.workingDir, _ = os.Getwd()
	}
	log.Printf("[INFO] working directory: %s", c.workingDir)

	log.Printf("[INFO] initializing terraform...")
	terraform, err := tf.NewTerraform(c.workingDir, c.Verbose)
	if err != nil {
		log.Fatal(err)
	}

	planCommand := &PlanCommand{ //nolint
		Ui:             c.Ui,
		Verbose:        c.Verbose,
		Strict:         c.Strict,
		workingDir:     c.workingDir,
		varFile:        c.varFile,
		TargetProvider: c.TargetProvider,
	}
	allResources := planCommand.Plan(terraform, false)
	c.MigrateResources(terraform, allResources)
	return 0
}