check

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2025 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceTypeDataSource = "data source"
	ResourceTypeEphemeral  = "ephemeral"
	ResourceTypeFunction   = "function"
	ResourceTypeResource   = "resource"

	// Terraform Registry Storage Limits
	RegistryMaximumSizeOfFile = 500000 // 500KB
)
View Source
const (
	CdktfIndexDirectory = `cdktf`

	DocumentationGlobPattern = `{docs/index.md,docs/{,cdktf/}{data-sources,ephemeral-resources,guides,resources},website/docs}/**/*`

	LegacyIndexDirectory       = `website/docs`
	LegacyDataSourcesDirectory = `d`
	LegacyEphemeralsDirectory  = `ephemeral-resources`
	LegacyFunctionsDirectory   = `functions`
	LegacyGuidesDirectory      = `guides`
	LegacyResourcesDirectory   = `r`

	RegistryIndexDirectory       = `docs`
	RegistryDataSourcesDirectory = `data-sources`
	RegistryEphemeralsDirectory  = `ephemeral-resources`
	RegistryFunctionsDirectory   = `functions`
	RegistryGuidesDirectory      = `guides`
	RegistryResourcesDirectory   = `resources`
)
View Source
const (
	FileExtensionHtmlMarkdown = `.html.markdown`
	FileExtensionHtmlMd       = `.html.md`
	FileExtensionMarkdown     = `.markdown`
	FileExtensionMd           = `.md`
)
View Source
const (
	FileIgnoreDSStore = `.DS_Store`
)

Variables

View Source
var IgnoreFiles = []string{
	FileIgnoreDSStore,
}
View Source
var ValidCdktfLanguages = []string{
	"csharp",
	"go",
	"java",
	"python",
	"typescript",
}
View Source
var ValidRegistryFileExtensions = []string{
	FileExtensionMd,
}

Functions

func FileIgnoreCheck added in v0.16.7

func FileIgnoreCheck(path string) bool

FileIgnoreCheck checks if the file should be ignored.

func FilePathEndsWithExtensionFrom

func FilePathEndsWithExtensionFrom(path string, validExtensions []string) bool

func FileSizeCheck

func FileSizeCheck(fullpath string) error

FileSizeCheck verifies that documentation file is below the Terraform Registry storage limit.

func GetDirectories

func GetDirectories(basepath string) (map[string][]string, error)

func InvalidDirectoriesCheck

func InvalidDirectoriesCheck(directories map[string][]string) error

func IsValidCdktfDirectory

func IsValidCdktfDirectory(directory string) bool

func IsValidLegacyDirectory

func IsValidLegacyDirectory(directory string) bool

func IsValidRegistryDirectory

func IsValidRegistryDirectory(directory string) bool

func LegacyFileExtensionCheck

func LegacyFileExtensionCheck(path string) error

func MixedDirectoriesCheck

func MixedDirectoriesCheck(directories map[string][]string) error

func RegistryFileExtensionCheck

func RegistryFileExtensionCheck(path string) error

func TrimFileExtension

func TrimFileExtension(path string) string

TrimFileExtension removes file extensions including those with multiple periods.

Types

type Check

type Check struct {
	Options *CheckOptions
}

func NewCheck

func NewCheck(opts *CheckOptions) *Check

func (*Check) Run

func (check *Check) Run(directories map[string][]string) error

type CheckOptions

type CheckOptions struct {
	DataSourceFileMismatch *FileMismatchOptions
	EphemeralFileMismatch  *FileMismatchOptions
	FunctionFileMismatch   *FileMismatchOptions
	ResourceFileMismatch   *FileMismatchOptions

	LegacyDataSourceFile *LegacyDataSourceFileOptions
	LegacyEphemeralFile  *LegacyEphemeralFileOptions
	LegacyFunctionFile   *LegacyFunctionFileOptions
	LegacyGuideFile      *LegacyGuideFileOptions
	LegacyIndexFile      *LegacyIndexFileOptions
	LegacyResourceFile   *LegacyResourceFileOptions

	ProviderName   string
	ProviderSource string

	RegistryDataSourceFile *RegistryDataSourceFileOptions
	RegistryEphemeralFile  *RegistryEphemeralFileOptions
	RegistryFunctionFile   *RegistryFunctionFileOptions
	RegistryGuideFile      *RegistryGuideFileOptions
	RegistryIndexFile      *RegistryIndexFileOptions
	RegistryResourceFile   *RegistryResourceFileOptions

	IgnoreCdktfMissingFiles bool
}

