diff --git a/pkg/tfgen/docs.go b/pkg/tfgen/docs.go index 291dd510e..0c6ea43e0 100644 --- a/pkg/tfgen/docs.go +++ b/pkg/tfgen/docs.go @@ -34,6 +34,7 @@ import ( "golang.org/x/text/language" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tf2pulumi/gen/python" + "github.com/pulumi/pulumi/sdk/v3/go/common/diag" "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" "github.com/spf13/afero" @@ -156,7 +157,8 @@ func getRepoPath(gitHost string, org string, provider string, version string) (s command.Dir = curWd output, err := command.CombinedOutput() if err != nil { - return "", fmt.Errorf("error running 'go mod download -json' for module: %w", err) + msg := "error running 'go mod download -json' in %q dir for module: %w\n\nOutput: %s" + return "", fmt.Errorf(msg, curWd, err, output) } target := struct { @@ -178,7 +180,8 @@ func getRepoPath(gitHost string, org string, provider string, version string) (s return target.Dir, nil } -func getMarkdownDetails(org string, provider string, resourcePrefix string, kind DocKind, rawname string, +func getMarkdownDetails(sink diag.Sink, org string, provider string, + resourcePrefix string, kind DocKind, rawname string, info tfbridge.ResourceOrDataSourceInfo, providerModuleVersion string, githost string) ([]byte, string, bool) { var docinfo *tfbridge.DocInfo @@ -191,6 +194,8 @@ func getMarkdownDetails(org string, provider string, resourcePrefix string, kind repoPath, err := getRepoPath(githost, org, provider, providerModuleVersion) if err != nil { + msg := "Skip getMarkdownDetails(rawname=%q) because getRepoPath(%q, %q, %q, %q) failed: %v" + sink.Debugf(&diag.Diag{Message: msg}, rawname, githost, org, provider, providerModuleVersion, err) return nil, "", false } @@ -251,8 +256,8 @@ func getDocsForProvider(g *Generator, org string, provider string, resourcePrefi return entityDocs{}, nil } - markdownBytes, markdownFileName, found := getMarkdownDetails(org, provider, resourcePrefix, kind, rawname, info, - providerModuleVersion, githost) + markdownBytes, markdownFileName, found := getMarkdownDetails(g.sink, org, provider, + resourcePrefix, kind, rawname, info, providerModuleVersion, githost) if !found { entitiesMissingDocs++ msg := fmt.Sprintf("could not find docs for %v %v. Override the Docs property in the %v mapping. See "+