-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
--glob
option with --recursive
- Loading branch information
Showing
11 changed files
with
171 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invalid { |
6 changes: 6 additions & 0 deletions
6
fixtures/invalid/nested-folder-with-error/a/b/c/tf-generator.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
generate { | ||
content = merge-tfvars([ | ||
load("locals.tfvars"), | ||
]) | ||
output = "tf-generator.tfvars" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package generate | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// findFilesByName finds all files with a specific name in a directory and its subdirectories | ||
func findFilesByName(directory, filename string) ([]string, error) { | ||
var matches []string | ||
|
||
err := filepath.Walk(directory, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
if info.IsDir() { | ||
return nil | ||
} | ||
if info.Name() == filename { | ||
matches = append(matches, path) | ||
} | ||
return nil | ||
}) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
return matches, nil | ||
} | ||
|
||
// hasDirs check if the file path specifies any directories | ||
func hasDirs(filePath string) bool { | ||
dir, _ := filepath.Split(filePath) | ||
return dir != "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package generate | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type HasDirsFixture struct { | ||
filePath string | ||
hasDirs bool | ||
} | ||
|
||
func TestHasDirsFixtures(t *testing.T) { | ||
for _, fixture := range []HasDirsFixture{ | ||
{ | ||
filePath: "test.txt", | ||
hasDirs: false, | ||
}, | ||
{ | ||
filePath: "abc", | ||
hasDirs: false, | ||
}, | ||
{ | ||
filePath: "./test.txt", | ||
hasDirs: true, | ||
}, | ||
{ | ||
filePath: "test/test.txt", | ||
hasDirs: true, | ||
}, | ||
} { | ||
t.Run(fixture.filePath, func(t *testing.T) { | ||
assert.Equal(t, fixture.hasDirs, hasDirs(fixture.filePath)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
nix-build -E 'let tf-generator-overlay = import ./.; pkgs = import <nixpkgs> { overlays = [ tf-generator-overlay ]; }; in pkgs.mkShellNoCC { buildInputs = with pkgs; [ tf-generator ]; }' --dry-run | ||
mkdir -p dist | ||
nix-build -E 'let tf-generator-overlay = import ./.; pkgs = import <nixpkgs> { overlays = [ tf-generator-overlay ]; }; in pkgs.mkShellNoCC { buildInputs = with pkgs; [ tf-generator ]; }' -o dist/release | ||
rm -rf dist |