type ContentsCheck

type ContentsCheck struct {
	Options *ContentsOptions
}

func NewContentsCheck

func NewContentsCheck(opts *ContentsOptions) *ContentsCheck

func (*ContentsCheck) Run

func (check *ContentsCheck) Run(path string, exampleLanguage string) error

type ContentsOptions

type ContentsOptions struct {
	*FileOptions

	Enable                bool
	ProviderName          string
	RequireSchemaOrdering bool
}

ContentsOptions represents configuration options for Contents.

type FileCheck

type FileCheck interface {
	Run(string) error
	RunAll([]string) error
}

type FileMismatchCheck

type FileMismatchCheck struct {
	Options *FileMismatchOptions
}

func NewFileMismatchCheck

func NewFileMismatchCheck(opts *FileMismatchOptions) *FileMismatchCheck

func (*FileMismatchCheck) IgnoreFileMismatch

func (check *FileMismatchCheck) IgnoreFileMismatch(file string) bool

func (*FileMismatchCheck) IgnoreFileMissing

func (check *FileMismatchCheck) IgnoreFileMissing(resourceName string) bool

func (*FileMismatchCheck) Run

func (check *FileMismatchCheck) Run(files []string) error

type FileMismatchOptions

type FileMismatchOptions struct {
	*FileOptions

	IgnoreFileMismatch []string

	IgnoreFileMissing []string

	ProviderName string

	ResourceType string

	ResourceNames []string
}

type FileOptions

type FileOptions struct {
	BasePath string
}

func (*FileOptions) FullPath

func (opts *FileOptions) FullPath(path string) string

FullPath returns the full path of the file, combining path portions from opts.BasePath and path.

type FrontMatterCheck

type FrontMatterCheck struct {
	Options *FrontMatterOptions
}

func NewFrontMatterCheck

func NewFrontMatterCheck(opts *FrontMatterOptions) *FrontMatterCheck

func (*FrontMatterCheck) Run

func (check *FrontMatterCheck) Run(src []byte) error

type FrontMatterData

type FrontMatterData struct {
	Description    *string `yaml:"description,omitempty"`
	Layout         *string `yaml:"layout,omitempty"`
	PageTitle      *string `yaml:"page_title,omitempty"`
	SidebarCurrent *string `yaml:"sidebar_current,omitempty"`
	Subcategory    *string `yaml:"subcategory,omitempty"`
}

FrontMatterData represents the YAML frontmatter of Terraform Provider documentation.

type FrontMatterOptions

type FrontMatterOptions struct {
	AllowedSubcategories []string
	NoDescription        bool
	NoLayout             bool
	NoPageTitle          bool
	NoSidebarCurrent     bool
	NoSubcategory        bool
	RequireDescription   bool
	RequireLayout        bool
	RequirePageTitle     bool
	RequireSubcategory   bool
}

FrontMatterOptions represents configuration options for FrontMatter.

type LegacyDataSourceFileCheck

type LegacyDataSourceFileCheck struct {
	FileCheck

	Options *LegacyDataSourceFileOptions
}

func (*LegacyDataSourceFileCheck) Run

func (check *LegacyDataSourceFileCheck) Run(path string) error

func (*LegacyDataSourceFileCheck) RunAll

func (check *LegacyDataSourceFileCheck) RunAll(files []string) error

type LegacyDataSourceFileOptions

type LegacyDataSourceFileOptions struct {
	*FileOptions

	FrontMatter *FrontMatterOptions
}

type LegacyEphemeralFileCheck added in v0.16.0

