Skip to content

Commit ab734ee

Browse files
fix: skip content checks for cdktf files
they are translated and the original documents are valid already
1 parent e7c2351 commit ab734ee

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

check/legacy_resource_file.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"os"
7+
"path/filepath"
78

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

62+
// skip cdktf directories
63+
if IsValidCdktfDirectory(path) {
64+
return nil
65+
}
66+
6167
log.Printf("[DEBUG] Checking file: %s", fullpath)
6268

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

81-
if err := NewContentsCheck(check.Options.Contents).Run(fullpath, exampleLanguage); err != nil {
82-
return fmt.Errorf("%s: error checking file contents: %w", path, err)
87+
// We don't want to check the content for CDKTF files since they are converted
88+
if !IsValidCdktfDirectory(filepath.Dir(fullpath)) {
89+
if err := NewContentsCheck(check.Options.Contents).Run(fullpath, exampleLanguage); err != nil {
90+
return fmt.Errorf("%s: error checking file contents: %w", path, err)
91+
}
8392
}
84-
8593
return nil
8694
}
8795

check/registry_resource_file.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"os"
7+
"path/filepath"
78

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

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

0 commit comments

Comments
 (0)