Skip to content

Commit

Permalink
Chore: print schema output error when we get it (#203)
Browse files Browse the repository at this point in the history
* Chore: print schema output error when we get it

* add standard output
  • Loading branch information
TomerHeber authored Oct 20, 2024
1 parent c131667 commit 4369f90
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
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

0 comments on commit 4369f90

Please sign in to comment.