type LegacyEphemeralFileCheck struct {
	FileCheck

	Options *LegacyEphemeralFileOptions
}

func NewLegacyEphemeralFileCheck added in v0.16.0

func NewLegacyEphemeralFileCheck(opts *LegacyEphemeralFileOptions) *LegacyEphemeralFileCheck

func (*LegacyEphemeralFileCheck) Run added in v0.16.0

func (check *LegacyEphemeralFileCheck) Run(path string, exampleLanguage string) error

func (*LegacyEphemeralFileCheck) RunAll added in v0.16.0

func (check *LegacyEphemeralFileCheck) RunAll(files []string, exampleLanguage string) error

type LegacyEphemeralFileOptions added in v0.16.0

type LegacyEphemeralFileOptions struct {
	*FileOptions

	Contents     *ContentsOptions
	FrontMatter  *FrontMatterOptions
	ProviderName string
}

type LegacyFunctionFileCheck added in v0.12.0

type LegacyFunctionFileCheck struct {
	FileCheck

	Options *LegacyFunctionFileOptions
}

func NewLegacyFunctionFileCheck added in v0.12.0

func NewLegacyFunctionFileCheck(opts *LegacyFunctionFileOptions) *LegacyFunctionFileCheck

func (*LegacyFunctionFileCheck) Run added in v0.12.0

func (check *LegacyFunctionFileCheck) Run(path string) error

func (*LegacyFunctionFileCheck) RunAll added in v0.12.0

func (check *LegacyFunctionFileCheck) RunAll(files []string) error

type LegacyFunctionFileOptions added in v0.12.0

type LegacyFunctionFileOptions struct {
	*FileOptions

	FrontMatter *FrontMatterOptions
}

type LegacyGuideFileCheck

type LegacyGuideFileCheck struct {
	FileCheck

	Options *LegacyGuideFileOptions
}

func NewLegacyGuideFileCheck

func NewLegacyGuideFileCheck(opts *LegacyGuideFileOptions) *LegacyGuideFileCheck

func (*LegacyGuideFileCheck) Run

func (check *LegacyGuideFileCheck) Run(path string) error

func (*LegacyGuideFileCheck) RunAll

func (check *LegacyGuideFileCheck) RunAll(files []string) error

type LegacyGuideFileOptions

type LegacyGuideFileOptions struct {
	*FileOptions

	FrontMatter *FrontMatterOptions
}

type LegacyIndexFileCheck

type LegacyIndexFileCheck struct {
	FileCheck

	Options *LegacyIndexFileOptions
}

func NewLegacyIndexFileCheck

func NewLegacyIndexFileCheck(opts *LegacyIndexFileOptions) *LegacyIndexFileCheck

func (*LegacyIndexFileCheck) Run

func (check *LegacyIndexFileCheck) Run(path string) error

func (*LegacyIndexFileCheck) RunAll

func (check *LegacyIndexFileCheck) RunAll(files []string) error

type LegacyIndexFileOptions

type LegacyIndexFileOptions struct {
	*FileOptions

	FrontMatter *FrontMatterOptions
}

type LegacyResourceFileCheck

type LegacyResourceFileCheck struct {
	FileCheck

	Options *LegacyResourceFileOptions
}

func (*LegacyResourceFileCheck) Run

func (check *LegacyResourceFileCheck) Run(path string, exampleLanguage string) error

func (*LegacyResourceFileCheck) RunAll

func (check *LegacyResourceFileCheck) RunAll(files []string, exampleLanguage string) error

type LegacyResourceFileOptions

type LegacyResourceFileOptions struct {
	*FileOptions

	Contents     *ContentsOptions
	FrontMatter  *FrontMatterOptions
	ProviderName string
}

type RegistryDataSourceFileCheck

type RegistryDataSourceFileCheck struct {
	FileCheck

	Options *RegistryDataSourceFileOptions
}

func (*RegistryDataSourceFileCheck) Run

func (check *RegistryDataSourceFileCheck) Run(path string) error

func (*RegistryDataSourceFileCheck) RunAll

