Skip to content

Commit

Permalink
(DRON-124) add ReposRunningStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
TP Honey committed Sep 15, 2021
1 parent dd4f57e commit 4e2678c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
9 changes: 9 additions & 0 deletions drone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
pathFeed = "%s/api/user/feed"
pathRepos = "%s/api/user/repos"
pathIncomplete = "%s/api/builds/incomplete"
pathRunningStatus = "%s/api/builds/running_status"
pathReposAll = "%s/api/repos"
pathRepo = "%s/api/repos/%s/%s"
pathRepoMove = "%s/api/repos/%s/%s/move?to=%s"
Expand Down Expand Up @@ -168,6 +169,14 @@ func (c *client) Incomplete() ([]*Repo, error) {
return out, err
}

// ReposRunningStatus returns a list of repos and any stages that are running/pending.
func (c *client) ReposRunningStatus() ([]*RepoBuildStageStatus, error) {
var out []*RepoBuildStageStatus
uri := fmt.Sprintf(pathRunningStatus, c.addr)
err := c.get(uri, &out)
return out, err
}

// Repo returns a repository by name.
func (c *client) Repo(owner string, name string) (*Repo, error) {
out := new(Repo)
Expand Down
2 changes: 1 addition & 1 deletion drone/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ func mockHandler(w http.ResponseWriter, r *http.Request) {
break
}
w.WriteHeader(route.code)
w.Write(body)
_, _ = w.Write(body)
return
}
w.WriteHeader(404)
Expand Down
3 changes: 3 additions & 0 deletions drone/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type Client interface {
// Incomplete returns a list of incomplete builds.
Incomplete() ([]*Repo, error)

// ReposRunningStatus returns a list of repos and any stages that are running/pending.
ReposRunningStatus() ([]*RepoBuildStageStatus, error)

// Repo returns a repository by name.
Repo(namespace, name string) (*Repo, error)

Expand Down
20 changes: 20 additions & 0 deletions drone/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ type (
Build Build `json:"build,omitempty"`
}

RepoBuildStageStatus struct {
RepoNamespace string `json:"repo_namespace"`
RepoName string `json:"repo_name"`
RepoSlug string `json:"repo_slug"`
BuildNumber int64 `json:"build_number"`
BuildAuthor string `json:"build_author"`
BuildAuthorName string `json:"build_author_name"`
BuildAuthorEmail string `json:"build_author_email"`
BuildAuthorAvatar string `json:"build_author_avatar"`
BuildSender string `json:"build_sender"`
StageName string `json:"stage_name"`
StageKind string `json:"stage_kind"`
StageType string `json:"stage_type"`
StageStatus string `json:"stage_status"`
StageOS string `json:"stage_os"`
StageArch string `json:"stage_arch"`
StageVariant string `json:"stage_variant"`
StageKernel string `json:"stage_kernel"`
}

// RepoPatch defines a repository patch request.
RepoPatch struct {
Config *string `json:"config_path,omitempty"`
Expand Down

0 comments on commit 4e2678c

Please sign in to comment.