Skip to content

Commit 2114cd1

Browse files
committed
Revert "feat(provisionersdk): add support for .tf.json templates (#7744)"
This reverts commit 9b8e5c2.
1 parent a442420 commit 2114cd1

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

provisionersdk/archive.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ const (
1515
TemplateArchiveLimit = 1 << 20
1616
)
1717

18-
func dirHasExt(dir string, exts ...string) (bool, error) {
18+
func dirHasExt(dir string, ext string) (bool, error) {
1919
dirEnts, err := os.ReadDir(dir)
2020
if err != nil {
2121
return false, err
2222
}
2323

2424
for _, fi := range dirEnts {
25-
for _, ext := range exts {
26-
if strings.HasSuffix(fi.Name(), ext) {
27-
return true, nil
28-
}
25+
if strings.HasSuffix(fi.Name(), ext) {
26+
return true, nil
2927
}
3028
}
3129

@@ -37,8 +35,8 @@ func Tar(w io.Writer, directory string, limit int64) error {
3735
tarWriter := tar.NewWriter(w)
3836
totalSize := int64(0)
3937

40-
tfExts := []string{".tf", ".tf.json"}
41-
hasTf, err := dirHasExt(directory, tfExts...)
38+
const tfExt = ".tf"
39+
hasTf, err := dirHasExt(directory, tfExt)
4240
if err != nil {
4341
return err
4442
}
@@ -52,7 +50,7 @@ func Tar(w io.Writer, directory string, limit int64) error {
5250
// useless.
5351
return xerrors.Errorf(
5452
"%s is not a valid template since it has no %s files",
55-
absPath, tfExts,
53+
absPath, tfExt,
5654
)
5755
}
5856

provisionersdk/archive_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ func TestTar(t *testing.T) {
3333
err = provisionersdk.Tar(io.Discard, dir, 1024)
3434
require.NoError(t, err)
3535
})
36-
t.Run("ValidJSON", func(t *testing.T) {
37-
t.Parallel()
38-
dir := t.TempDir()
39-
file, err := os.CreateTemp(dir, "*.tf.json")
40-
require.NoError(t, err)
41-
_ = file.Close()
42-
err = provisionersdk.Tar(io.Discard, dir, 1024)
43-
require.NoError(t, err)
44-
})
4536
t.Run("HiddenFiles", func(t *testing.T) {
4637
t.Parallel()
4738
dir := t.TempDir()

0 commit comments

Comments
 (0)