func (check *RegistryDataSourceFileCheck) RunAll(files []string) error

type RegistryDataSourceFileOptions

type RegistryDataSourceFileOptions struct {
	*FileOptions

	FrontMatter *FrontMatterOptions
}

type RegistryEphemeralFileCheck added in v0.16.0

type RegistryEphemeralFileCheck struct {
	FileCheck

	Options *RegistryEphemeralFileOptions
}

func NewRegistryEphemeralFileCheck added in v0.16.0

func NewRegistryEphemeralFileCheck(opts *RegistryEphemeralFileOptions) *RegistryEphemeralFileCheck

func (*RegistryEphemeralFileCheck) Run added in v0.16.0

func (check *RegistryEphemeralFileCheck) Run(path string, exampleLanguage string) error

func (*RegistryEphemeralFileCheck) RunAll added in v0.16.0

func (check *RegistryEphemeralFileCheck) RunAll(files []string, exampleLanguage string) error

type RegistryEphemeralFileOptions added in v0.16.0

type RegistryEphemeralFileOptions struct {
	*FileOptions

	Contents     *ContentsOptions
	FrontMatter  *FrontMatterOptions
	ProviderName string
}

type RegistryFunctionFileCheck added in v0.12.0

type RegistryFunctionFileCheck struct {
	FileCheck

	Options *RegistryFunctionFileOptions
}

func NewRegistryFunctionFileCheck added in v0.12.0

func NewRegistryFunctionFileCheck(opts *RegistryFunctionFileOptions) *RegistryFunctionFileCheck

func (*RegistryFunctionFileCheck) Run added in v0.12.0

func (check *RegistryFunctionFileCheck) Run(path string) error

func (*RegistryFunctionFileCheck) RunAll added in v0.12.0

func (check *RegistryFunctionFileCheck) RunAll(files []string) error

type RegistryFunctionFileOptions added in v0.12.0

type RegistryFunctionFileOptions struct {
	*FileOptions

	FrontMatter *FrontMatterOptions
}

type RegistryGuideFileCheck

type RegistryGuideFileCheck struct {
	FileCheck

	Options *RegistryGuideFileOptions
}

func NewRegistryGuideFileCheck

func NewRegistryGuideFileCheck(opts *RegistryGuideFileOptions) *RegistryGuideFileCheck

func (*RegistryGuideFileCheck) Run

func (check *RegistryGuideFileCheck) Run(path string) error

func (*RegistryGuideFileCheck) RunAll

func (check *RegistryGuideFileCheck) RunAll(files []string) error

type RegistryGuideFileOptions

type RegistryGuideFileOptions struct {
	*FileOptions

	FrontMatter *FrontMatterOptions
}

type RegistryIndexFileCheck

type RegistryIndexFileCheck struct {
	FileCheck

	Options *RegistryIndexFileOptions
}

func NewRegistryIndexFileCheck

func NewRegistryIndexFileCheck(opts *RegistryIndexFileOptions) *RegistryIndexFileCheck

func (*RegistryIndexFileCheck) Run

func (check *RegistryIndexFileCheck) Run(path string) error

func (*RegistryIndexFileCheck) RunAll

func (check *RegistryIndexFileCheck) RunAll(files []string) error

type RegistryIndexFileOptions

type RegistryIndexFileOptions struct {
	*FileOptions

	FrontMatter *FrontMatterOptions
}

type RegistryResourceFileCheck

type RegistryResourceFileCheck struct {
	FileCheck

	Options *RegistryResourceFileOptions
}

func (*RegistryResourceFileCheck) Run

func (check *RegistryResourceFileCheck) Run(path string, exampleLanguage string) error

func (*RegistryResourceFileCheck) RunAll

func (check *RegistryResourceFileCheck) RunAll(files []string, exampleLanguage string) error

type RegistryResourceFileOptions

type RegistryResourceFileOptions struct {
	*FileOptions

	Contents     *ContentsOptions
	FrontMatter  *FrontMatterOptions
	ProviderName string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL