Documentation
¶
Overview ¶
Package validation contains logic to perform project validation against provided rules This package contains only interfaces for module translation (to deal with vanity servers) and license resolution and it should not include such logic.
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
- type WebhookNotifier
- type WebhookNotifierParams
- type WebhookTemplateContext
Constants ¶
This section is empty.
Variables ¶
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 Module ¶
type Module struct { Name string Version *semver.Version }
Module represents go module
type ModuleMatcher ¶
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
type ValidatorMock ¶
type WebhookNotifier ¶ added in v0.0.5
type WebhookNotifier struct { WebhookNotifierParams // contains filtered or unexported fields }
WebhookNotifier calls http endpoint when license for projects with unknown license
func NewWebhookNotifier ¶ added in v0.0.5
func NewWebhookNotifier(log *zap.Logger, webhookNotifierParams WebhookNotifierParams) *WebhookNotifier
func (*WebhookNotifier) NotifyUnknownLicense ¶ added in v0.0.5
func (w *WebhookNotifier) NotifyUnknownLicense(ctx context.Context, m Module) error
type WebhookNotifierParams ¶ added in v0.0.5
type WebhookTemplateContext ¶ added in v0.0.5
type WebhookTemplateContext struct {
Module Module
}
WebhookTemplateContext is a request body template execution context