lint

package
v2.13.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlainTextOutput string = "plain-text"
	JSONOutput      string = "json"
)

Variables

View Source
var DockerfileLinters = []Linter{
	&DockerfileCommandLinter{},
}
View Source
var K8sManifestLinters = []Linter{
	&YamlFieldLinter{},
}
View Source
var SkaffoldYamlLinters = []Linter{
	&YamlFieldLinter{},
}

Functions

func GetDockerfilesLintResults

func GetDockerfilesLintResults(ctx context.Context, opts Options, dockerCfg docker.Config) (*[]Result, error)

func GetK8sManifestsLintResults

func GetK8sManifestsLintResults(ctx context.Context, opts Options) (*[]Result, error)

func GetSkaffoldYamlsLintResults

func GetSkaffoldYamlsLintResults(ctx context.Context, opts Options) (*[]Result, error)

func Lint

func Lint(ctx context.Context, out io.Writer, opts Options, dockerCfg docker.Config) error

func OutputFormatter

func OutputFormatter(out io.Writer, opt string) format.Formatter

Types

type ConfigFile

type ConfigFile struct {
	AbsPath string
	RelPath string
	Text    string
}

type DockerCommandFilter

type DockerCommandFilter struct {
	DockerCommand          string
	DockerCopyDestRegExp   string
	DockerCopySourceRegExp string
}

type DockerfileCommandLinter

type DockerfileCommandLinter struct{}

func (*DockerfileCommandLinter) Lint

func (*DockerfileCommandLinter) Lint(params InputParams, rules *[]Rule) (*[]Result, error)

type InputParams

type InputParams struct {
	ConfigFile               ConfigFile
	DockerfileToDepMap       map[string][]string
	DockerfileToFromToToDeps map[string]map[string][]string
	SkaffoldConfig           *parser.SkaffoldConfigEntry
	DockerCopyCommandInfo    docker.FromTo
	WorkspacePath            string
	DockerConfig             docker.Config
}

type Linter

type Linter interface {
	Lint(InputParams, *[]Rule) (*[]Result, error)
}

type Options

type Options struct {
	// Filename is the `skaffold.yaml` file path
	Filename string
	// RemoteCacheDir is the directory for the remote cache
	RemoteCacheDir string
	// OutFormat is the output format. One of: json
	OutFormat string
	// Modules is the module filter for specific commands
	Modules []string
	// Profiles is the slice of profile names to activate.
	Profiles []string
}

Options holds flag values for the various `skaffold lint` commands

type Result

type Result struct {
	Rule        *Rule
	AbsFilePath string
	RelFilePath string
	Explanation string
	StartLine   int
	EndLine     int
	StartColumn int
	EndColumn   int
}

func GetAllLintResults

func GetAllLintResults(ctx context.Context, opts Options, dockerCfg docker.Config) ([]Result, error)

type Rule

type Rule struct {
	RuleID               RuleID
	RuleType             RuleType
	ExplanationTemplate  string
	Severity             protocol.DiagnosticSeverity
	Filter               interface{}
	ExplanationPopulator func(InputParams) (explanationInfo, error) `json:"-"`
	LintConditions       []func(InputParams) bool                   `json:"-"`
}

type RuleID

type RuleID int
const (
	DummyRuleIDForTesting RuleID = iota

	SkaffoldYamlAPIVersionOutOfDate
	SkaffoldYamlUseStaticPort
	SkaffoldYamlSyncPython

	DockerfileCopyOver1000Files
	DockerfileCopyContainsGitDir

	K8sManifestManagedByLabelInUse

	// TODO(aaron-prindle) see if it makes sense to add a rule type for each validation error possibility
	ValidationError
)

func (RuleID) String

func (a RuleID) String() string

type RuleType

type RuleType int
const (
	YamlFieldLintRule RuleType = iota
	DockerfileCommandLintRule
)

func (RuleType) String

func (a RuleType) String() string

type YamlFieldFilter

type YamlFieldFilter struct {
	Filter      yaml.Filter
	FieldMatch  string
	InvertMatch bool
}

type YamlFieldLinter

type YamlFieldLinter struct{}

func (*YamlFieldLinter) Lint

func (*YamlFieldLinter) Lint(lintInputs InputParams, rules *[]Rule) (*[]Result, error)

Jump to

Keyboard shortcuts

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