Documentation
¶
Index ¶
- Constants
- Variables
- func LoadRepoPolicies(policies *Policies) error
- func NewParams(paramNames ...string) runParameters
- func NewVariations() *variations
- func NonTrivialDiff(dir string, op, colours bool) ([]string, error)
- func Serve(port, tvDir string) error
- type AllTestsuiteVariations
- type AuthConfig
- type Bundle
- type DockerConfig
- type GHoutput
- type GitRepo
- func (r *GitRepo) AddFile(path string) (plumbing.Hash, error)
- func (r *GitRepo) Branch() string
- func (r *GitRepo) Branches(re string) ([]string, error)
- func (r *GitRepo) Commit(msg string) error
- func (r *GitRepo) CreateFile(path string) (*os.File, error)
- func (r *GitRepo) DeleteRemoteBranch(remoteBranch string) error
- func (r *GitRepo) EnableSigning(key *openpgp.Entity) error
- func (r *GitRepo) FetchBranch(branch string) error
- func (r *GitRepo) PullBranch(branch string) error
- func (r *GitRepo) Push(remoteBranch string) error
- func (r *GitRepo) RemoveAll(path string) error
- type GithubClient
- func (gh *GithubClient) ClosePR(prOpts *PullRequest) error
- func (gh *GithubClient) CreatePR(bv any, prOpts *PullRequest) (*github.PullRequest, error)
- func (gh *GithubClient) EnableAutoMerge(prID string) error
- func (gh *GithubClient) Open(prOpts *PullRequest) error
- func (gh *GithubClient) RenderPRTemplate(body *string, bv any) (*bytes.Buffer, error)
- func (gh *GithubClient) UpdatePrBranch(prOpts *PullRequest) error
- type JiraClient
- type JiraIssue
- type Matches
- type ParsedImageName
- type Policies
- type PullRequest
- type PushOptions
- type RepoPolicy
- func (rp *RepoPolicy) GetAllBranches() []string
- func (rp RepoPolicy) GetCC(target, host string) string
- func (rp RepoPolicy) GetDockerBuilds() buildMap
- func (rp RepoPolicy) GetDockerPlatforms() []string
- func (rp RepoPolicy) GetImages(repos ...string) []string
- func (rp *RepoPolicy) GetTimeStamp() (time.Time, error)
- func (rp RepoPolicy) HasBuild(build string) bool
- func (rp *RepoPolicy) ProcessBranch(pushOpts *PushOptions) error
- func (rp *RepoPolicy) SetBranch(branch string) error
- func (rp *RepoPolicy) SetTimestamp(ts time.Time)
- type Server
Constants ¶
const ( UNKNOWN_VALIDATOR validator = iota GORELEASER GHA )
const ( Testsuite = 0 Branch = 1 Trigger = 2 Repo = 3 )
Tree depth of ghMatrix
Variables ¶
var Green = "\033[32m"
var LBlue = "\033[94m"
var NoPRs = errors.New("no matching PRs found")
var Red = "\033[31m"
var Reset = "\033[0m"
var White = "\033[97m"
var Yellow = "\033[33m"
Functions ¶
func LoadRepoPolicies ¶
LoadRepoPolicies populates the supplied policies with the policy key from a the config file This will panic if the type assertions fail
func NewParams ¶
func NewParams(paramNames ...string) runParameters
NewParams looks in the environment for the named parameters and returns a map suitable for usage in versions.env and to decide the test scope
func NewVariations ¶
func NewVariations() *variations
Types ¶
type AllTestsuiteVariations ¶
type AllTestsuiteVariations map[string]variations
RepoTestsuiteVariations maps file→variations
func (AllTestsuiteVariations) Files ¶
func (av AllTestsuiteVariations) Files() []string
type AuthConfig ¶
type AuthConfig struct {
Auth string `json:"auth"`
}
type Bundle ¶
type Bundle struct {
Name string
// contains filtered or unexported fields
}
Bundle represents a directory tree, instantiated by NewBundle()
func (*Bundle) Add ¶
Add adds the path and corresponding template into the templateNode tree This code due to ChatGPT
type DockerConfig ¶
type DockerConfig struct {
Auths map[string]AuthConfig `json:"auths"`
}
func NewDockerAuths ¶
func NewDockerAuths(fname string) (*DockerConfig, error)
func (*DockerConfig) GetMatches ¶
func (d *DockerConfig) GetMatches(registry, tag string, repos []string) (Matches, error)
type GitRepo ¶
type GitRepo struct {
// contains filtered or unexported fields
}
GitRepo models a local git worktree with the authentication and enough metadata to allow it to be pushed it to github
func (*GitRepo) AddFile ¶
AddFile adds a file in the worktree to the index. The file is assumed to have been updated prior to calling this function.
func (*GitRepo) Branch ¶
Branch returns the short name of the ref HEAD is pointing to - provided the ref is a branch. Returns empty string if ref is not a branch.
func (*GitRepo) Branches ¶
(r *GitRepo) Branches will return a list of branches matching the supplied regexp for the repo
func (*GitRepo) Commit ¶
Commit adds all unstaged changes and commits the current worktree, confirming if asked Note that this commit will be lost if it is not pushed to a remote.
func (*GitRepo) CreateFile ¶
CreateFile will create a file in a directory, truncating it if it already exists with the embedded git worktree. Any intermediate directories are also created.
func (*GitRepo) DeleteRemoteBranch ¶
DeleteRemoteBranch deletes the given branch from the remote origin, this is mainly used in the test functions to delete the test branches, but can also be called from other contexts. Please note that it operates only on the origin remote.
func (*GitRepo) EnableSigning ¶
(r *GitRepo) EnableSignging will enable commits to be signed for this repo
func (*GitRepo) FetchBranch ¶
(r *GitRepo) FetchBranch fetches the given ref and then checks it out to the worktree Any local changes are lost. If the branch does not exist in the `origin` remote, an error is returned
func (*GitRepo) PullBranch ¶
(r *GitRepo) PullBranch will incorporate changes from origin. Only ff changes can be merged.
type GithubClient ¶
type GithubClient struct {
// contains filtered or unexported fields
}
func NewGithubClient ¶
func NewGithubClient(ghToken string) *GithubClient
NewGithubClient returns a client that uses the v3 (REST) API to talk to Github
func (*GithubClient) ClosePR ¶
func (gh *GithubClient) ClosePR(prOpts *PullRequest) error
(gh *GithubClient) ClosePR will close matching PRs without merging
func (*GithubClient) CreatePR ¶
func (gh *GithubClient) CreatePR(bv any, prOpts *PullRequest) (*github.PullRequest, error)
CreatePR will create a PR using the user supplied title and the embedded PR body If a PR already exists, it will return that PR
func (*GithubClient) EnableAutoMerge ¶
func (gh *GithubClient) EnableAutoMerge(prID string) error
EnableAutoMergePR uses the graphQL github v4 API with the PR ID (not number) to mutate graphQL PR object to enable automerge
func (*GithubClient) Open ¶
func (gh *GithubClient) Open(prOpts *PullRequest) error
(gh *GithubClient) Open will open the PR matching prOpts in the default browser
func (*GithubClient) RenderPRTemplate ¶
RenderPRTemplate will fill in the supplied template body with values from GitRepo
func (*GithubClient) UpdatePrBranch ¶
func (gh *GithubClient) UpdatePrBranch(prOpts *PullRequest) error
(gh *GithubClient) UpdatePR will update prOpts.PrBranch without needing a git checkout
type JiraClient ¶
type JiraClient struct {
// contains filtered or unexported fields
}
func NewJiraClient ¶
func NewJiraClient(email, token string) *JiraClient
NewJiraClient returns a client for v3 REST operations
func (*JiraClient) GetIssue ¶
func (j *JiraClient) GetIssue(id string) (*JiraIssue, error)
(j *JiraClient) GetIssue returns the issue after serialising the description Jira v3 API returns a structured version of the description, this function only understands a few types. Unknown content types are ignored.
type ParsedImageName ¶
func ParseImageName ¶
func ParseImageName(imageName string) *ParsedImageName
type Policies ¶
Policies models the config file structure. There are three levels at which a particular value can be set: group-level, repo, branch. The group level is applicable for all the repos in that group. Repeating the same repo in multiple groups is UB
func (*Policies) GetRepoPolicy ¶
func (p *Policies) GetRepoPolicy(repo string) (RepoPolicy, error)
GetRepoPolicy will fetch the RepoPolicy for the supplied repo with all overrides (group, repo, branch levels) processed. This is the constructor for RepoPolicy.
type PullRequest ¶
type PushOptions ¶
type PushOptions struct {
OpDir string
Branch string
RemoteBranch string
CommitMsg string
Repo *GitRepo
}
PushOptions collects the input required to update templates for a branch in git and push changes upstream
type RepoPolicy ¶
type RepoPolicy struct {
Owner string
Name string
Default string
PackageName string
Binary string
Builds buildMap
Reviewers []string
ExposePorts string
Cgo bool
ConfigFile string
VersionPackage string
UpgradeFromVer string
Branch string
Branchvals branchVals
Branches map[string]branchVals
Timestamp string
}
RepoPolicy is used to render templates. It provides an abstraction between config.yaml and the templates. It is instantiated from Policies for a particular repo and branch and the constructor implements all the overriding/merging logic between the various levels of the Policies type.
func (*RepoPolicy) GetAllBranches ¶
func (rp *RepoPolicy) GetAllBranches() []string
GetAllBranches returns all the branches that are managed for this repo
func (RepoPolicy) GetCC ¶
func (rp RepoPolicy) GetCC(target, host string) string
getCC returns the appropriate C compiler for the target architecture given the host architecture
func (RepoPolicy) GetDockerBuilds ¶
func (rp RepoPolicy) GetDockerBuilds() buildMap
getDockerBuilds returns a map of builds that have at least one container build
func (RepoPolicy) GetDockerPlatforms ¶
func (rp RepoPolicy) GetDockerPlatforms() []string
getDockerPlatforms returns the list of docker platforms that are to be supported
func (RepoPolicy) GetImages ¶
func (rp RepoPolicy) GetImages(repos ...string) []string
getImages returns the list of container manifests
func (*RepoPolicy) GetTimeStamp ¶
func (rp *RepoPolicy) GetTimeStamp() (time.Time, error)
GetTimeStamp returns the timestamp currently set for the given repopolicy.
func (RepoPolicy) HasBuild ¶
func (rp RepoPolicy) HasBuild(build string) bool
(rp RepoPolicy) HasBuild(build string) checks if the supplied build is defined
func (*RepoPolicy) ProcessBranch ¶
func (rp *RepoPolicy) ProcessBranch(pushOpts *PushOptions) error
ProcessBranch will render the templates into a git worktree for the supplied branch, commit and push the changes upstream The upstream branch name is the supplied branch name prefixed with releng/ and is returned
func (*RepoPolicy) SetBranch ¶
func (rp *RepoPolicy) SetBranch(branch string) error
SetBranch sets the Branch and Branchvals properties so that templates can simply access them instead of looking them up in the Branches map. This must be called before calling Render()
func (*RepoPolicy) SetTimestamp ¶
func (rp *RepoPolicy) SetTimestamp(ts time.Time)
SetTimestamp Sets the given time as the repopolicy timestamp. If called with zero time sets the current time in UTC