Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip content checks for cdktf files #80

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: go mod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
Expand All @@ -26,7 +26,7 @@ jobs:
name: go test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
Expand All @@ -36,7 +36,7 @@ jobs:
needs: [go_mod, go_test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
Expand All @@ -55,11 +55,11 @@ jobs:
run: |
sed -n -e "1{/# v/d;}" -e "2{/^$/d;}" -e "/# $(git describe --abbrev=0 --exclude="$(git describe --abbrev=0 --match='v*.*.*' --tags)" --match='v*.*.*' --tags)/q;p" CHANGELOG.md > RELEASE-NOTES.md
- name: goreleaser check
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4.3.0
with:
args: check
- name: goreleaser release
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4.3.0
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: go mod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
Expand All @@ -20,7 +20,7 @@ jobs:
name: go test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
Expand All @@ -29,7 +29,7 @@ jobs:
name: goreleaser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
Expand Down
14 changes: 7 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ brews:
- go
description: Terraform Provider Documentation Tool
folder: Formula
tap:
owner: bflad
repository:
owner: YakDriver
name: homebrew-tap
homepage: https://github.com/bflad/tfproviderdocs
homepage: https://github.com/YakDriver/tfproviderdocs
install: |
bin.install "tfproviderdocs"
test: |
Expand All @@ -33,7 +33,7 @@ builds:
- arm64
- 386
ldflags:
- -s -w -X github.com/bflad/tfproviderdocs/version.Version={{.Version}} -X github.com/bflad/tfproviderdocs/version.VersionPrerelease=
- -s -w -X github.com/YakDriver/tfproviderdocs/version.Version={{.Version}} -X github.com/YakDriver/tfproviderdocs/version.VersionPrerelease=
main: .
changelog:
skip: true
Expand All @@ -44,9 +44,9 @@ dockers:
- "--label=org.label-schema.version={{.Version}}"
- "--label=org.label-schema.name={{.ProjectName}}"
image_templates:
- 'bflad/tfproviderdocs:{{ .Version }}'
- 'bflad/tfproviderdocs:{{ .Major }}.{{ .Minor }}'
- 'bflad/tfproviderdocs:latest'
- 'YakDriver/tfproviderdocs:{{ .Version }}'
- 'YakDriver/tfproviderdocs:{{ .Major }}.{{ .Minor }}'
- 'YakDriver/tfproviderdocs:latest'
milestones:
-
close: true
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ A documentation tool for [Terraform Provider](https://www.terraform.io/docs/prov

### Local Install

Release binaries are available in the [Releases](https://github.com/bflad/tfproviderdocs/releases) section.
Release binaries are available in the [Releases](https://github.com/YakDriver/tfproviderdocs/releases) section.

To instead use Go to install into your `$GOBIN` directory (e.g. `$GOPATH/bin`):

```shell
go install github.com/bflad/tfproviderdocs
go install github.com/YakDriver/tfproviderdocs
```

### Docker Install

```shell
docker pull bflad/tfproviderdocs
docker pull YakDriver/tfproviderdocs
```

### Homebrew Install

```shell
brew install bflad/tap/tfproviderdocs
brew install YakDriver/tap/tfproviderdocs
```

## Usage
Expand All @@ -47,7 +47,7 @@ tfproviderdocs
Change into the directory of the Terraform Provider code and run:

```shell
docker run -v $(pwd):/src bflad/tfproviderdocs
docker run -v $(pwd):/src YakDriver/tfproviderdocs
```

## Available Commands
Expand Down
2 changes: 1 addition & 1 deletion check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"sort"

"github.com/bflad/tfproviderdocs/markdown"
"github.com/YakDriver/tfproviderdocs/markdown"
"github.com/hashicorp/go-multierror"
)

Expand Down
2 changes: 1 addition & 1 deletion check/contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package check
import (
"fmt"

"github.com/bflad/tfproviderdocs/check/contents"
"github.com/YakDriver/tfproviderdocs/check/contents"
)

type ContentsCheck struct {
Expand Down
23 changes: 14 additions & 9 deletions check/contents/check_attributes_section.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,48 @@ func (d *Document) checkAttributesSection() error {
section := d.Sections.Attributes

if section == nil {
return fmt.Errorf("missing attributes section: ## Attributes Reference")
return fmt.Errorf("missing attribute section: ## Attribute Reference")
}

heading := section.Heading

if heading.Level != 2 {
return fmt.Errorf("attributes section heading level (%d) should be: 2", heading.Level)
return fmt.Errorf("attribute section heading level (%d) should be: 2", heading.Level)
}

headingText := string(heading.Text(d.source))
expectedHeadingText := "Attributes Reference"
expectedHeadingTexts := []string{
"Attribute Reference",
"Attributes Reference",
}

if headingText != expectedHeadingText {
return fmt.Errorf("attributes section heading (%s) should be: %s", headingText, expectedHeadingText)
if headingText != expectedHeadingTexts[0] && headingText != expectedHeadingTexts[1] {
return fmt.Errorf("attribute section heading (%s) should be: %q (preferred) or %q", headingText, expectedHeadingTexts[0], expectedHeadingTexts[1])
}

paragraphs := section.Paragraphs
expectedBylineTexts := []string{
"This resource exports the following attributes in addition to the arguments above:",
"This data source exports the following attributes in addition to the arguments above:",
"In addition to all arguments above, the following attributes are exported:",
"No additional attributes are exported.",
}

switch len(paragraphs) {
case 0:
return fmt.Errorf("attributes section byline should be: %q or %q", expectedBylineTexts[0], expectedBylineTexts[1])
return fmt.Errorf("attribute section byline should be: %q, %q, %q, or %q", expectedBylineTexts[0], expectedBylineTexts[1], expectedBylineTexts[2], expectedBylineTexts[3])
case 1:
paragraphText := string(paragraphs[0].Text(d.source))

if paragraphText != expectedBylineTexts[0] && paragraphText != expectedBylineTexts[1] {
return fmt.Errorf("attributes section byline (%s) should be: %q or %q", paragraphText, expectedBylineTexts[0], expectedBylineTexts[1])
if paragraphText != expectedBylineTexts[0] && paragraphText != expectedBylineTexts[1] && paragraphText != expectedBylineTexts[2] && paragraphText != expectedBylineTexts[3] {
return fmt.Errorf("attribute section byline (%s) should be: %q, %q, %q, or %q", paragraphText, expectedBylineTexts[0], expectedBylineTexts[1], expectedBylineTexts[2], expectedBylineTexts[3])
}
}

if checkOpts.RequireSchemaOrdering {
for _, list := range section.SchemaAttributeLists {
if !sort.IsSorted(SchemaAttributeListItemByName(list.Items)) {
return fmt.Errorf("attributes section is not sorted by name")
return fmt.Errorf("attribute section is not sorted by name")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion check/contents/check_example_section.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/bflad/tfproviderdocs/markdown"
"github.com/YakDriver/tfproviderdocs/markdown"
)

type CheckExamplesSectionOptions struct {
Expand Down
2 changes: 1 addition & 1 deletion check/contents/check_import_section.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/bflad/tfproviderdocs/markdown"
"github.com/YakDriver/tfproviderdocs/markdown"
)

func (d *Document) checkImportSection() error {
Expand Down
2 changes: 1 addition & 1 deletion check/contents/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"path/filepath"
"strings"

"github.com/bflad/tfproviderdocs/markdown"
"github.com/YakDriver/tfproviderdocs/markdown"
"github.com/yuin/goldmark/ast"
)

Expand Down
5 changes: 5 additions & 0 deletions check/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ func NumberOfFilesCheck(directories map[string][]string) error {
var numberOfFiles int

for directory, files := range directories {
// Ignore CDKTF files. The file limit is per-language and presumably there is one CDKTF file per source HCL file.
if IsValidCdktfDirectory(directory) {
continue
}

directoryNumberOfFiles := len(files)
log.Printf("[TRACE] Found %d documentation files in directory: %s", directoryNumberOfFiles, directory)
numberOfFiles = numberOfFiles + directoryNumberOfFiles
Expand Down
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
2 changes: 1 addition & 1 deletion command/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
"text/tabwriter"

"github.com/bflad/tfproviderdocs/check"
"github.com/YakDriver/tfproviderdocs/check"
tfjson "github.com/hashicorp/terraform-json"
"github.com/mitchellh/cli"
)
Expand Down
2 changes: 1 addition & 1 deletion command/commands.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package command

import (
"github.com/bflad/tfproviderdocs/version"
"github.com/YakDriver/tfproviderdocs/version"
"github.com/mitchellh/cli"
)

Expand Down
2 changes: 1 addition & 1 deletion command/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package command

import (
"github.com/bflad/tfproviderdocs/version"
"github.com/YakDriver/tfproviderdocs/version"
"github.com/mitchellh/cli"
)

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/bflad/tfproviderdocs
module github.com/YakDriver/tfproviderdocs

go 1.19

require (
github.com/bmatcuk/doublestar v1.3.4
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/terraform-json v0.16.0
github.com/hashicorp/terraform-json v0.17.1
github.com/mattn/go-colorable v0.1.13
github.com/mitchellh/cli v1.1.5
github.com/yuin/goldmark v1.5.4
Expand All @@ -33,7 +33,7 @@ require (
github.com/posener/complete v1.1.1 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/zclconf/go-cty v1.13.0 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/text v0.3.8 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/terraform-json v0.16.0 h1:UKkeWRWb23do5LNAFlh/K3N0ymn1qTOO8c+85Albo3s=
github.com/hashicorp/terraform-json v0.16.0/go.mod h1:v0Ufk9jJnk6tcIZvScHvetlKfiNTC+WS21mnXIlc0B0=
github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA=
github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
Expand Down Expand Up @@ -74,8 +74,8 @@ github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU=
github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc=
github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0=
github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0=
github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0=
github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
Expand Down
Loading