deprecate helper/copy
helper/copy CopyDir was used heavily in tests. It differes from internal/copydir in a few ways, the main one being that it creates the dst directory while the internal version expected the dst to exist (there are other differences, which is why I did not just switch tests to using internal's CopyDir). I moved the CopyDir func from helper/copy into command_test.go; I could also have moved it into internal/copy and named it something like CreateDirAndCopy so if that seems like a better option please let me know. helper/copy/CopyFile was used in a couple of spots so I moved it into internal, at which point I thought it made more sense to rename the package copy (instead of copydir). There's also a `go mod tidy` included.
This commit is contained in:
parent
f4324a384e
commit
04be220f5f
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/hashicorp/terraform/configs/configload"
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/helper/logging"
|
||||
"github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/plans"
|
||||
"github.com/hashicorp/terraform/plans/planfile"
|
||||
"github.com/hashicorp/terraform/providers"
|
||||
|
@ -893,6 +894,71 @@ func testLockState(sourceDir, path string) (func(), error) {
|
|||
return deferFunc, nil
|
||||
}
|
||||
|
||||
// testCopyDir recursively copies a directory tree, attempting to preserve
|
||||
// permissions. Source directory must exist, destination directory must *not*
|
||||
// exist. Symlinks are ignored and skipped.
|
||||
func testCopyDir(t *testing.T, src, dst string) {
|
||||
t.Helper()
|
||||
|
||||
src = filepath.Clean(src)
|
||||
dst = filepath.Clean(dst)
|
||||
|
||||
si, err := os.Stat(src)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !si.IsDir() {
|
||||
t.Fatal("source is not a directory")
|
||||
}
|
||||
|
||||
_, err = os.Stat(dst)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("destination already exists")
|
||||
}
|
||||
|
||||
err = os.MkdirAll(dst, si.Mode())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
entries, err := ioutil.ReadDir(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
srcPath := filepath.Join(src, entry.Name())
|
||||
dstPath := filepath.Join(dst, entry.Name())
|
||||
|
||||
// If the entry is a symlink, we copy the contents
|
||||
for entry.Mode()&os.ModeSymlink != 0 {
|
||||
target, err := os.Readlink(srcPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
entry, err = os.Stat(target)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
if entry.IsDir() {
|
||||
testCopyDir(t, srcPath, dstPath)
|
||||
} else {
|
||||
err = copy.CopyFile(srcPath, dstPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// normalizeJSON removes all insignificant whitespace from the given JSON buffer
|
||||
// and returns it as a string for easier comparison.
|
||||
func normalizeJSON(t *testing.T, src []byte) string {
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
@ -192,7 +191,7 @@ func TestConsole_variables(t *testing.T) {
|
|||
|
||||
func TestConsole_modules(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("modules"), td)
|
||||
testCopyDir(t, testFixturePath("modules"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
|
@ -56,7 +55,7 @@ func TestGet_multipleArgs(t *testing.T) {
|
|||
|
||||
func TestGet_noArgs(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("get"), td)
|
||||
testCopyDir(t, testFixturePath("get"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/providers"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
|
@ -152,7 +152,7 @@ func TestImport_providerConfig(t *testing.T) {
|
|||
// "remote" state provided by the "local" backend
|
||||
func TestImport_remoteState(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("import-provider-remote-state"), td)
|
||||
testCopyDir(t, testFixturePath("import-provider-remote-state"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -258,7 +258,7 @@ func TestImport_remoteState(t *testing.T) {
|
|||
// early failure on import should not leave stale lock
|
||||
func TestImport_initializationErrorShouldUnlock(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("import-provider-remote-state"), td)
|
||||
testCopyDir(t, testFixturePath("import-provider-remote-state"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -746,7 +746,7 @@ func TestImport_missingModuleConfig(t *testing.T) {
|
|||
|
||||
func TestImportModuleVarFile(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("import-module-var-file"), td)
|
||||
testCopyDir(t, testFixturePath("import-module-var-file"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -816,7 +816,7 @@ func TestImportModuleVarFile(t *testing.T) {
|
|||
// module of {} causes this local evaluation to error, breaking import.
|
||||
func TestImportModuleInputVariableEvaluation(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("import-module-input-variable"), td)
|
||||
testCopyDir(t, testFixturePath("import-module-input-variable"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/configs"
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/internal/getproviders"
|
||||
"github.com/hashicorp/terraform/internal/providercache"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
|
@ -186,7 +185,7 @@ func TestInit_fromModule_dstInSrc(t *testing.T) {
|
|||
func TestInit_get(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get"), td)
|
||||
testCopyDir(t, testFixturePath("init-get"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -245,7 +244,7 @@ func TestInit_getUpgradeModules(t *testing.T) {
|
|||
func TestInit_backend(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -270,7 +269,7 @@ func TestInit_backend(t *testing.T) {
|
|||
func TestInit_backendUnset(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -333,7 +332,7 @@ func TestInit_backendUnset(t *testing.T) {
|
|||
func TestInit_backendConfigFile(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend-config-file"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend-config-file"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -460,7 +459,7 @@ func TestInit_backendConfigFile(t *testing.T) {
|
|||
func TestInit_backendConfigFilePowershellConfusion(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend-config-file"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend-config-file"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -494,7 +493,7 @@ func TestInit_backendConfigFilePowershellConfusion(t *testing.T) {
|
|||
func TestInit_backendConfigFileChange(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend-config-file-change"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend-config-file-change"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -526,7 +525,7 @@ func TestInit_backendConfigFileChange(t *testing.T) {
|
|||
func TestInit_backendConfigKV(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend-config-kv"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend-config-kv"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -553,7 +552,7 @@ func TestInit_backendConfigKV(t *testing.T) {
|
|||
func TestInit_backendConfigKVReInit(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend-config-kv"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend-config-kv"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -614,7 +613,7 @@ func TestInit_backendConfigKVReInit(t *testing.T) {
|
|||
func TestInit_backendConfigKVReInitWithConfigDiff(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -660,7 +659,7 @@ func TestInit_backendConfigKVReInitWithConfigDiff(t *testing.T) {
|
|||
func TestInit_backendCli_no_config_block(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init"), td)
|
||||
testCopyDir(t, testFixturePath("init"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -691,7 +690,7 @@ func TestInit_targetSubdir(t *testing.T) {
|
|||
defer testChdir(t, td)()
|
||||
|
||||
// copy the source into a subdir
|
||||
copy.CopyDir(testFixturePath("init-backend"), filepath.Join(td, "source"))
|
||||
testCopyDir(t, testFixturePath("init-backend"), filepath.Join(td, "source"))
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &InitCommand{
|
||||
|
@ -720,7 +719,7 @@ func TestInit_targetSubdir(t *testing.T) {
|
|||
|
||||
func TestInit_backendReinitWithExtra(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend-empty"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend-empty"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -776,7 +775,7 @@ func TestInit_backendReinitWithExtra(t *testing.T) {
|
|||
// move option from config to -backend-config args
|
||||
func TestInit_backendReinitConfigToExtra(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -832,7 +831,7 @@ func TestInit_backendReinitConfigToExtra(t *testing.T) {
|
|||
// make sure inputFalse stops execution on migrate
|
||||
func TestInit_inputFalse(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -907,7 +906,7 @@ func TestInit_inputFalse(t *testing.T) {
|
|||
func TestInit_getProvider(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-providers"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-providers"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -991,7 +990,7 @@ func TestInit_getProvider(t *testing.T) {
|
|||
func TestInit_getProviderSource(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-provider-source"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-provider-source"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1040,7 +1039,7 @@ func TestInit_getProviderSource(t *testing.T) {
|
|||
func TestInit_getProviderLegacyFromState(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-provider-legacy-from-state"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-provider-legacy-from-state"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1080,7 +1079,7 @@ func TestInit_getProviderLegacyFromState(t *testing.T) {
|
|||
func TestInit_getProviderInvalidPackage(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-provider-invalid-package"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-provider-invalid-package"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1141,7 +1140,7 @@ func TestInit_getProviderInvalidPackage(t *testing.T) {
|
|||
func TestInit_getProviderDetectedLegacy(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-provider-detected-legacy"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-provider-detected-legacy"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1208,7 +1207,7 @@ func TestInit_providerSource(t *testing.T) {
|
|||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
configDirName := "init-required-providers"
|
||||
copy.CopyDir(testFixturePath(configDirName), filepath.Join(td, configDirName))
|
||||
testCopyDir(t, testFixturePath(configDirName), filepath.Join(td, configDirName))
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1306,7 +1305,7 @@ func TestInit_cancel(t *testing.T) {
|
|||
|
||||
td := tempDir(t)
|
||||
configDirName := "init-required-providers"
|
||||
copy.CopyDir(testFixturePath(configDirName), filepath.Join(td, configDirName))
|
||||
testCopyDir(t, testFixturePath(configDirName), filepath.Join(td, configDirName))
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1351,7 +1350,7 @@ func TestInit_cancel(t *testing.T) {
|
|||
func TestInit_getUpgradePlugins(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-providers"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-providers"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1467,7 +1466,7 @@ func TestInit_getUpgradePlugins(t *testing.T) {
|
|||
func TestInit_getProviderMissing(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-providers"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-providers"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1505,7 +1504,7 @@ func TestInit_getProviderMissing(t *testing.T) {
|
|||
func TestInit_checkRequiredVersion(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-check-required-version"), td)
|
||||
testCopyDir(t, testFixturePath("init-check-required-version"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1533,7 +1532,7 @@ func TestInit_checkRequiredVersion(t *testing.T) {
|
|||
func TestInit_providerLockFile(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-provider-lock-file"), td)
|
||||
testCopyDir(t, testFixturePath("init-provider-lock-file"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1647,7 +1646,7 @@ func TestInit_pluginDirReset(t *testing.T) {
|
|||
// Test user-supplied -plugin-dir
|
||||
func TestInit_pluginDirProviders(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-providers"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-providers"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1734,7 +1733,7 @@ func TestInit_pluginDirProviders(t *testing.T) {
|
|||
// Test user-supplied -plugin-dir doesn't allow auto-install
|
||||
func TestInit_pluginDirProvidersDoesNotGet(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-get-providers"), td)
|
||||
testCopyDir(t, testFixturePath("init-get-providers"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1810,7 +1809,7 @@ func TestInit_pluginDirProvidersDoesNotGet(t *testing.T) {
|
|||
// Verify that plugin-dir doesn't prevent discovery of internal providers
|
||||
func TestInit_pluginDirWithBuiltIn(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-internal"), td)
|
||||
testCopyDir(t, testFixturePath("init-internal"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1847,7 +1846,7 @@ func TestInit_invalidBuiltInProviders(t *testing.T) {
|
|||
// - an explicit dependency on terraform.io/builtin/nonexist, which does
|
||||
// not exist at all.
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-internal-invalid"), td)
|
||||
testCopyDir(t, testFixturePath("init-internal-invalid"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/hashicorp/terraform/configs"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/plans"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
"github.com/hashicorp/terraform/states/statefile"
|
||||
|
@ -222,7 +222,7 @@ func TestMetaBackend_emptyWithExplicitState(t *testing.T) {
|
|||
func TestMetaBackend_configureInterpolation(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-new-interp"), td)
|
||||
testCopyDir(t, testFixturePath("backend-new-interp"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -239,7 +239,7 @@ func TestMetaBackend_configureInterpolation(t *testing.T) {
|
|||
// Newly configured backend
|
||||
func TestMetaBackend_configureNew(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-new"), td)
|
||||
testCopyDir(t, testFixturePath("backend-new"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -304,7 +304,7 @@ func TestMetaBackend_configureNew(t *testing.T) {
|
|||
func TestMetaBackend_configureNewWithState(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-new-migrate"), td)
|
||||
testCopyDir(t, testFixturePath("backend-new-migrate"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -378,7 +378,7 @@ func TestMetaBackend_configureNewWithState(t *testing.T) {
|
|||
func TestMetaBackend_configureNewWithoutCopy(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-new-migrate"), td)
|
||||
testCopyDir(t, testFixturePath("backend-new-migrate"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -429,7 +429,7 @@ func TestMetaBackend_configureNewWithoutCopy(t *testing.T) {
|
|||
func TestMetaBackend_configureNewWithStateNoMigrate(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-new-migrate"), td)
|
||||
testCopyDir(t, testFixturePath("backend-new-migrate"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -474,7 +474,7 @@ func TestMetaBackend_configureNewWithStateNoMigrate(t *testing.T) {
|
|||
func TestMetaBackend_configureNewWithStateExisting(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-new-migrate-existing"), td)
|
||||
testCopyDir(t, testFixturePath("backend-new-migrate-existing"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -546,7 +546,7 @@ func TestMetaBackend_configureNewWithStateExisting(t *testing.T) {
|
|||
func TestMetaBackend_configureNewWithStateExistingNoMigrate(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-new-migrate-existing"), td)
|
||||
testCopyDir(t, testFixturePath("backend-new-migrate-existing"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -658,7 +658,7 @@ func TestMetaBackend_configuredUnchanged(t *testing.T) {
|
|||
func TestMetaBackend_configuredChange(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -738,7 +738,7 @@ func TestMetaBackend_configuredChange(t *testing.T) {
|
|||
func TestMetaBackend_reconfigureChange(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change-single-to-single"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change-single-to-single"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -789,7 +789,7 @@ func TestMetaBackend_reconfigureChange(t *testing.T) {
|
|||
func TestMetaBackend_configuredChangeCopy(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -837,7 +837,7 @@ func TestMetaBackend_configuredChangeCopy(t *testing.T) {
|
|||
func TestMetaBackend_configuredChangeCopy_singleState(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change-single-to-single"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change-single-to-single"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -892,7 +892,7 @@ func TestMetaBackend_configuredChangeCopy_singleState(t *testing.T) {
|
|||
func TestMetaBackend_configuredChangeCopy_multiToSingleDefault(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change-multi-default-to-single"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change-multi-default-to-single"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -946,7 +946,7 @@ func TestMetaBackend_configuredChangeCopy_multiToSingleDefault(t *testing.T) {
|
|||
func TestMetaBackend_configuredChangeCopy_multiToSingle(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change-multi-to-single"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change-multi-to-single"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1016,7 +1016,7 @@ func TestMetaBackend_configuredChangeCopy_multiToSingle(t *testing.T) {
|
|||
func TestMetaBackend_configuredChangeCopy_multiToSingleCurrentEnv(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change-multi-to-single"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change-multi-to-single"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1082,7 +1082,7 @@ func TestMetaBackend_configuredChangeCopy_multiToSingleCurrentEnv(t *testing.T)
|
|||
func TestMetaBackend_configuredChangeCopy_multiToMulti(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change-multi-to-multi"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change-multi-to-multi"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1176,7 +1176,7 @@ func TestMetaBackend_configuredChangeCopy_multiToMulti(t *testing.T) {
|
|||
func TestMetaBackend_configuredChangeCopy_multiToNoDefaultWithDefault(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change-multi-to-no-default-with-default"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change-multi-to-no-default-with-default"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1252,7 +1252,7 @@ func TestMetaBackend_configuredChangeCopy_multiToNoDefaultWithDefault(t *testing
|
|||
func TestMetaBackend_configuredChangeCopy_multiToNoDefaultWithoutDefault(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change-multi-to-no-default-without-default"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change-multi-to-no-default-without-default"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1326,7 +1326,7 @@ func TestMetaBackend_configuredChangeCopy_multiToNoDefaultWithoutDefault(t *test
|
|||
func TestMetaBackend_configuredUnset(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-unset"), td)
|
||||
testCopyDir(t, testFixturePath("backend-unset"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1389,7 +1389,7 @@ func TestMetaBackend_configuredUnset(t *testing.T) {
|
|||
func TestMetaBackend_configuredUnsetCopy(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-unset"), td)
|
||||
testCopyDir(t, testFixturePath("backend-unset"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1447,7 +1447,7 @@ func TestMetaBackend_configuredUnsetCopy(t *testing.T) {
|
|||
func TestMetaBackend_planLocal(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-plan-local"), td)
|
||||
testCopyDir(t, testFixturePath("backend-plan-local"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1536,7 +1536,7 @@ func TestMetaBackend_planLocal(t *testing.T) {
|
|||
// A plan with a custom state save path
|
||||
func TestMetaBackend_planLocalStatePath(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-plan-local"), td)
|
||||
testCopyDir(t, testFixturePath("backend-plan-local"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1639,7 +1639,7 @@ func TestMetaBackend_planLocalStatePath(t *testing.T) {
|
|||
func TestMetaBackend_planLocalMatch(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-plan-local-match"), td)
|
||||
testCopyDir(t, testFixturePath("backend-plan-local-match"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1727,7 +1727,7 @@ func TestMetaBackend_planLocalMatch(t *testing.T) {
|
|||
func TestMetaBackend_configureWithExtra(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend-empty"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend-empty"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1779,7 +1779,7 @@ func TestMetaBackend_configureWithExtra(t *testing.T) {
|
|||
func TestMetaBackend_localDoesNotDeleteLocal(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend-empty"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend-empty"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1807,7 +1807,7 @@ func TestMetaBackend_localDoesNotDeleteLocal(t *testing.T) {
|
|||
func TestMetaBackend_configToExtra(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1852,7 +1852,7 @@ func TestMetaBackend_configToExtra(t *testing.T) {
|
|||
// no config; return inmem backend stored in state
|
||||
func TestBackendFromState(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-from-state"), td)
|
||||
testCopyDir(t, testFixturePath("backend-from-state"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"github.com/hashicorp/terraform/addrs"
|
||||
backendinit "github.com/hashicorp/terraform/backend/init"
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/plans"
|
||||
"github.com/hashicorp/terraform/providers"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
|
@ -26,7 +25,7 @@ import (
|
|||
|
||||
func TestPlan(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("plan"), td)
|
||||
testCopyDir(t, testFixturePath("plan"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -47,7 +46,7 @@ func TestPlan(t *testing.T) {
|
|||
|
||||
func TestPlan_lockedState(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("plan"), td)
|
||||
testCopyDir(t, testFixturePath("plan"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -264,7 +263,7 @@ func TestPlan_outPathNoChange(t *testing.T) {
|
|||
func TestPlan_outBackend(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("plan-out-backend"), td)
|
||||
testCopyDir(t, testFixturePath("plan-out-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -472,7 +471,7 @@ func TestPlan_validate(t *testing.T) {
|
|||
defer func() { test = true }()
|
||||
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("plan-invalid"), td)
|
||||
testCopyDir(t, testFixturePath("plan-invalid"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -763,7 +762,7 @@ func TestPlan_varFileWithDecls(t *testing.T) {
|
|||
|
||||
func TestPlan_detailedExitcode(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("plan"), td)
|
||||
testCopyDir(t, testFixturePath("plan"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -784,7 +783,7 @@ func TestPlan_detailedExitcode(t *testing.T) {
|
|||
|
||||
func TestPlan_detailedExitcode_emptyDiff(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("plan-emptydiff"), td)
|
||||
testCopyDir(t, testFixturePath("plan-emptydiff"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -884,7 +883,7 @@ func TestPlan_shutdown(t *testing.T) {
|
|||
|
||||
func TestPlan_init_required(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("plan"), td)
|
||||
testCopyDir(t, testFixturePath("plan"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@ import (
|
|||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/mitchellh/cli"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
)
|
||||
|
||||
func TestProvidersSchema_error(t *testing.T) {
|
||||
|
@ -45,7 +43,7 @@ func TestProvidersSchema_output(t *testing.T) {
|
|||
t.Run(entry.Name(), func(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
inputDir := filepath.Join(fixtureDir, entry.Name())
|
||||
copy.CopyDir(inputDir, td)
|
||||
testCopyDir(t, inputDir, td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
|
@ -77,7 +76,7 @@ func TestProviders_noConfigs(t *testing.T) {
|
|||
|
||||
func TestProviders_modules(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("providers/modules"), td)
|
||||
testCopyDir(t, testFixturePath("providers/modules"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/providers"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
"github.com/hashicorp/terraform/states/statefile"
|
||||
|
@ -83,7 +82,7 @@ func TestRefresh(t *testing.T) {
|
|||
func TestRefresh_empty(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("refresh-empty"), td)
|
||||
testCopyDir(t, testFixturePath("refresh-empty"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/plans"
|
||||
"github.com/hashicorp/terraform/providers"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
|
@ -243,7 +242,7 @@ func TestShow_json_output(t *testing.T) {
|
|||
t.Run(entry.Name(), func(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
inputDir := filepath.Join(fixtureDir, entry.Name())
|
||||
copy.CopyDir(inputDir, td)
|
||||
testCopyDir(t, inputDir, td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -342,7 +341,7 @@ func TestShow_json_output_state(t *testing.T) {
|
|||
t.Run(entry.Name(), func(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
inputDir := filepath.Join(fixtureDir, entry.Name())
|
||||
copy.CopyDir(inputDir, td)
|
||||
testCopyDir(t, inputDir, td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
|
@ -99,7 +98,7 @@ func TestStateListWithNonExistentID(t *testing.T) {
|
|||
func TestStateList_backendDefaultState(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-list-backend-default"), td)
|
||||
testCopyDir(t, testFixturePath("state-list-backend-default"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -128,7 +127,7 @@ func TestStateList_backendDefaultState(t *testing.T) {
|
|||
func TestStateList_backendCustomState(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-list-backend-custom"), td)
|
||||
testCopyDir(t, testFixturePath("state-list-backend-custom"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -157,7 +156,7 @@ func TestStateList_backendCustomState(t *testing.T) {
|
|||
func TestStateList_backendOverrideState(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-list-backend-custom"), td)
|
||||
testCopyDir(t, testFixturePath("state-list-backend-custom"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/mitchellh/cli"
|
||||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
)
|
||||
|
||||
|
@ -444,7 +443,7 @@ func TestStateMv_differentResourceTypes(t *testing.T) {
|
|||
// don't modify backend state is we supply a -state flag
|
||||
func TestStateMv_explicitWithBackend(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("init-backend"), td)
|
||||
testCopyDir(t, testFixturePath("init-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1040,7 +1039,7 @@ func TestStateMv_toNewModule(t *testing.T) {
|
|||
|
||||
func TestStateMv_withinBackend(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-unchanged"), td)
|
||||
testCopyDir(t, testFixturePath("backend-unchanged"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -1118,7 +1117,7 @@ func TestStateMv_withinBackend(t *testing.T) {
|
|||
|
||||
func TestStateMv_fromBackendToLocal(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-unchanged"), td)
|
||||
testCopyDir(t, testFixturePath("backend-unchanged"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -6,14 +6,13 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestStatePull(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-pull-backend"), td)
|
||||
testCopyDir(t, testFixturePath("state-pull-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/hashicorp/terraform/backend/remote-state/inmem"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
@ -16,7 +15,7 @@ import (
|
|||
func TestStatePush_empty(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-push-good"), td)
|
||||
testCopyDir(t, testFixturePath("state-push-good"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -45,7 +44,7 @@ func TestStatePush_empty(t *testing.T) {
|
|||
func TestStatePush_lockedState(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-push-good"), td)
|
||||
testCopyDir(t, testFixturePath("state-push-good"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -76,7 +75,7 @@ func TestStatePush_lockedState(t *testing.T) {
|
|||
func TestStatePush_replaceMatch(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-push-replace-match"), td)
|
||||
testCopyDir(t, testFixturePath("state-push-replace-match"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -105,7 +104,7 @@ func TestStatePush_replaceMatch(t *testing.T) {
|
|||
func TestStatePush_replaceMatchStdin(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-push-replace-match"), td)
|
||||
testCopyDir(t, testFixturePath("state-push-replace-match"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -141,7 +140,7 @@ func TestStatePush_replaceMatchStdin(t *testing.T) {
|
|||
func TestStatePush_lineageMismatch(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-push-bad-lineage"), td)
|
||||
testCopyDir(t, testFixturePath("state-push-bad-lineage"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -170,7 +169,7 @@ func TestStatePush_lineageMismatch(t *testing.T) {
|
|||
func TestStatePush_serialNewer(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-push-serial-newer"), td)
|
||||
testCopyDir(t, testFixturePath("state-push-serial-newer"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -199,7 +198,7 @@ func TestStatePush_serialNewer(t *testing.T) {
|
|||
func TestStatePush_serialOlder(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("state-push-serial-older"), td)
|
||||
testCopyDir(t, testFixturePath("state-push-serial-older"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -227,7 +226,7 @@ func TestStatePush_serialOlder(t *testing.T) {
|
|||
|
||||
func TestStatePush_forceRemoteState(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("inmem-backend"), td)
|
||||
testCopyDir(t, testFixturePath("inmem-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
defer inmem.Reset()
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/mitchellh/cli"
|
||||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
)
|
||||
|
||||
|
@ -367,7 +366,7 @@ func TestStateRm_noState(t *testing.T) {
|
|||
|
||||
func TestStateRm_needsInit(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-change"), td)
|
||||
testCopyDir(t, testFixturePath("backend-change"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -394,7 +393,7 @@ func TestStateRm_needsInit(t *testing.T) {
|
|||
|
||||
func TestStateRm_backendState(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-unchanged"), td)
|
||||
testCopyDir(t, testFixturePath("backend-unchanged"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/mitchellh/cli"
|
||||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
)
|
||||
|
||||
|
@ -460,7 +459,7 @@ func TestTaint_module(t *testing.T) {
|
|||
func TestTaint_checkRequiredVersion(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("taint-check-required-version"), td)
|
||||
testCopyDir(t, testFixturePath("taint-check-required-version"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/backend/remote-state/inmem"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
@ -65,7 +64,7 @@ func TestUnlock(t *testing.T) {
|
|||
func TestUnlock_inmemBackend(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("backend-inmem-locked"), td)
|
||||
testCopyDir(t, testFixturePath("backend-inmem-locked"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
defer inmem.Reset()
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
|
@ -59,7 +58,7 @@ func TestValidateCommandWithTfvarsFile(t *testing.T) {
|
|||
// Create a temporary working directory that is empty because this test
|
||||
// requires scanning the current working directory by validate command.
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("validate-valid/with-tfvars-file"), td)
|
||||
testCopyDir(t, testFixturePath("validate-valid/with-tfvars-file"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
|
@ -16,7 +15,7 @@ func TestVersionCommand_implements(t *testing.T) {
|
|||
func TestVersion(t *testing.T) {
|
||||
fixtureDir := "testdata/providers-schema/basic"
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(fixtureDir, td)
|
||||
testCopyDir(t, fixtureDir, td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
@ -111,7 +110,7 @@ func TestVersion_outdated(t *testing.T) {
|
|||
func TestVersion_json(t *testing.T) {
|
||||
fixtureDir := "testdata/providers-schema/basic"
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(fixtureDir, td)
|
||||
testCopyDir(t, fixtureDir, td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/hashicorp/terraform/backend/local"
|
||||
"github.com/hashicorp/terraform/backend/remote-state/inmem"
|
||||
"github.com/hashicorp/terraform/helper/copy"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
"github.com/hashicorp/terraform/states/statemgr"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
@ -215,7 +214,7 @@ func TestWorkspace_createInvalid(t *testing.T) {
|
|||
|
||||
func TestWorkspace_createWithState(t *testing.T) {
|
||||
td := tempDir(t)
|
||||
copy.CopyDir(testFixturePath("inmem-backend"), td)
|
||||
testCopyDir(t, testFixturePath("inmem-backend"), td)
|
||||
defer os.RemoveAll(td)
|
||||
defer testChdir(t, td)()
|
||||
defer inmem.Reset()
|
||||
|
|
4
go.mod
4
go.mod
|
@ -8,7 +8,6 @@ require (
|
|||
github.com/ChrisTrenkamp/goxpath v0.0.0-20190607011252-c5096ec8773d // indirect
|
||||
github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af // indirect
|
||||
github.com/agext/levenshtein v1.2.2
|
||||
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190329064014-6e358769c32a
|
||||
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190103054945-8205d1f41e70
|
||||
github.com/aliyun/aliyun-tablestore-go-sdk v4.1.2+incompatible
|
||||
|
@ -40,7 +39,6 @@ require (
|
|||
github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7 // indirect
|
||||
github.com/golang/mock v1.3.1
|
||||
github.com/golang/protobuf v1.3.4
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
|
||||
github.com/google/go-cmp v0.3.1
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/gophercloud/gophercloud v0.10.1-0.20200424014253-c3bfe50899e5
|
||||
|
@ -74,7 +72,6 @@ require (
|
|||
github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb // indirect
|
||||
github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7
|
||||
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
|
||||
github.com/hashicorp/vault v0.10.4
|
||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
|
||||
github.com/imdario/mergo v0.3.9 // indirect
|
||||
github.com/jmespath/go-jmespath v0.3.0
|
||||
|
@ -82,7 +79,6 @@ require (
|
|||
github.com/joyent/triton-go v0.0.0-20180313100802-d8f9c0314926
|
||||
github.com/jtolds/gls v4.2.1+incompatible // indirect
|
||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
|
||||
github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba // indirect
|
||||
github.com/lib/pq v1.0.0
|
||||
github.com/likexian/gokit v0.20.15
|
||||
github.com/lusis/go-artifactory v0.0.0-20160115162124-7e4ce345df82
|
||||
|
|
14
go.sum
14
go.sum
|
@ -49,8 +49,6 @@ github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJM
|
|||
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
|
||||
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI=
|
||||
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190329064014-6e358769c32a h1:APorzFpCcv6wtD5vmRWYqNm4N55kbepL7c7kTq9XI6A=
|
||||
|
@ -179,8 +177,6 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
|
|||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20160524151835-7d79101e329e/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
|
||||
|
@ -275,10 +271,6 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws=
|
||||
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
|
||||
github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
|
||||
github.com/hashicorp/hcl/v2 v2.6.0 h1:3krZOfGY6SziUXa6H9PJU6TyohHn7I+ARYnhbeNBz+o=
|
||||
github.com/hashicorp/hcl/v2 v2.6.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
|
||||
github.com/hashicorp/hcl/v2 v2.6.1-0.20200924164639-8eccdca8f95e h1:FC0v89ARfanOQUIZMTism4dw8riV9egA5lA2aFbxh2M=
|
||||
github.com/hashicorp/hcl/v2 v2.6.1-0.20200924164639-8eccdca8f95e/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
|
||||
github.com/hashicorp/hcl/v2 v2.6.1-0.20200925151948-a0de289809fb h1:mt4Roh7CUTNmwwtPqUYtxxz+viwpCLXoLW2bwlcq6RE=
|
||||
github.com/hashicorp/hcl/v2 v2.6.1-0.20200925151948-a0de289809fb/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
|
||||
github.com/hashicorp/memberlist v0.1.0 h1:qSsCiC0WYD39lbSitKNt40e30uorm2Ss/d4JGU1hzH8=
|
||||
|
@ -289,8 +281,6 @@ github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7
|
|||
github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A=
|
||||
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
|
||||
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
|
||||
github.com/hashicorp/vault v0.10.4 h1:4x0lHxui/ZRp/B3E0Auv1QNBJpzETqHR2kQD3mHSBJU=
|
||||
github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0=
|
||||
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
|
||||
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
|
||||
|
@ -318,8 +308,6 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY
|
|||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
|
||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
||||
github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba h1:NARVGAAgEXvoMeNPHhPFt1SBt1VMznA3Gnz9d0qj+co=
|
||||
github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
|
@ -505,8 +493,6 @@ github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557/go.mod h1:ce1O1j6Ut
|
|||
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
|
||||
github.com/zclconf/go-cty v1.6.2-0.20200908203537-4ad5e68430d3 h1:iGouBJrrvGf/H4L6a2n7YBCO0FDhq81FEHI4ILDphkw=
|
||||
github.com/zclconf/go-cty v1.6.2-0.20200908203537-4ad5e68430d3/go.mod h1:VDR4+I79ubFBGm1uJac1226K5yANQFHeauxPBoP54+o=
|
||||
github.com/zclconf/go-cty v1.6.2-0.20200923201117-36785d4dc4ac h1:rwzriIhzzyzWalNaKfMs3x/gQpqncr+r7sEIDnXJjsA=
|
||||
github.com/zclconf/go-cty v1.6.2-0.20200923201117-36785d4dc4ac/go.mod h1:VDR4+I79ubFBGm1uJac1226K5yANQFHeauxPBoP54+o=
|
||||
github.com/zclconf/go-cty-yaml v1.0.2 h1:dNyg4QLTrv2IfJpm7Wtxi55ed5gLGOlPrZ6kMd51hY0=
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
package copy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// From: https://gist.github.com/m4ng0squ4sh/92462b38df26839a3ca324697c8cba04
|
||||
|
||||
// CopyFile copies the contents of the file named src to the file named
|
||||
// by dst. The file will be created if it does not already exist. If the
|
||||
// destination file exists, all it's contents will be replaced by the contents
|
||||
// of the source file. The file mode will be copied from the source and
|
||||
// the copied data is synced/flushed to stable storage.
|
||||
func CopyFile(src, dst string) (err error) {
|
||||
in, err := os.Open(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
out, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if e := out.Close(); e != nil {
|
||||
err = e
|
||||
}
|
||||
}()
|
||||
|
||||
_, err = io.Copy(out, in)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = out.Sync()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
si, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = os.Chmod(dst, si.Mode())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CopyDir recursively copies a directory tree, attempting to preserve permissions.
|
||||
// Source directory must exist, destination directory must *not* exist.
|
||||
// Symlinks are ignored and skipped.
|
||||
func CopyDir(src string, dst string) (err error) {
|
||||
src = filepath.Clean(src)
|
||||
dst = filepath.Clean(dst)
|
||||
|
||||
si, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !si.IsDir() {
|
||||
return fmt.Errorf("source is not a directory")
|
||||
}
|
||||
|
||||
_, err = os.Stat(dst)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return
|
||||
}
|
||||
if err == nil {
|
||||
return fmt.Errorf("destination already exists")
|
||||
}
|
||||
|
||||
err = os.MkdirAll(dst, si.Mode())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
entries, err := ioutil.ReadDir(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
srcPath := filepath.Join(src, entry.Name())
|
||||
dstPath := filepath.Join(dst, entry.Name())
|
||||
|
||||
// If the entry is a symlink, we copy the contents
|
||||
for entry.Mode()&os.ModeSymlink != 0 {
|
||||
target, err := os.Readlink(srcPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
entry, err = os.Stat(target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if entry.IsDir() {
|
||||
err = CopyDir(srcPath, dstPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = CopyFile(srcPath, dstPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package copydir
|
||||
package copy
|
||||
|
||||
import (
|
||||
"io"
|
|
@ -1,4 +1,4 @@
|
|||
package copydir
|
||||
package copy
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
|
@ -0,0 +1,52 @@
|
|||
package copy
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// From: https://gist.github.com/m4ng0squ4sh/92462b38df26839a3ca324697c8cba04
|
||||
|
||||
// CopyFile copies the contents of the file named src to the file named
|
||||
// by dst. The file will be created if it does not already exist. If the
|
||||
// destination file exists, all it's contents will be replaced by the contents
|
||||
// of the source file. The file mode will be copied from the source and
|
||||
// the copied data is synced/flushed to stable storage.
|
||||
func CopyFile(src, dst string) (err error) {
|
||||
in, err := os.Open(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
out, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if e := out.Close(); e != nil {
|
||||
err = e
|
||||
}
|
||||
}()
|
||||
|
||||
_, err = io.Copy(out, in)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = out.Sync()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
si, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = os.Chmod(dst, si.Mode())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
|
@ -9,11 +9,11 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/internal/earlyconfig"
|
||||
|
||||
version "github.com/hashicorp/go-version"
|
||||
"github.com/hashicorp/terraform-config-inspect/tfconfig"
|
||||
"github.com/hashicorp/terraform/internal/copydir"
|
||||
"github.com/hashicorp/terraform/internal/modsdir"
|
||||
"github.com/hashicorp/terraform/registry"
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
|
@ -174,7 +174,7 @@ func DirFromModule(rootDir, modulesDir, sourceAddr string, reg *registry.Client,
|
|||
// We've found the module the user requested, which we must
|
||||
// now copy into rootDir so it can be used directly.
|
||||
log.Printf("[TRACE] copying new root module from %s to %s", record.Dir, rootDir)
|
||||
err := copydir.CopyDir(rootDir, record.Dir)
|
||||
err := copy.CopyDir(rootDir, record.Dir)
|
||||
if err != nil {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
|
@ -325,7 +325,7 @@ func DirFromModule(rootDir, modulesDir, sourceAddr string, reg *registry.Client,
|
|||
// We copy rather than "rename" here because renaming between directories
|
||||
// can be tricky in edge-cases like network filesystems, etc.
|
||||
log.Printf("[TRACE] copying new module %s from %s to %s", newKey, record.Dir, instPath)
|
||||
err := copydir.CopyDir(instPath, tempPath)
|
||||
err := copy.CopyDir(instPath, tempPath)
|
||||
if err != nil {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
version "github.com/hashicorp/go-version"
|
||||
"github.com/hashicorp/terraform/configs"
|
||||
"github.com/hashicorp/terraform/configs/configload"
|
||||
"github.com/hashicorp/terraform/internal/copydir"
|
||||
"github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/registry"
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
)
|
||||
|
@ -211,7 +211,7 @@ func TestDirFromModule_rel_submodules(t *testing.T) {
|
|||
if err := os.Mkdir(fromModuleDir, os.ModePerm); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := copydir.CopyDir(fromModuleDir, "testdata/local-modules"); err != nil {
|
||||
if err := copy.CopyDir(fromModuleDir, "testdata/local-modules"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Mkdir(workDir, os.ModePerm); err != nil {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
cleanhttp "github.com/hashicorp/go-cleanhttp"
|
||||
getter "github.com/hashicorp/go-getter"
|
||||
"github.com/hashicorp/terraform/internal/copydir"
|
||||
"github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/registry/regsrc"
|
||||
)
|
||||
|
||||
|
@ -113,7 +113,7 @@ func (g reusingGetter) getWithGoGetter(instPath, addr string) (string, error) {
|
|||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create directory %s: %s", instPath, err)
|
||||
}
|
||||
err = copydir.CopyDir(instPath, prevDir)
|
||||
err = copy.CopyDir(instPath, prevDir)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to copy from %s to %s: %s", prevDir, instPath, err)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"github.com/hashicorp/terraform/configs"
|
||||
"github.com/hashicorp/terraform/configs/configload"
|
||||
"github.com/hashicorp/terraform/helper/logging"
|
||||
"github.com/hashicorp/terraform/internal/copydir"
|
||||
"github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/registry"
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
)
|
||||
|
@ -544,7 +544,7 @@ func tempChdir(t *testing.T, sourceDir string) (string, func()) {
|
|||
return "", nil
|
||||
}
|
||||
|
||||
if err := copydir.CopyDir(tmpDir, sourceDir); err != nil {
|
||||
if err := copy.CopyDir(tmpDir, sourceDir); err != nil {
|
||||
t.Fatalf("failed to copy fixture to temporary directory: %s", err)
|
||||
return "", nil
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/apparentlymart/go-versions/versions"
|
||||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/internal/copydir"
|
||||
copydir "github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/internal/getproviders"
|
||||
)
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ import (
|
|||
getter "github.com/hashicorp/go-getter"
|
||||
|
||||
"github.com/hashicorp/terraform/httpclient"
|
||||
"github.com/hashicorp/terraform/internal/copydir"
|
||||
"github.com/hashicorp/terraform/internal/copy"
|
||||
copydir "github.com/hashicorp/terraform/internal/copy"
|
||||
"github.com/hashicorp/terraform/internal/getproviders"
|
||||
)
|
||||
|
||||
|
@ -180,7 +181,7 @@ func installFromLocalDir(ctx context.Context, meta getproviders.PackageMeta, tar
|
|||
if err != nil && os.IsExist(err) {
|
||||
return nil, fmt.Errorf("failed to create directory %s: %s", absNew, err)
|
||||
}
|
||||
err = copydir.CopyDir(absNew, absCurrent)
|
||||
err = copy.CopyDir(absNew, absCurrent)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to either symlink or copy %s to %s: %s", absCurrent, absNew, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue