config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GithubClient

func GithubClient(config *Config, token *string) *github.Client

Types

type Config

type Config struct {
	Projects []string `yaml:"projects"`
	Git      Git      `yaml:"git"`
}

Settings read from a config file.

func ReadConfig

func ReadConfig(path string) *Config

Doesn't mind if the expected fields are missing from the config file. Default values are supplied if they are missing. Exits the program if parsing the config file failed.

type Env

type Env struct {
	C    *github.Client
	W    *Witness
	L    *Lookups
	T    *Terminal
	Conf *Config
}

Our global runtime environment. Passing these as a group simplifies a number of function calls. Not every function that receives `Env` will need every value, but in practice this isn't a problem.

func RuntimeEnv

func RuntimeEnv(conf *Config, client *github.Client) *Env

Everything necessary for coordinated concurrency and Github lookups.

type Git

type Git struct {
	Name  string `yaml:"name"`
	Email string `yaml:"email"`
	User  string `yaml:"user"`
	Token string `yaml:"token"`
}

type Lookups

type Lookups struct {
	Vers map[string]string
	Mut  sync.Mutex
}

For Actions that actually had a valid 'latest' release, we store the version thereof. This is separate from `Witness`, since all _attempted_ lookups might not have had an actual result. Keeping them separate also allows for slightly less locking.

type Terminal

type Terminal struct {
	Scan *bufio.Scanner
	Mut  sync.Mutex
}

If changes were detected for a given workflow file, we want to prompt the user for confirmation before applying them. The update detection process is concurrent however, and there would be trouble if multiple prompts appeared at the same time.

type Witness

type Witness struct {
	Seen map[string]bool
	Mut  sync.Mutex
}

During the lookup of the latest version of an `Action`, we don't want to call the Github API more than once per Action. The `seen` map keeps a record of lookup attempts.

Jump to

Keyboard shortcuts

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