From 4369f90427965a576bebfbe4ec6cfebe6d1bd440 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Sun, 20 Oct 2024 08:48:19 -0500 Subject: [PATCH] Chore: print schema output error when we get it (#203) * Chore: print schema output error when we get it * add standard output --- .github/workflows/release.yml | 6 +++--- internal/tfschema/tfschema.go | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf095c9..446e958 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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: | diff --git a/internal/tfschema/tfschema.go b/internal/tfschema/tfschema.go index 7227525..1c80987 100644 --- a/internal/tfschema/tfschema.go +++ b/internal/tfschema/tfschema.go @@ -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.