fix force-copy
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
diff --git a/tfexec/init.go b/tfexec/init.go
index bff9ecd..8fd3667 100644
--- a/tfexec/init.go
+++ b/tfexec/init.go
@@ -52,6 +52,10 @@
conf.dir = opt.path
}
+func (opt *ForceCopyOption) configureInit(conf *initConfig) {
+ conf.forceCopy = opt.forceCopy
+}
+
func (opt *FromModuleOption) configureInit(conf *initConfig) {
conf.fromModule = opt.source
}
@@ -116,7 +120,7 @@
o.configureInit(&c)
}
- args := []string{"init", "-no-color", "-force-copy", "-input=false"}
+ args := []string{"init", "-no-color", "-input=false"}
// string opts: only pass if set
if c.fromModule != "" {
@@ -144,6 +148,10 @@
args = append(args, "-verify-plugins="+fmt.Sprint(c.verifyPlugins))
}
+ if c.forceCopy {
+ args = append(args, "-force-copy")
+ }
+
// unary flags: pass if true
if c.reconfigure {
args = append(args, "-reconfigure")
diff --git a/tfexec/init_test.go b/tfexec/init_test.go
index 850f36f..4d1a7fd 100644
--- a/tfexec/init_test.go
+++ b/tfexec/init_test.go
@@ -33,7 +33,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-lock-timeout=0s",
"-backend=true",
@@ -46,7 +45,7 @@
})
t.Run("override all defaults", func(t *testing.T) {
- initCmd, err := tf.initCmd(context.Background(), Backend(false), BackendConfig("confpath1"), BackendConfig("confpath2"), FromModule("testsource"), Get(false), GetPlugins(false), Lock(false), LockTimeout("999s"), PluginDir("testdir1"), PluginDir("testdir2"), Reconfigure(true), Upgrade(true), VerifyPlugins(false), Dir("initdir"))
+ initCmd, err := tf.initCmd(context.Background(), Backend(false), BackendConfig("confpath1"), BackendConfig("confpath2"), ForceCopy(true), FromModule("testsource"), Get(false), GetPlugins(false), Lock(false), LockTimeout("999s"), PluginDir("testdir1"), PluginDir("testdir2"), Reconfigure(true), Upgrade(true), VerifyPlugins(false), Dir("initdir"))
if err != nil {
t.Fatal(err)
}
@@ -54,7 +53,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-from-module=testsource",
"-lock-timeout=999s",
@@ -64,6 +62,7 @@
"-lock=false",
"-get-plugins=false",
"-verify-plugins=false",
+ "-force-copy",
"-reconfigure",
"-backend-config=confpath1",
"-backend-config=confpath2",
@@ -95,7 +94,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -112,7 +110,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-from-module=testsource",
"-backend=false",
diff --git a/tfexec/terraform_test.go b/tfexec/terraform_test.go
index 7991991..79338ea 100644
--- a/tfexec/terraform_test.go
+++ b/tfexec/terraform_test.go
@@ -117,7 +117,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -155,7 +154,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -193,7 +191,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -262,7 +259,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -300,7 +296,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -338,7 +333,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -381,7 +375,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -413,7 +406,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -463,7 +455,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -513,7 +504,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -582,7 +572,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -620,7 +609,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -658,7 +646,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -708,7 +695,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-lock-timeout=0s",
"-backend=true",
@@ -740,7 +726,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-lock-timeout=0s",
"-backend=true",
@@ -787,7 +772,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",
@@ -815,7 +799,6 @@
assertCmd(t, []string{
"init",
"-no-color",
- "-force-copy",
"-input=false",
"-backend=true",
"-get=true",