-
Notifications
You must be signed in to change notification settings - Fork 7
/
model_gitops.go
47 lines (40 loc) · 1.15 KB
/
model_gitops.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
type ModelGitOps struct {
github *GitHub
git *GitOperator
plugin GitOpsPlugin
}
type GitOpsPrepareOutput struct {
// PullRequestID is the node ID of the pull request.
// It's used to merge and close the pull request using GitHub GraphQL API.
//
// Note that this is not the pull request ID, which is an integer,
// and used by non-GraphQL API to identify a pull request.
PullRequestID string
PullRequestNumber int
PullRequestHTMLURL string
Branch string
status DeployStatus
}
func (self GitOpsPrepareOutput) Status() DeployStatus {
return self.status
}
func (self GitOpsPrepareOutput) Message() string {
return "Success to deploy"
}
func (self ModelGitOps) Commit(pullRequestID string) error {
return self.github.MergePullRequest(pullRequestID)
}
func (self ModelGitOps) Deploy(pj DeployProject, phase string, option DeployOption) (do DeployOutput, err error) {
o, err := self.plugin.Prepare(pj, phase, option.Branch, option.Assigner, option.Tag)
if err != nil {
return
}
if o.Status() == DeployStatusSuccess {
err = self.Commit(o.PullRequestID)
if err != nil {
return
}
}
return o, nil
}