config

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRootDir

func GetRootDir() (string, error)

Types

type Config

type Config struct {
	ErrorLevel      errlevel.Level            `json:"error_level,omitempty"`
	ShownErrorLevel errlevel.Level            `json:"shown_error_level,omitempty"`
	Targets         []*Target                 `json:"targets,omitempty"`
	Outputs         Outputs                   `json:"outputs,omitempty"`
	ModuleArchives  map[string]*ModuleArchive `json:"module_archives,omitempty"`
	IgnoredPatterns []string                  `json:"ignore_patterns,omitempty"`
}

type DataFile added in v0.3.0

type DataFile struct {
	Path     string
	Excluded bool
}

func NewDataFile added in v0.3.0

func NewDataFile(s string) *DataFile

type LintFile

type LintFile struct {
	ID     string         `json:"id,omitempty"`
	Path   string         `json:"path,omitempty"`
	Config map[string]any `json:"config,omitempty"`
	Link   string         `json:"-"`
}

type LintGlob

type LintGlob struct {
	// Glob is either an absolute path or a relative path from configuration file path
	Glob     string         `json:"path"`
	Config   map[string]any `json:"config,omitempty"`
	Excluded bool           `json:"-"`
}

func (*LintGlob) Clean added in v0.3.0

func (lg *LintGlob) Clean()

func (*LintGlob) UnmarshalJSON

func (lg *LintGlob) UnmarshalJSON(b []byte) error

type LintGlobFile added in v0.3.0

type LintGlobFile struct {
	Path     string         `json:"path"`
	Config   map[string]any `json:"config,omitempty"`
	Excluded bool           `json:"-"`
}

func (*LintGlobFile) Clean added in v0.3.0

func (lg *LintGlobFile) Clean()

func (*LintGlobFile) UnmarshalJSON added in v0.3.0

func (lg *LintGlobFile) UnmarshalJSON(b []byte) error

type Module

type Module struct {
	Archive   *ModuleArchive
	SlashPath string
	Config    map[string]interface{}
}

func ParseImport

func ParseImport(line string) (*Module, error)

func (*Module) FilePath

func (m *Module) FilePath() string

type ModuleArchive

type ModuleArchive struct {
	Type      string `json:"type,omitempty"`
	Host      string `json:"host,omitempty"`
	RepoOwner string `json:"repo_owner,omitempty"`
	RepoName  string `json:"repo_name,omitempty"`
	Ref       string `json:"ref,omitempty"`
	Tag       string `json:"tag,omitempty"`
}

func (*ModuleArchive) FilePath

func (m *ModuleArchive) FilePath() string

func (*ModuleArchive) String added in v0.3.0

func (m *ModuleArchive) String() string

String returns a human readable string. This is different from file path. This is used for log.

func (*ModuleArchive) URL added in v0.4.6

func (m *ModuleArchive) URL(rootDir, p string) (string, error)

type ModuleGlob

type ModuleGlob struct {
	SlashPath string                 `json:"slash_path,omitempty"`
	Archive   *ModuleArchive         `json:"archive,omitempty"`
	Config    map[string]interface{} `json:"config,omitempty"`
	Files     []*LintGlobFile        `json:"files,omitempty"`
	Excluded  bool                   `json:"excluded,omitempty"`
}

func ParseModuleLine

func ParseModuleLine(line string) (*ModuleGlob, error)

type Output

type Output struct {
	ID string `json:"id"`
	// text/template, html/template, jsonnet
	Renderer string `json:"renderer"`
	// path to a template file
	Template string `json:"template"`
	// parameter
	Config map[string]any `json:"config"`
	// Transform is a transformation file path.
	// A transformation file transforms lint results before the results are outputted.
	// A tranformation file must be a Jsonnet.
	// A file path must be an absolute path, a relative path from the configuration file, or a module path.
	// e.g.
	// transform.jsonnnet
	// /home/foo/.lintent/transform.jsonnnet
	// github_archive/github.com/lintnet/modules/transform.jsonnet@32ca3be646ec5b5861aab72fed30cd71f6eba9bf:v0.1.2
	Transform string `json:"transform"`

	TemplateModule  *Module `json:"-"`
	TransformModule *Module `json:"-"`
}

func (*Output) Preprocess added in v0.3.0

func (o *Output) Preprocess(modules map[string]*ModuleArchive) error

type Outputs added in v0.3.0

type Outputs []*Output

func (Outputs) Output added in v0.3.0

func (os Outputs) Output(id string) *Output

func (Outputs) Preprocess added in v0.3.0

func (os Outputs) Preprocess(modules map[string]*ModuleArchive) error

type RawConfig

type RawConfig struct {
	FilePath        string       `json:"-"`
	ErrorLevel      string       `json:"error_level,omitempty"`
	ShownErrorLevel string       `json:"shown_error_level,omitempty"`
	IgnoredDirs     []string     `json:"ignored_dirs,omitempty"`
	Targets         []*RawTarget `json:"targets"`
	Outputs         Outputs      `json:"outputs,omitempty"`
}

func (*RawConfig) GetTarget added in v0.3.0

func (rc *RawConfig) GetTarget(targetID string) (*RawTarget, error)

func (*RawConfig) Parse

func (rc *RawConfig) Parse() (*Config, error)

Parse processes a raw configuration.

type RawModule

type RawModule struct {
	Glob   string          `json:"path"`
	Files  []*LintGlobFile `json:"files,omitempty"`
	Config map[string]any  `json:"config"`
}

func (*RawModule) Parse

func (rm *RawModule) Parse() (*ModuleGlob, error)

func (*RawModule) UnmarshalJSON

func (rm *RawModule) UnmarshalJSON(b []byte) error

type RawTarget

type RawTarget struct {
	ID           string       `json:"id,omitempty"`
	BaseDataPath string       `json:"base_data_path,omitempty"`
	LintGlobs    []*LintGlob  `json:"lint_files"`
	Modules      []*RawModule `json:"modules"`
	DataFiles    []string     `json:"data_files"`
}

func (*RawTarget) Parse

func (rt *RawTarget) Parse() (*Target, error)

type Target

type Target struct {
	ID             string                    `json:"id,omitempty"`
	BaseDataPath   string                    `json:"base_data_path,omitempty"`
	LintFiles      []*LintGlob               `json:"lint_files,omitempty"`
	Modules        []*ModuleGlob             `json:"modules,omitempty"`
	ModuleArchives map[string]*ModuleArchive `json:"module_archives,omitempty"`
	DataFiles      []*DataFile               `json:"data_files,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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