policy

package
v0.0.0-...-9d3cee1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package policy provides definitions and functionality related to dependency policies

Index

Constants

View Source
const (
	// Allow is a rule kind that enumerates accepted dependencies
	Allow constraintKind = "allow"
	// Forbid is a rule kind that enumerates forbidden dependencies
	Forbid constraintKind = "forbid"
)
View Source
const (
	// Error error level
	Error errorLevel = "error"
	// Warn error level
	Warn errorLevel = "warn"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CanonicalConstraint

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

CanonicalConstraint is a plain raw (ie without references to components) dependency constraint

func (CanonicalConstraint) String

func (c CanonicalConstraint) String() string

type CheckResult

type CheckResult struct {
	Warns []error
	Errs  []error
}

CheckResult models the result of a dependency checking

type Checker

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

Checker models a dependencies constraints checker

func NewChecker

func NewChecker(p Policy, pkgs []*packages.Package, l logger) (*Checker, error)

NewChecker yields a dependencies constraint checker

func (Checker) CheckPkg

func (c Checker) CheckPkg(pkg *packages.Package, out chan<- CheckResult)

CheckPkg checks if the given package respects the dependency constraints of this checker

func (Checker) String

func (c Checker) String() string

String yields a string representation of this checker

type Constraint

type Constraint struct {
	Name    string
	Scope   string
	Kind    constraintKind
	Deps    string
	OnBreak errorLevel
}

Constraint represents the set of dependency constraints to enforce on a set of modules

type Policy

type Policy struct {
	Components map[string]interface{}

	Classes map[string]interface{}

	Constraints []Constraint
	// contains filtered or unexported fields
}

Policy represents the set of dependency constraints to enforce

func NewPolicyFromJSON

func NewPolicyFromJSON(stream io.Reader) (Policy, error)

NewPolicyFromJSON builds a Policy from a JSON

func (*Policy) ComponentsForPackage

func (p *Policy) ComponentsForPackage(pkg string) []string

ComponentsForPackage yields all components matching the given package Ideally, a package should match a single component but it will be not always the case

func (Policy) GetApplicableConstraints

func (p Policy) GetApplicableConstraints(pkg string) (constraints []CanonicalConstraint)

GetApplicableConstraints yields constraints applicable to a given package

Jump to

Keyboard shortcuts

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