Documentation
¶
Index ¶
- Variables
- type ActionSpec
- type Changelog
- type GitHubClient
- type Github
- func (g *Github) Add(files []string) error
- func (g *Github) Changelog(version version.Version) (string, error)
- func (g *Github) ChangelogV3(version string) (string, error)
- func (g *Github) Checkout() error
- func (g *Github) Clean() error
- func (g *Github) Clone() (string, error)
- func (g *Github) Commit(message string) error
- func (g *Github) GetBranches() (sourceBranch, workingBranch, targetBranch string)
- func (g *Github) GetChangedFiles(workingDir string) ([]string, error)
- func (g *Github) GetDirectory() (directory string)
- func (g *Github) GetURL() string
- func (g *Github) IsRemoteBranchUpToDate() (bool, error)
- func (g *Github) Push() error
- func (g *Github) PushBranch(branch string) error
- func (g *Github) PushTag(tag string) error
- func (g *Github) SearchReleases(releaseType ReleaseType) (releases []string, err error)
- func (g *Github) SearchTags() (tags []string, err error)
- type GithubHandler
- type MockGitHubClient
- type PageInfo
- type PullRequest
- type PullRequestApi
- type RateLimit
- type ReleaseType
- type Repository
- type Spec
Constants ¶
This section is empty.
Variables ¶
var ( ErrAutomergeNotAllowOnRepository = errors.New("automerge is not allowed on repository") ErrBadMergeMethod = errors.New("wrong merge method defined, accepting one of 'squash', 'merge', 'rebase', or ''") )
Functions ¶
This section is empty.
Types ¶
type ActionSpec ¶ added in v0.40.0
type ActionSpec struct {
// Specifies if automerge is enabled for the new pullrequest
AutoMerge bool `yaml:",omitempty"`
// Specifies the Pull Request title
Title string `yaml:",omitempty"`
// Specifies user input description used during pull body creation
Description string `yaml:",omitempty"`
// Specifies repository labels used for the Pull Request. !! Labels must already exist on the repository
Labels []string `yaml:",omitempty"`
// Specifies if a Pull Request is set to draft, default false
Draft bool `yaml:",omitempty"`
// Specifies if maintainer can modify pullRequest
MaintainerCannotModify bool `yaml:",omitempty"`
// Specifies which merge method is used to incorporate the Pull Request. Accept "merge", "squash", "rebase", or ""
MergeMethod string `yaml:",omitempty"`
// Specifies to use the Pull Request title as commit message when using auto merge, only works for "squash" or "rebase"
UseTitleForAutoMerge bool `yaml:",omitempty"`
// Specifies if a Pull Request should be sent to the parent of a fork.
Parent bool `yaml:",omitempty"`
}
ActionSpec specifies the configuration of an action of type "GitHub Pull Request"
func (*ActionSpec) Validate ¶ added in v0.40.0
func (s *ActionSpec) Validate() error
Validate ensures that the provided ActionSpec is valid
type GitHubClient ¶
type GitHubClient interface {
Query(ctx context.Context, q interface{}, variables map[string]interface{}) error
Mutate(ctx context.Context, m interface{}, input githubv4.Input, variables map[string]interface{}) error
}
GitHubClient must be implemented by any GitHub query client (v4 API)
type Github ¶
type Github struct {
// Spec contains inputs coming from updatecli configuration
Spec Spec
// contains filtered or unexported fields
}
GitHub contains settings to interact with GitHub
func (*Github) ChangelogV3 ¶ added in v0.49.0
ChangelogV3 returns a changelog description based on a release name using the GitHub api v3 version
func (*Github) GetBranches ¶ added in v0.53.0
func (*Github) GetChangedFiles ¶
func (*Github) GetDirectory ¶
GetDirectory returns the local git repository path.
func (*Github) IsRemoteBranchUpToDate ¶ added in v0.45.0
IsRemoteBranchUpToDate checks if the branch reference name is published on on the default remote
func (*Github) PushBranch ¶ added in v0.44.0
PushBranch push tags
func (*Github) SearchReleases ¶
func (g *Github) SearchReleases(releaseType ReleaseType) (releases []string, err error)
SearchReleases return every releases from the github api ordered by reverse order of created time. Draft and pre-releases are filtered out.
func (*Github) SearchTags ¶
SearchTags return every tags from the github api return in reverse order of commit tags.
type GithubHandler ¶
type GithubHandler interface {
SearchReleases(releaseType ReleaseType) (releases []string, err error)
SearchTags() (tags []string, err error)
Changelog(version.Version) (string, error)
}
GithubHandler must be implemented by any GitHub module
type MockGitHubClient ¶
type MockGitHubClient struct {
// contains filtered or unexported fields
}
type PullRequest ¶
func NewAction ¶ added in v0.40.0
func NewAction(spec ActionSpec, gh *Github) (PullRequest, error)
func (*PullRequest) CreateAction ¶ added in v0.40.0
func (p *PullRequest) CreateAction(report reports.Action) error
func (*PullRequest) EnablePullRequestAutoMerge ¶
func (p *PullRequest) EnablePullRequestAutoMerge() error
EnablePullRequestAutoMerge updates an existing pullrequest with the flag automerge
func (*PullRequest) GetPullRequestLabelsInformation ¶
func (p *PullRequest) GetPullRequestLabelsInformation() ([]repositoryLabelApi, error)
getPullRequestLabelsInformation queries GitHub Api to retrieve every labels assigned to a pullRequest
func (*PullRequest) OpenPullRequest ¶
func (p *PullRequest) OpenPullRequest() error
OpenPullRequest creates a new GitHub Pull Request.
type PullRequestApi ¶
type PullRequestApi struct {
BaseRefName string
Body string
HeadRefName string
ID string
State string
Title string
Url string
Number int
}
PullRequest contains multiple fields mapped to GitHub V4 api
type ReleaseType ¶ added in v0.38.0
type ReleaseType struct {
// "Draft" enable/disable GitHub draft release
Draft bool
// "PreRelease" enable/disable GitHub PreRelease
PreRelease bool
// "Release" enable/disable GitHub release
Release bool
// "Latest" if set to true will only filter the release flag as latest.
Latest bool
}
ReleaseType specifies accepted GitHub Release type
func (*ReleaseType) Init ¶ added in v0.38.0
func (r *ReleaseType) Init()
func (ReleaseType) IsZero ¶ added in v0.38.0
func (r ReleaseType) IsZero() bool
IsZero checks if all release type are set to disable
type Repository ¶ added in v0.45.0
type Repository struct {
ID string
Name string
Owner string
ParentID string
ParentName string
ParentOwner string
}
Repository contains GitHub repository data
type Spec ¶
type Spec struct {
/*
"branch" defines the git branch to work on.
compatible:
* scm
default:
main
remark:
depending on which resource references the GitHub scm, the behavior will be different.
If the scm is linked to a source or a condition (using scmid), the branch will be used to retrieve
file(s) from that branch.
If the scm is linked to target then Updatecli creates a new "working branch" based on the branch value.
The working branch created by Updatecli looks like "updatecli_<pipelineID>".
It is worth mentioning that it is not possible to by pass the working branch in the current situation.
For more information, please refer to the following issue:
https://github.com/updatecli/updatecli/issues/1139
If you need to push changes to a specific branch, you must use the plugin "git" instead of this
*/
Branch string `yaml:",omitempty"`
/*
"directory" defines the local path where the git repository is cloned.
compatible:
* scm
remark:
Unless you know what you are doing, it is recommended to use the default value.
The reason is that Updatecli may automatically clean up the directory after a pipeline execution.
default:
/tmp/updatecli/github/<owner>/<repository>
*/
Directory string `yaml:",omitempty"`
/*
"email" defines the email used to commit changes.
compatible:
* scm
default:
default set to your global git configuration
*/
Email string `yaml:",omitempty"`
/*
"owner" defines the owner of a repository.
compatible:
* scm
*/
Owner string `yaml:",omitempty" jsonschema:"required"`
/*
repository specifies the name of a repository for a specific owner.
compatible:
* scm
*/
Repository string `yaml:",omitempty" jsonschema:"required"`
/*
"token" specifies the credential used to authenticate with GitHub API.
compatible:
* scm
*/
Token string `yaml:",omitempty" jsonschema:"required"`
/*
url specifies the default github url in case of GitHub enterprise
compatible:
* scm
default:
github.com
*/
URL string `yaml:",omitempty"`
/*
"username" specifies the username used to authenticate with GitHub API.
compatible:
* scm
remark:
the token is usually enough to authenticate with GitHub API.
*/
Username string `yaml:",omitempty"`
/*
"user" specifies the user associated with new git commit messages created by Updatecli
compatible:
* scm
*/
User string `yaml:",omitempty"`
/*
"gpg" specifies the GPG key and passphrased used for commit signing
compatible:
* scm
*/
GPG sign.GPGSpec `yaml:",omitempty"`
/*
"force" is used during the git push phase to run `git push --force`.
compatible:
* scm
default:
false
*/
Force bool `yaml:",omitempty"`
/*
"commitMessage" is used to generate the final commit message.
compatible:
* scm
remark:
it's worth mentioning that the commit message settings is applied to all targets linked to the same scm.
*/
CommitMessage commit.Commit `yaml:",omitempty"`
}
Spec represents the configuration input
func (*Spec) Merge ¶ added in v0.28.0
Merge returns nil if it successfully merges the child Spec into target receiver. Please note that child attributes always overrides receiver's
func (*Spec) MergeFromEnv ¶ added in v0.28.0
MergeFromEnv updates the target receiver with the "non zero-ed" environment variables