conf

package
v0.6.18 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package conf contains code related to the configuration of the tool, which in turns specifies which upstream sources to fetch statements from, which sources are trusted, and how to merge statements according to one or more strategies

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

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

A Configuration encapsulates the relevant fields of configurations objects. This is used to hide the different configuration schema versions an provide a general API. This is the type that is ready everywere in the other packages.

func (*Configuration) Backend

func (c *Configuration) Backend() string

Backend returns the backend from which to export

func (*Configuration) ExportDenylist

func (c *Configuration) ExportDenylist() []string

ExportDenylist returns the ExportScripts to generate

func (*Configuration) ExportScripts

func (c *Configuration) ExportScripts() []ExportScript

ExportScripts returns the ExportScripts to generate

func (*Configuration) Policies

func (c *Configuration) Policies() []Policy

Policies returns the Policies from which to export

func (*Configuration) Sources

func (c *Configuration) Sources() []Source

Sources returns the sources (as a slice)

func (*Configuration) Validate

func (c *Configuration) Validate() (ok bool, err error)

Validate checks consistency of configuration

func (*Configuration) Version

func (c *Configuration) Version() string

Version returns the configuration schema version

type ExportScript

type ExportScript struct {
	Target   string
	Filename string
	Pre      string
	Each     string
	Post     string
}

ExportScript defines how to generate import scripts for a set of statements

type Parser

type Parser struct {
	viper.Viper
}

Parser is responsible for parsing the configuration file in order to generate a configuration object

func NewParser

func NewParser(cfgFile string) (*Parser, error)

NewParser creates a new Parser and initializes the viper configuration

func (*Parser) Parse

func (p *Parser) Parse() (config Configuration, err error)

Parse parses the configuration file according to the version specified This method produces as output a Configuration object that hides the differences in the configuration schema versions. All the logic to handle different versions should be invisible to the client of Configuration instances.

func (*Parser) SetConfigFile

func (p *Parser) SetConfigFile(configFile string)

SetConfigFile allows to inject an additional config file overriding what was set previously

type Policy

type Policy int

A Policy determines how statements from different source repositories are to be merged (reconciled, when conflicting)

const (
	None Policy = iota
	Strict
	Soft
	Latest
	Oldest
)

Enumeration of the existing policy names

func PolicyFromString

func PolicyFromString(p string) Policy

PolicyFromString converts a policy name into a Policy instance

func (Policy) String

func (p Policy) String() string

type Source

type Source struct {
	Repo   string `yaml:"repo"`
	Branch string `yaml:"branch"`
	Signed bool   `yaml:"signed"`
	Rank   int    `yaml:"rank"`
}

A Source represents a remote repository in which vulnerability statements are stored

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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