Skip to content

Commit

Permalink
Improve autobump documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mpherman2 committed Jan 20, 2021
1 parent 5d64d2b commit 882fe0e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 47 deletions.
26 changes: 2 additions & 24 deletions experiment/autobumper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,8 @@ We need to fulfil those requirements to use this tool:
to be used by this tool to push changes and create PRs against the remote repo.
* a yaml config file that specifies the follwing information passed in with the flag -config=FILEPATH:
* gitHubOrg: The GitHub org name where the autobump PR will be created. Only required when SkipPullRequest is false.
* gitHubRepo: The GitHub repo name where the autobump PR will be created. Only required when SkipPullRequest is false.
* gitHubLogin: The GitHub username to use. If not specified, uses values from the user associated with the access token.
* gitHubToken: The path to the GitHub token file. Only required when SkipPullRequest is false.
* gitName: The name to use on the git commit. Only required when GitEmail is specified. If not specified, uses values from the user associated with the access token
* gitEmail: The email to use on the git commit. Only required when GitName is specified. If not specified, uses values from the user associated with the access token.
* onCallAddress: The oncall address where we can get the JSON file that stores the current oncall information.
* skipPullRequest: Whether to skip creating the pull request for this bump.
* upstreamURLBase: The URL where upstream images are located. Required only if Target Version is "upstream" or "upstreamStaging"
* includedConfigPaths: List of the config paths to be included in this bump, in which only .yaml files will be considered. By default all files are included.
* excludedConfigPaths: List of the config paths to be excluded in this bump, in which only .yaml files will be considered.
* extraFiles: The extra non-yaml file to be considered in this bump.
* targetVersion: The target version to bump images version to, which can be one of latest, upstream, upstream-staging and vYYYYMMDD-deadbeef.
* remoteName: The name used in the address when creating remote. Format will be git@github.com:{GitLogin}/{RemoteName}.git
* headBranchName: The name of the branch that will be used when creating the pull request. If unset, defaults to "autobump".
* prefixes: List of prefixes that the autobumped is looking for, and other information needed to bump them. The Fields for the Prefix are as follows:
* name: Name of the tool being bumped
* prefix: The image prefix that the autobumper should look for
* refConfigFile: File that is looked at when bumping to match upstream. Required only if targetVersion is "upstream"
* stagingRefConfigFile: File that is looked at when bumping to match upstreamStaging. Required only if targetVersion is "upstreamStaging"
* repo: Repo used when generating pull request
* summarise: Whether or not the format of the PR summary for this prefix should be summarised.
* consistentImages: Whether the prefix tags should be consistent after the bump
* For info about what should go in the config look at [the documentation for the Options here](https://pkg.go.dev/k8s.io/test-infra/experiment/autobumper/bumper#Options) and look at the example below.
e.g.,
```yaml
gitHubLogin: "k8s-ci-robot"
Expand Down
48 changes: 25 additions & 23 deletions experiment/autobumper/bumper/bumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,55 +84,55 @@ func (af *fileArrayFlag) Set(value string) error {

// Options is the options for autobumper operations.
type Options struct {
//The GitHub org name where the autobump PR will be created. Must not be empty when SkipPullRequest is false.
// The GitHub org name where the autobump PR will be created. Only required when SkipPullRequest is false.
GitHubOrg string `yaml:"gitHubOrg"`
//The GitHub repo name where the autobump PR will be created. Must not be empty when SkipPullRequest is false.
// The GitHub repo name where the autobump PR will be created. Only required when SkipPullRequest is false.
GitHubRepo string `yaml:"gitHubRepo"`
//The GitHub username to use. If not specified, uses values from the user associated with the access token.
// The GitHub username to use. If not specified, uses values from the user associated with the access token.
GitHubLogin string `yaml:"gitHubLogin"`
//The path to the GitHub token file.
// The path to the GitHub token file. Only required when SkipPullRequest is false.
GitHubToken string `yaml:"gitHubToken"`
//The name to use on the git commit. Requires GitEmail. If not specified, uses values from the user associated with the access token
// The name to use on the git commit. Only required when GitEmail is specified and SkipPullRequest is false. If not specified, uses values from the user associated with the access token
GitName string `yaml:"gitName"`
//"The email to use on the git commit. Requires GitName. If not specified, uses values from the user associated with the access token.
// The email to use on the git commit. Only required when GitName is specified and SkipPullRequest is false. If not specified, uses values from the user associated with the access token.
GitEmail string `yaml:"gitEmail"`
//The oncall address where we can get the JSON file that stores the current oncall information.
// The oncall address where we can get the JSON file that stores the current oncall information.
OncallAddress string `yaml:"onCallAddress"`
//Whether to skip creating the pull request for this bump.
// Whether to skip creating the pull request for this bump.
SkipPullRequest bool `yaml:"skipPullRequest"`
//The URL where upstream images are located. Must not be empty if Target Version is "upstream" or "upstreamStaging"
// The URL where upstream images are located. Only required if Target Version is "upstream" or "upstreamStaging"
UpstreamURLBase string `yaml:"upstreamURLBase"`
//The config paths to be included in this bump, in which only .yaml files will be considered. By default all files are included.
// The config paths to be included in this bump, in which only .yaml files will be considered. By default all files are included.
IncludedConfigPaths []string `yaml:"includedConfigPaths"`
//The config paths to be excluded in this bump, in which only .yaml files will be considered.
// The config paths to be excluded in this bump, in which only .yaml files will be considered.
ExcludedConfigPaths []string `yaml:"excludedConfigPaths"`
//The extra non-yaml file to be considered in this bump.
// The extra non-yaml file to be considered in this bump.
ExtraFiles []string `yaml:"extraFiles"`
//The target version to bump images version to, which can be one of latest, upstream, upstream-staging and vYYYYMMDD-deadbeef.
// The target version to bump images version to, which can be one of latest, upstream, upstream-staging and vYYYYMMDD-deadbeef.
TargetVersion string `yaml:"targetVersion"`
//The name used in the address when creating remote. Format will be git@github.com:{GitLogin}/{RemoteName}.git
// The name used in the address when creating remote. Format will be git@github.com:{GitLogin}/{RemoteName}.git
RemoteName string `yaml:"remoteName"`
//The name of the branch that will be used when creating the pull request. If unset, defaults to "autobump".
// The name of the branch that will be used when creating the pull request. If unset, defaults to "autobump".
HeadBranchName string `yaml:"headBranchName"`
//List of prefixes that the autobumped is looking for, and other information needed to bump them
// List of prefixes that the autobumped is looking for, and other information needed to bump them. Must have at least 1 prefix.
Prefixes []Prefix `yaml:"prefixes"`
}

// Prefix is the information needed for each prefix being bumped.
type Prefix struct {
//Name of the tool being bumped
// Name of the tool being bumped
Name string `yaml:"name"`
//The image prefix that the autobumper should look for
// The image prefix that the autobumper should look for
Prefix string `yaml:"prefix"`
//File that is looked at when bumping to match upstream
// File that is looked at to determine current upstream image when bumping to upstream. Required only if targetVersion is "upstream"
RefConfigFile string `yaml:"refConfigFile"`
//File that is looked at when bumping to match upstreamStaging
// File that is looked at to determine current upstream staging image when bumping to upstream staging. Required only if targetVersion is "upstream-staging"
StagingRefConfigFile string `yaml:"stagingRefConfigFile"`
//Repo used when generating pull request
// The source repo of the images to use for comparison links in the PR summary.
Repo string `yaml:"repo"`
//Whether or not the format of the PR summary for this prefix should be summarised.
// Whether or not the format of the PR summary for this prefix should be summarised.
Summarise bool `yaml:"summarise"`
//Whether the prefix tags should be consistent after the bump
// Whether the prefix tags should be consistent after the bump
ConsistentImages bool `yaml:"consistentImages"`
}

Expand Down Expand Up @@ -365,6 +365,8 @@ func UpdatePullRequest(gc github.Client, org, repo, title, body, source, baseBra
return UpdatePullRequestWithLabels(gc, org, repo, title, body, source, baseBranch, headBranch, allowMods, nil)
}

// UpdatePullRequestWithLabels updates with github client "gc" the PR of github repo org/repo
// with "title" and "body" of PR matching author and headBranch from "source" to "baseBranch" with labels
func UpdatePullRequestWithLabels(gc github.Client, org, repo, title, body, source, baseBranch, headBranch string, allowMods bool, labels []string) error {
logrus.Info("Creating or updating PR...")
n, err := updater.EnsurePRWithLabels(org, repo, title, body, source, baseBranch, headBranch, allowMods, gc, labels)
Expand Down

0 comments on commit 882fe0e

Please sign in to comment.