-
Notifications
You must be signed in to change notification settings - Fork 36
/
terraform_command.go
82 lines (61 loc) · 1.55 KB
/
terraform_command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package command
import (
"fmt"
)
func NewInit(pluginDir string) TerraformCommand {
return initCommand{pluginDir: pluginDir}
}
type initCommand struct {
pluginDir string
}
func (cmd initCommand) Command() []string {
return []string{"init", fmt.Sprintf("-plugin-dir=%s", cmd.pluginDir), "-no-color"}
}
type apply struct{}
func NewApply() TerraformCommand {
return apply{}
}
func (apply) Command() []string {
return []string{"apply", "-auto-approve", "-no-color"}
}
func NewDestroy() TerraformCommand {
return destroy{}
}
type destroy struct{}
func (destroy) Command() []string {
return []string{"destroy", "-auto-approve", "-no-color"}
}
func NewShow() TerraformCommand {
return show{}
}
type show struct{}
func (show) Command() []string {
return []string{"show", "-no-color"}
}
func NewPlan() TerraformCommand {
return plan{}
}
type plan struct{}
func (plan) Command() []string {
return []string{"plan", "-no-color"}
}
func NewImport(addr, id string) TerraformCommand {
return importCmd{Addr: addr, ID: id}
}
type importCmd struct {
Addr string
ID string
}
func (cmd importCmd) Command() []string {
return []string{"import", cmd.Addr, cmd.ID}
}
type renameProvider struct {
oldProviderName string
newProviderName string
}
func (cmd renameProvider) Command() []string {
return []string{"state", "replace-provider", "-auto-approve", cmd.oldProviderName, cmd.newProviderName}
}
func NewRenameProvider(oldProviderName, newProviderName string) TerraformCommand {
return renameProvider{oldProviderName: oldProviderName, newProviderName: newProviderName}
}