config

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 18 Imported by: 11

Documentation

Overview

Package config knows how to read and parse config.yaml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchRequirements

func BranchRequirements(org, repo, branch string, presubmits map[string][]job.Presubmit) ([]string, []string, []string)

BranchRequirements partitions status contexts for a given org, repo branch into three buckets:

  • contexts that are always required to be present
  • contexts that are required, _if_ present
  • contexts that are always optional

func VolumeMountPaths

func VolumeMountPaths() []string

VolumeMountPaths returns a string slice with *MountPath consts in it.

func VolumeMounts

func VolumeMounts() []string

VolumeMounts returns a string slice with *MountName consts in it.

Types

type Agent

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

Agent watches a path and automatically loads the config stored therein.

func (*Agent) Config

func (ca *Agent) Config() *Config

Config returns the latest config. Do not modify the config.

func (*Agent) Set

func (ca *Agent) Set(c *Config)

Set sets the config. Useful for testing.

func (*Agent) Subscribe

func (ca *Agent) Subscribe(subscription DeltaChan)

Subscribe registers the channel for messages on config reload. The caller can expect a copy of the previous and current config to be sent down the subscribed channel when a new configuration is loaded.

type Config

type Config struct {
	JobConfig
	ProwConfig
}

Config is a read-only snapshot of the config.

func Load

func Load(prowConfig, jobConfig string) (c *Config, err error)

Load loads and parses the config at path.

func LoadYAMLConfig

func LoadYAMLConfig(data []byte) (*Config, error)

LoadYAMLConfig loads the configuration from the given data

func (*Config) GetBranchProtection

func (c *Config) GetBranchProtection(org, repo, branch string) (*branchprotection.Policy, error)

GetBranchProtection returns the policy for a given branch.

Handles merging any policies defined at repo/org/global levels into the branch policy.

func (*Config) GetDeployments added in v1.16.0

func (c *Config) GetDeployments(repository scm.Repository) []job.Deployment

GetDeployments lets return all the deployments

func (Config) GetKeeperContextPolicy

func (c Config) GetKeeperContextPolicy(org, repo, branch string) (*keeper.ContextPolicy, error)

GetKeeperContextPolicy parses the prow config to find context merge options. If none are set, it will use the prow jobs configured and use the default github combined status. Otherwise if set it will use the branch protection setting, or the listed jobs.

func (*Config) GetPolicy

func (c *Config) GetPolicy(org, repo, branch string, b branchprotection.Branch) (*branchprotection.Policy, error)

GetPolicy returns the protection policy for the branch, after merging in presubmits.

func (*Config) GetPostsubmits

func (c *Config) GetPostsubmits(repository scm.Repository) []job.Postsubmit

GetPostsubmits lets return all the post submits

func (*Config) GetPresubmits

func (c *Config) GetPresubmits(repository scm.Repository) []job.Presubmit

GetPresubmits lets return all the pre submits for the given repo

type Cookie struct {
	Secret string `json:"secret,omitempty"`
}

Cookie holds the secret returned from github that authenticates the user who authorized this app.

type Delta

type Delta struct {
	Before, After Config
}

Delta represents the before and after states of a Config change detected by the Agent.

type DeltaChan

type DeltaChan = chan<- Delta

DeltaChan is a channel to receive config delta events when config changes.

type Getter

type Getter func() *Config

Getter returns the current Config in a thread-safe manner.

type GithubOAuthConfig

type GithubOAuthConfig struct {
	ClientID         string   `json:"client_id"`
	ClientSecret     string   `json:"client_secret"`
	RedirectURL      string   `json:"redirect_url"`
	Scopes           []string `json:"scopes,omitempty"`
	FinalRedirectURL string   `json:"final_redirect_url"`

	CookieStore *sessions.CookieStore `json:"-"`
}

GithubOAuthConfig is a config for requesting users access tokens from Github API. It also has a Cookie Store that retains user credentials deriving from Github API.

func (*GithubOAuthConfig) InitGithubOAuthConfig

func (gac *GithubOAuthConfig) InitGithubOAuthConfig(cookie *sessions.CookieStore)

InitGithubOAuthConfig creates an OAuthClient using GithubOAuth config and a Cookie Store to retain user credentials.

type JobConfig

type JobConfig = job.Config

JobConfig is a type alias for job.Config

type ProwConfig

type ProwConfig = lighthouse.Config

ProwConfig is a type alias for lighthouse.Config

Directories

Path Synopsis
Package secret implements an agent to read and reload the secrets.
Package secret implements an agent to read and reload the secrets.

Jump to

Keyboard shortcuts

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