Skip to content

Commit

Permalink
fix: skip content checks for cdktf files
Browse files Browse the repository at this point in the history
they are translated and the original documents are valid already
  • Loading branch information
DanielMSchmidt committed Jul 14, 2023
1 parent 0f380a8 commit 72ef30e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 11 additions & 3 deletions check/legacy_resource_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"path/filepath"

"github.com/hashicorp/go-multierror"
)
Expand Down Expand Up @@ -58,6 +59,11 @@ func NewLegacyResourceFileCheck(opts *LegacyResourceFileOptions) *LegacyResource
func (check *LegacyResourceFileCheck) Run(path string, exampleLanguage string) error {
fullpath := check.Options.FullPath(path)

// skip cdktf directories
if IsValidCdktfDirectory(path) {
return nil
}

log.Printf("[DEBUG] Checking file: %s", fullpath)

if err := LegacyFileExtensionCheck(path); err != nil {
Expand All @@ -78,10 +84,12 @@ func (check *LegacyResourceFileCheck) Run(path string, exampleLanguage string) e
return fmt.Errorf("%s: error checking file frontmatter: %w", path, err)
}

if err := NewContentsCheck(check.Options.Contents).Run(fullpath, exampleLanguage); err != nil {
return fmt.Errorf("%s: error checking file contents: %w", path, err)
// We don't want to check the content for CDKTF files since they are converted
if !IsValidCdktfDirectory(filepath.Dir(fullpath)) {
if err := NewContentsCheck(check.Options.Contents).Run(fullpath, exampleLanguage); err != nil {
return fmt.Errorf("%s: error checking file contents: %w", path, err)
}
}

return nil
}

Expand Down
9 changes: 6 additions & 3 deletions check/registry_resource_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"path/filepath"

"github.com/hashicorp/go-multierror"
)
Expand Down Expand Up @@ -76,10 +77,12 @@ func (check *RegistryResourceFileCheck) Run(path string, exampleLanguage string)
return fmt.Errorf("%s: error checking file frontmatter: %w", path, err)
}

if err := NewContentsCheck(check.Options.Contents).Run(fullpath, exampleLanguage); err != nil {
return fmt.Errorf("%s: error checking file contents: %w", path, err)
// We don't want to check the content for CDKTF files since they are converted
if !IsValidCdktfDirectory(filepath.Dir(fullpath)) {
if err := NewContentsCheck(check.Options.Contents).Run(fullpath, exampleLanguage); err != nil {
return fmt.Errorf("%s: error checking file contents: %w", path, err)
}
}

return nil
}

Expand Down

0 comments on commit 72ef30e

Please sign in to comment.