Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: print schema output error when we get it #203

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
version: ~> v1
args: release --clean
env:
CGO_ENABLED: 0
Expand Down Expand Up @@ -48,9 +48,9 @@ jobs:
CGO_ENABLED=0 go build -ldflags "-X main.version=${{github.ref_name}}" -a -installsuffix cgo -o ./out/terratag/terratag ./cmd/terratag
# Setup .npmrc file to publish to GitHub Packages
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "12.x"
node-version: 20
registry-url: "https://registry.npmjs.org"
scope: "@env0"
- run: |
Expand Down
13 changes: 12 additions & 1 deletion internal/tfschema/tfschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,18 @@ func getResourceSchema(resourceType string, resource hclwrite.Block, dir string,

out, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("failed to execute '%s providers schema -json' command: %w", name, err)
var ee *exec.ExitError
if errors.As(err, &ee) && ee.Stderr != nil {
log.Println("===============================================")
log.Printf("Error output: %s\n", string(ee.Stderr))
log.Println("===============================================")
}

log.Println("===============================================")
log.Printf("Standard output: %s\n", string(out))
log.Println("===============================================")

return nil, fmt.Errorf("failed to execute '%s providers schema -json' command in directory '%s': %w", name, dir, err)
}

// Output can vary between operating systems. Get the correct output line.
Expand Down
Loading