Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Sep 1, 2022
1 parent 47eb00b commit e4c2ec3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ jobs:
-
name: Run go fmt
run: go run github.com/mh-cbon/go-fmt-fail ./...
-
name: Run verbose test / debug
run: go test -cover -covermode=atomic -timeout=5m -race ./internal/terraform/module -run=TestParseProviderVersions_multipleVersions -v
-
name: Run tests
run: go test -cover -covermode=atomic -timeout=5m -race ./...
9 changes: 9 additions & 0 deletions internal/terraform/module/module_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"log"

"github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-version"
Expand Down Expand Up @@ -137,6 +138,7 @@ func ObtainSchema(ctx context.Context, modStore *state.ModuleStore, schemaStore
return err
}
if exist {
log.Printf("all schemas already exist: %#v", pReqs)
// avoid obtaining schemas if we already have it
return nil
}
Expand All @@ -159,6 +161,8 @@ func ObtainSchema(ctx context.Context, modStore *state.ModuleStore, schemaStore
return err
}

log.Printf("received schemas: %#v", ps)

for rawAddr, pJsonSchema := range ps.Schemas {
pAddr, err := tfaddr.ParseProviderSource(rawAddr)
if err != nil {
Expand Down Expand Up @@ -202,6 +206,7 @@ func ParseModuleConfiguration(ctx context.Context, fs ReadOnlyFS, modStore *stat
}

files, diags, err := parser.ParseModuleFiles(fs, modPath)
log.Printf("parsed module files: %#v, %s\nfiles (%d): %#v", err, diags, len(files), files)

sErr := modStore.UpdateParsedModuleFiles(modPath, files, err)
if sErr != nil {
Expand Down Expand Up @@ -313,6 +318,8 @@ func ParseProviderVersions(ctx context.Context, fs ReadOnlyFS, modStore *state.M

pvm, err := datadir.ParsePluginVersions(fs, modPath)

log.Printf("storing provider versions: %#v", pvm)

sErr := modStore.UpdateInstalledProviders(modPath, pvm, err)
if sErr != nil {
return sErr
Expand Down Expand Up @@ -359,6 +366,8 @@ func LoadModuleMetadata(ctx context.Context, modStore *state.ModuleStore, modPat
}
meta.ProviderReferences = providerRefs

log.Printf("storing module meta: %#v", meta)

sErr := modStore.UpdateMetadata(modPath, meta, mErr)
if sErr != nil {
return sErr
Expand Down
4 changes: 2 additions & 2 deletions internal/terraform/module/module_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func TestParseProviderVersions_multipleVersions(t *testing.T) {
}
`),
},
filepath.Join(modPathFirst, "main.tf"): &fstest.MapFile{
modPathFirst + "/main.tf": &fstest.MapFile{
Data: []byte(`terraform {
required_providers {
aws = {
Expand Down Expand Up @@ -455,7 +455,7 @@ func TestParseProviderVersions_multipleVersions(t *testing.T) {
}
`),
},
filepath.Join(modPathSecond, "main.tf"): &fstest.MapFile{
modPathSecond + "/main.tf": &fstest.MapFile{
Data: []byte(`terraform {
required_providers {
aws = {
Expand Down
3 changes: 3 additions & 0 deletions internal/terraform/parser/module.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package parser

import (
"log"
"path/filepath"

"github.com/hashicorp/terraform-ls/internal/terraform/ast"
Expand All @@ -15,6 +16,8 @@ func ParseModuleFiles(fs FS, modPath string) (ast.ModFiles, ast.ModDiags, error)
return nil, nil, err
}

log.Printf("dir entries (%d): %#v", len(infos), infos)

for _, info := range infos {
if info.IsDir() {
// We only care about files
Expand Down

0 comments on commit e4c2ec3

Please sign in to comment.