check

package
v1.44.1-0...-77b165e Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SliceDiff

func SliceDiff(want, got []string, caseInSensitive bool) (missed, spare []string)

Types

type Checker

type Checker interface {
	Line() int
	Key() string // property key path
	ShouldSkip() bool
	MDField() *model.Field

	// String display diff item information for check
	String() string

	// Fix try to fix this issue with line. return the updated line
	Fix(line string) (result string, err error)
}

type DiffResult

type DiffResult struct {
	// contains filtered or unexported fields
}

func DiffAll

func DiffAll(regs Resources, dryRun bool) *DiffResult

func NewDiffResult

func NewDiffResult() *DiffResult

func (*DiffResult) CostTime

func (d *DiffResult) CostTime() time.Duration

func (*DiffResult) FixDocuments

func (d *DiffResult) FixDocuments() (err error)

func (*DiffResult) GetResult

func (d *DiffResult) GetResult() []*ResourceDiff

func (*DiffResult) HasDiff

func (d *DiffResult) HasDiff() bool

func (*DiffResult) ToString

func (d *DiffResult) ToString() string

type Fixer

type Fixer struct {
	MDFile       string
	SchemaFile   string
	ResourceType string

	Diff []Checker // diff of exist in both md and code

	FixedContent string
}

Fixer fix document with diff

func NewFixer

func NewFixer(d *ResourceDiff) *Fixer

func (*Fixer) TryFix

func (f *Fixer) TryFix() (err error)

func (*Fixer) WriteBack

func (f *Fixer) WriteBack() (err error)

type ForceNewType

type ForceNewType int
const (
	ForceNewDefault ForceNewType = iota
	ShouldBeForceNew
	ShouldBeNotForceNew
)

func (ForceNewType) String

func (f ForceNewType) String() string

type MissType

type MissType int
const (
	NotMiss MissType = iota
	MissInDoc
	MissInCode
	MissInDocAttr
	MissBlockDeclare // document block declares wrong-formatted
	Misspelling
	MissWrongPlace // field nested in the wrong block
)

func (MissType) String

func (m MissType) String() string

type RequiredMiss

type RequiredMiss int
const (
	RequiredOK       RequiredMiss = iota // no need to fix requiredness
	ShouldBeRequired                     // code is required, but doc be optional or not specify
	ShouldBeOptional                     // code is optional, but doc be required or not specify
	ShouldBeComputed
)

func (RequiredMiss) String

func (r RequiredMiss) String() string

type ResourceDiff

type ResourceDiff struct {
	SchemaFile string
	MDFile     string

	Diff []Checker // diff of exist in both md and code
	// contains filtered or unexported fields
}

func NewResourceDiff

func NewResourceDiff(tf *schema.Resource) *ResourceDiff

NewResourceDiff tf is required, mdPath is optional, it can be detected by resource name

func (*ResourceDiff) DiffAll

func (r *ResourceDiff) DiffAll()

func (*ResourceDiff) Diffs

func (d *ResourceDiff) Diffs() []Checker

func (*ResourceDiff) ToString

func (d *ResourceDiff) ToString() string

type Resources

type Resources struct {
	// contains filtered or unexported fields
}

func AzurermAllResources

func AzurermAllResources(service, skipService string, resources, skipResources string) Resources

type TimeoutDiffItem

type TimeoutDiffItem struct {
	Line int         // which line
	Type TimeoutType //
	Want int64       // correct timeout value in second
}

func NewTimeoutDiffItem

func NewTimeoutDiffItem(line int, typ TimeoutType, want int64) TimeoutDiffItem

func (*TimeoutDiffItem) FixLine

func (t *TimeoutDiffItem) FixLine(line string) string

func (*TimeoutDiffItem) GenLine

func (t *TimeoutDiffItem) GenLine(rt string) string

GenLine generate a line for timeout if not exists

func (*TimeoutDiffItem) ValueString

func (t *TimeoutDiffItem) ValueString() string

type TimeoutType

type TimeoutType int
const (
	TimeoutMissed TimeoutType = iota // no timeout part in document
	TimeoutCreate
	TimeoutRead
	TimeoutUpdate
	TimeoutDelete
)

func (TimeoutType) IngString

func (t TimeoutType) IngString() string

func (TimeoutType) String

func (t TimeoutType) String() string

Jump to

Keyboard shortcuts

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