staging: refactor
This commit is contained in:
@@ -37,8 +37,14 @@ import (
|
||||
|
||||
//go:generate mockgen -source=obs_utils.go -destination=mock/obs_utils.go -typed
|
||||
|
||||
type BuildResultOptions struct {
|
||||
BinaryList bool
|
||||
OldState string
|
||||
LastBuild bool
|
||||
}
|
||||
|
||||
type ObsStatusFetcherWithState interface {
|
||||
BuildStatusWithState(project string, oldstate string, packages ...string) (*BuildResultList, error)
|
||||
BuildStatusWithState(project string, opts *BuildResultOptions, packages ...string) (*BuildResultList, error)
|
||||
}
|
||||
|
||||
type ObsClient struct {
|
||||
@@ -699,20 +705,28 @@ func (c *ObsClient) ProjectConfig(project string) (string, error) {
|
||||
}
|
||||
|
||||
func (c *ObsClient) BuildStatus(project string, packages ...string) (*BuildResultList, error) {
|
||||
return c.BuildStatusWithState(project, "", packages...)
|
||||
return c.BuildStatusWithState(project, &BuildResultOptions{}, packages...)
|
||||
}
|
||||
|
||||
func (c *ObsClient) BuildStatusWithState(project string, oldstate string, packages ...string) (*BuildResultList, error) {
|
||||
func (c *ObsClient) LastBuildResults(project string, packages ...string) (*BuildResultList, error) {
|
||||
return c.BuildStatusWithState(project, &BuildResultOptions{LastBuild: true}, packages...)
|
||||
}
|
||||
|
||||
func (c *ObsClient) BuildStatusWithState(project string, opts *BuildResultOptions, packages ...string) (*BuildResultList, error) {
|
||||
u := c.baseUrl.JoinPath("build", project, "_result")
|
||||
query := u.Query()
|
||||
query.Add("view", "status")
|
||||
// query.Add("view", "binarylist")
|
||||
if opts.BinaryList {
|
||||
query.Add("view", "binarylist")
|
||||
}
|
||||
query.Add("multibuild", "1")
|
||||
if len(oldstate) > 0 {
|
||||
query.Add("oldstate", oldstate)
|
||||
if len(opts.OldState) > 0 {
|
||||
query.Add("oldstate", opts.OldState)
|
||||
}
|
||||
if opts.LastBuild {
|
||||
query.Add("lastbuild", "1")
|
||||
}
|
||||
if len(packages) > 0 {
|
||||
query.Add("lastbuild", "1")
|
||||
for _, pkg := range packages {
|
||||
query.Add("package", pkg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user