config

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllRegoVersions added in v0.30.0

func AllRegoVersions(root string, conf *Config) (map[string]ast.RegoVersion, error)

AllRegoVersions returns a map of all Rego versions found in the provided config and .manifest files, keyed by the path of the directory for which the version applies. Config file has higher precedence than .manifest files.

func FilterIgnoredPaths added in v0.8.0

func FilterIgnoredPaths(paths, ignore []string, checkFileExists bool, pathPrefix string) ([]string, error)

func FindBundleRootDirectories added in v0.26.0

func FindBundleRootDirectories(path string) ([]string, error)

FindBundleRootDirectories finds all bundle root directories from the provided path, which **must** be an absolute path. Bundle root directories may be found either by:

- Configuration (`project.roots`) - By the presence of a .manifest file anywhere under the path - By the presence of a .regal directory anywhere under or above the path ...

All returned paths are absolute paths. If the provided path itself is determined to be a bundle root directory it will be included in the result.

func FindConfig

func FindConfig(path string) (*os.File, error)

FindConfig attempts to find either the .regal directory or .regal.yaml config file, and returns the appropriate file or an error.

func FindRegalConfigFile added in v0.30.1

func FindRegalConfigFile(path string) (*os.File, error)

FindRegalConfigFile searches for a .regal.yaml config file upwards from the provided path.

func FindRegalDirectory

func FindRegalDirectory(path string) (*os.File, error)

FindRegalDirectory searches for a .regal directory upwards from the provided path.

func GetPotentialRoots added in v0.26.0

func GetPotentialRoots(paths ...string) ([]string, error)

func GlobalDir added in v0.24.0

func GlobalDir() string

GlobalDir is the config directory that will be used for user-wide configuration. This is different from the .regal directories that are searched for when linting.

func ToMap added in v0.8.0

func ToMap(config Config) map[string]any

Types

type Builtin added in v0.12.0

type Builtin struct {
	Decl Decl `json:"decl" yaml:"decl"`
}

type Capabilities added in v0.12.0

type Capabilities struct {
	Builtins       map[string]*Builtin `json:"builtins"        yaml:"builtins"`
	FutureKeywords []string            `json:"future_keywords" yaml:"future_keywords"`
	Features       []string            `json:"features"        yaml:"features"`
}

func CapabilitiesForThisVersion added in v0.12.0

func CapabilitiesForThisVersion() *Capabilities

CapabilitiesForThisVersion returns the capabilities for the current OPA version Regal depends on.

type Category

type Category map[string]Rule

type Config

type Config struct {
	// Defaults state is loaded from configuration under rules and so is not (un)marshalled
	// in the same way.
	Defaults        Defaults            `json:"-"                          yaml:"-"`
	Rules           map[string]Category `json:"rules"                      yaml:"rules"`
	Capabilities    *Capabilities       `json:"capabilities,omitempty"     yaml:"capabilities,omitempty"`
	Features        *Features           `json:"features,omitempty"         yaml:"features,omitempty"`
	Project         *Project            `json:"project,omitempty"          yaml:"project,omitempty"`
	CapabilitiesURL string              `json:"capabilities_url,omitempty" yaml:"capabilities_url,omitempty"`
	Ignore          Ignore              `json:"ignore,omitempty"           yaml:"ignore,omitempty"`
}

func FromMap

func FromMap(confMap map[string]any) (Config, error)

func LoadConfigWithDefaultsFromBundle added in v0.24.0

func LoadConfigWithDefaultsFromBundle(regalBundle *bundle.Bundle, userConfig *Config) (Config, error)

func (Config) MarshalYAML added in v0.19.0

func (config Config) MarshalYAML() (any, error)

func (*Config) UnmarshalYAML added in v0.12.0

func (config *Config) UnmarshalYAML(value *yaml.Node) error

type Decl added in v0.12.0

type Decl struct {
	Result string   `json:"result" yaml:"result"`
	Args   []string `json:"args"   yaml:"args"`
}

type Default added in v0.19.0

type Default struct {
	Level string `json:"level" yaml:"level"`
}

Default represents global or category settings for rules, currently only the level is supported.

type Defaults added in v0.19.0

type Defaults struct {
	Categories map[string]Default
	Global     Default
}

Defaults is used to store information about global and category defaults for rules.

type ExtraAttributes

type ExtraAttributes map[string]any

type Features added in v0.24.0

type Features struct {
	Remote *RemoteFeatures `json:"remote,omitempty" yaml:"remote,omitempty"`
}

type Ignore added in v0.5.0

type Ignore struct {
	Files []string `json:"files,omitempty" yaml:"files,omitempty"`
}

type Project added in v0.26.0

type Project struct {
	Roots *[]Root `json:"roots,omitempty" yaml:"roots,omitempty"`
	// Set the Rego version for the whole project or workspace. Individual roots may override this.
	RegoVersion *int `json:"rego-version,omitempty" yaml:"rego-version,omitempty"`
}

func (*Project) UnmarshalYAML added in v0.30.0

func (p *Project) UnmarshalYAML(value *yaml.Node) error

type RemoteFeatures added in v0.24.0

type RemoteFeatures struct {
	CheckVersion bool `json:"check-version,omitempty" yaml:"check-version,omitempty"`
}

type Root added in v0.30.0

type Root struct {
	Path string
	// Note that contrary to ast.RegoVersion, we'll only accept 0 or 1 here currently.
	// This aligns with the Rego versioning scheme used in .manifest files, which is
	// the alternative way to provide this for a specific directory.
	RegoVersion *int `json:"rego-version,omitempty" yaml:"rego-version,omitempty"`
}

type Rule

type Rule struct {
	Ignore *Ignore `json:"ignore,omitempty" yaml:"ignore,omitempty"`
	Extra  ExtraAttributes
	Level  string
}

func (*Rule) MarshalJSON

func (rule *Rule) MarshalJSON() ([]byte, error)

func (*Rule) MarshalYAML added in v0.8.0

func (rule *Rule) MarshalYAML() (interface{}, error)

func (*Rule) UnmarshalJSON

func (rule *Rule) UnmarshalJSON(data []byte) error

func (*Rule) UnmarshalYAML added in v0.8.0

func (rule *Rule) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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