-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #995 from mumoshu/model-gitops-src
Move ModelGitOps code into its own model_gitops.go
- Loading branch information
Showing
2 changed files
with
41 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
type ModelGitOps struct { | ||
github *GitHub | ||
git *GitOperator | ||
plugin GitOpsPlugin | ||
} | ||
|
||
type GitOpsPrepareOutput struct { | ||
PullRequestID string | ||
PullRequestNumber int | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,9 @@ | ||
package main | ||
|
||
type ModelGitOps struct { | ||
github *GitHub | ||
git *GitOperator | ||
plugin GitOpsPlugin | ||
} | ||
|
||
func NewModelKustomize(github *GitHub, git *GitOperator) ModelGitOps { | ||
return ModelGitOps{ | ||
github: github, | ||
git: git, | ||
plugin: NewGitOpsPluginKustomize(github, git), | ||
} | ||
} | ||
|
||
type GitOpsPrepareOutput struct { | ||
PullRequestID string | ||
PullRequestNumber int | ||
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 | ||
} |