config

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2019 License: MPL-2.0 Imports: 18 Imported by: 20

Documentation

Overview

Package config implements application-level configuration functionality.

It works by loading configuration sources (e.g. CLI flags, configuration files, local VCS) and providing functions which compute relevant configuration values from these sources.

This design is intended to make how a particular value is computed very clear. All values can have their computation strategy modified independently of all other values. It should also be easy to determine which source set a particular configuration value.

Index

Constants

This section is empty.

Variables

View Source
var ErrFileNotFound = errors.New("no files existed")
View Source
var (
	MockBranch string
)

*** Mock configuration values ***

Functions

func APIKey added in v0.7.0

func APIKey() string

APIKey is user's FOSSA API key.

func BoolFlag added in v0.7.0

func BoolFlag(name string) bool

func Branch added in v0.7.0

func Branch() string

func Debug added in v0.7.0

func Debug() bool

Debug is true if the user has requested debug-level logging.

func Endpoint added in v0.7.0

func Endpoint() string

Endpoint is the desired FOSSA backend endpoint.

func ExistsFile added in v0.7.0

func ExistsFile() (bool, error)

func Fetcher added in v0.7.0

func Fetcher() string

func Filepath added in v0.7.0

func Filepath() string

Filepath is the configuration file path.

func Interactive added in v0.7.0

func Interactive() bool

Interactive is true if the user desires interactive output.

func JIRAProjectKey added in v0.7.6

func JIRAProjectKey() string
func Link() string

func Modules added in v0.7.0

func Modules() ([]module.Module, error)

func Options added in v0.7.0

func Options() (map[string]interface{}, error)

func Project added in v0.7.0

func Project() string

func ProjectURL added in v0.7.6

func ProjectURL() string

func Revision added in v0.7.0

func Revision() string

func SetContext added in v0.7.6

func SetContext(c *cli.Context) error

SetContext initializes application-level configuration.

func StringFlag added in v0.7.0

func StringFlag(name string) string

func Team added in v0.7.9

func Team() string

func Title added in v0.7.0

func Title() string

func TryFiles added in v0.7.0

func TryFiles(candidates ...string) (string, error)

func TryStrings added in v0.7.0

func TryStrings(candidates ...string) string

func UpdateFile added in v0.7.0

func UpdateFile(modules []module.Module) error

func Verbose added in v0.7.34

func Verbose() bool

Verbose is true if the user has requested verbose output.

func Version added in v0.7.22

func Version() int

Version outputs the installed FOSSA CLI version.

func WriteFile added in v0.7.0

func WriteFile(modules []module.Module) error

Types

type File added in v0.7.0

type File interface {
	GetVersion() int

	APIKey() string
	Server() string

	Title() string
	Fetcher() string
	Project() string
	Branch() string
	Revision() string
	ProjectURL() string
	JIRAProjectKey() string
	Link() string
	Team() string

	Modules() []module.Module
}

File defines the minimum interface for usage as a configuration file. We use an interface here in anticipation of new versions of configuration files, which will likely be implemented as different structs.

func InitFile added in v0.7.0

func InitFile(modules []module.Module) File

InitFile writes the current configuration to the current configuration file path.

func ReadFile added in v0.7.6

func ReadFile(c *cli.Context) (File, string, error)

ReadFile reads the configuration file specified by CLI flags.

type NoFile added in v0.7.0

type NoFile struct{}

func (NoFile) APIKey added in v0.7.0

func (_ NoFile) APIKey() string

func (NoFile) Branch added in v0.7.0

func (_ NoFile) Branch() string

func (NoFile) Fetcher added in v0.7.0

func (_ NoFile) Fetcher() string

func (NoFile) GetVersion added in v0.7.22

func (_ NoFile) GetVersion() int

func (NoFile) JIRAProjectKey added in v0.7.6

func (_ NoFile) JIRAProjectKey() string
func (_ NoFile) Link() string

func (NoFile) Modules added in v0.7.0

func (_ NoFile) Modules() []module.Module

func (NoFile) Project added in v0.7.0

func (_ NoFile) Project() string

func (NoFile) ProjectURL added in v0.7.6

func (_ NoFile) ProjectURL() string

func (NoFile) Revision added in v0.7.0

func (_ NoFile) Revision() string

func (NoFile) Server added in v0.7.0

func (_ NoFile) Server() string

func (NoFile) Team added in v0.7.9

func (_ NoFile) Team() string

func (NoFile) Title added in v0.7.0

func (_ NoFile) Title() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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