Documentation
¶
Index ¶
- Variables
- type ChainedLicenseResolver
- type ChainedTranslator
- type ErrBlacklistedModule
- type ErrDeniedLicense
- type License
- type LicenseResolver
- type LicenseResolverMock
- type LicensedModule
- type Module
- type ModuleMatcher
- type NotifyingValidator
- type NotifyingValidatorParams
- type RuleSet
- type RuleSetValidator
- type RuleSetValidatorParams
- type Translator
- type TranslatorMock
- type UnknownLicenseAction
- type UnknownLicenseNotifier
- type UnknownLicenseNotifierMock
- type Validator
- type ValidatorMock
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnknownLicense = fmt.Errorf("unknown license")
Functions ¶
This section is empty.
Types ¶
type ChainedLicenseResolver ¶
type ChainedLicenseResolver struct {
LicenseResolvers []LicenseResolver
}
ChainedLicenseResolver calls all resolvers until success If no success calls happened it returns ErrUnknownLicense
func (*ChainedLicenseResolver) ResolveLicense ¶
type ChainedTranslator ¶
type ChainedTranslator struct {
Translators []Translator
}
ChainedTranslator calls all translators until error passing translated module to next translator
type ErrBlacklistedModule ¶
type ErrBlacklistedModule struct {
Module LicensedModule
Matcher ModuleMatcher
}
func (*ErrBlacklistedModule) Error ¶
func (e *ErrBlacklistedModule) Error() string
type ErrDeniedLicense ¶
type ErrDeniedLicense struct {
Module LicensedModule
}
func (*ErrDeniedLicense) Error ¶
func (e *ErrDeniedLicense) Error() string
type License ¶
type LicenseResolver ¶
type LicenseResolverMock ¶
func (*LicenseResolverMock) ResolveLicense ¶
type LicensedModule ¶
LicensedModule represents a module with found license
func (*LicensedModule) String ¶
func (lm *LicensedModule) String() string
type ModuleMatcher ¶
type ModuleMatcher struct {
Name *regexp.Regexp
Version *semver.Constraints
}
ModuleMatcher defines a module matcher
func (*ModuleMatcher) Match ¶
func (mm *ModuleMatcher) Match(m *Module) bool
func (*ModuleMatcher) String ¶
func (mm *ModuleMatcher) String() string
type NotifyingValidator ¶
type NotifyingValidator struct {
NotifyingValidatorParams
// contains filtered or unexported fields
}
NotifyingValidator is a wrapper for Validator interface which performs notifications if requested by user
func NewNotifyingValidator ¶
func NewNotifyingValidator(log *zap.Logger, params NotifyingValidatorParams) *NotifyingValidator
type NotifyingValidatorParams ¶
type NotifyingValidatorParams struct {
Validator Validator
UnknownLicenseAction UnknownLicenseAction
UnknownLicenseNotifier UnknownLicenseNotifier
}
type RuleSet ¶
type RuleSet struct {
// WhitelistedModules always gives positive validation result
WhitelistedModules []ModuleMatcher
// BlacklistedModules always gives negative validation result
BlacklistedModules []ModuleMatcher
// AllowedLicenses contains set of allowed licenses
// If provided only modules with matched license will be allowed
AllowedLicenses []License
// DeniedLicenses contains set of denied licenses
DeniedLicenses []License
}
RuleSet represents module validation rule set
func (*RuleSet) Validate ¶
func (rs *RuleSet) Validate(lm LicensedModule) error
Validate validates provided module against rule set
type RuleSetValidator ¶
type RuleSetValidator struct {
RuleSetValidatorParams
// contains filtered or unexported fields
}
func NewRuleSetValidator ¶
func NewRuleSetValidator(logger *zap.Logger, validatorParams RuleSetValidatorParams) *RuleSetValidator
type RuleSetValidatorParams ¶
type RuleSetValidatorParams struct {
Translator Translator
LicenseResolver LicenseResolver
RuleSet RuleSet
}
type Translator ¶
type TranslatorMock ¶
type UnknownLicenseAction ¶
type UnknownLicenseAction int
const ( // UnknownLicenseAllow allows modules with non-determined license UnknownLicenseAllow UnknownLicenseAction = iota // UnknownLicenseWarn acts as UnknownLicenseAllow but explicitly notifies about it UnknownLicenseWarn // UnknownLicenseDeny fails validation for modules with non-determined license UnknownLicenseDeny )
type UnknownLicenseNotifier ¶
type UnknownLicenseNotifierMock ¶
func (*UnknownLicenseNotifierMock) NotifyUnknownLicense ¶
func (m *UnknownLicenseNotifierMock) NotifyUnknownLicense(ctx context.Context, module Module) error
Click to show internal directories.
Click to hide internal directories.