command: UI for import
This commit is contained in:
parent
126eb23864
commit
f6a59734ef
|
@ -251,6 +251,34 @@ func (h *UiHook) PreRefresh(
|
||||||
return terraform.HookActionContinue, nil
|
return terraform.HookActionContinue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *UiHook) PreImportState(
|
||||||
|
n *terraform.InstanceInfo) (terraform.HookAction, error) {
|
||||||
|
h.once.Do(h.init)
|
||||||
|
|
||||||
|
id := n.HumanId()
|
||||||
|
h.ui.Output(h.Colorize.Color(fmt.Sprintf(
|
||||||
|
"[reset][bold]%s: Importing from ID %q...",
|
||||||
|
id, n.Id)))
|
||||||
|
return terraform.HookActionContinue, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *UiHook) PostImportState(
|
||||||
|
n *terraform.InstanceInfo,
|
||||||
|
s []*terraform.InstanceState) (terraform.HookAction, error) {
|
||||||
|
h.once.Do(h.init)
|
||||||
|
|
||||||
|
id := n.HumanId()
|
||||||
|
h.ui.Output(h.Colorize.Color(fmt.Sprintf(
|
||||||
|
"[reset][bold][green]%s: Import complete!", id)))
|
||||||
|
for _, s := range s {
|
||||||
|
h.ui.Output(h.Colorize.Color(fmt.Sprintf(
|
||||||
|
"[reset][green] Imported %s (ID: %s)",
|
||||||
|
s.Ephemeral.Type, s.ID)))
|
||||||
|
}
|
||||||
|
|
||||||
|
return terraform.HookActionContinue, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (h *UiHook) init() {
|
func (h *UiHook) init() {
|
||||||
if h.Colorize == nil {
|
if h.Colorize == nil {
|
||||||
panic("colorize not given")
|
panic("colorize not given")
|
||||||
|
|
|
@ -67,6 +67,14 @@ func (c *ImportCommand) Run(args []string) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.Ui.Output(c.Colorize().Color(fmt.Sprintf(
|
||||||
|
"[reset][green]\n" +
|
||||||
|
"Import success! The resources imported are shown above. These are\n" +
|
||||||
|
"now in your Terraform state. Import does not currently generate\n" +
|
||||||
|
"configuration, so you must do this next. If you do not create configuration\n" +
|
||||||
|
"for the above resources, then the next `terraform plan` will mark\n" +
|
||||||
|
"them for destruction.")))
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue