Skip to content

Commit 69f4ddb

Browse files
author
TP Honey
authored
(DRON-124) add Incomplete V2 (#65)
1 parent dd4f57e commit 69f4ddb

File tree

5 files changed

+170
-2
lines changed

5 files changed

+170
-2
lines changed

.golangci.yml

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
linters-settings:
2+
dupl:
3+
threshold: 100
4+
funlen:
5+
lines: 100
6+
statements: 50
7+
gci:
8+
local-prefixes: github.com/golangci/golangci-lint
9+
goconst:
10+
min-len: 3
11+
min-occurrences: 3
12+
gocritic:
13+
enabled-tags:
14+
- diagnostic
15+
- experimental
16+
- opinionated
17+
- performance
18+
- style
19+
disabled-checks:
20+
- dupImport # https://github.com/go-critic/go-critic/issues/845
21+
- ifElseChain
22+
- octalLiteral
23+
- whyNoLint
24+
- wrapperFunc
25+
gocyclo:
26+
min-complexity: 15
27+
goimports:
28+
local-prefixes: github.com/golangci/golangci-lint
29+
gomnd:
30+
settings:
31+
mnd:
32+
# don't include the "operation" and "assign"
33+
checks: argument,case,condition,return
34+
govet:
35+
check-shadowing: true
36+
settings:
37+
printf:
38+
funcs:
39+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
40+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
41+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
42+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
43+
lll:
44+
line-length: 200
45+
maligned:
46+
suggest-new: true
47+
misspell:
48+
locale: US
49+
nolintlint:
50+
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
51+
allow-unused: false # report any unused nolint directives
52+
require-explanation: false # don't require an explanation for nolint directives
53+
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
54+
55+
linters:
56+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
57+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
58+
disable-all: true
59+
enable:
60+
- bodyclose
61+
- deadcode
62+
- depguard
63+
- dogsled
64+
- errcheck
65+
- exportloopref
66+
- exhaustive
67+
- funlen
68+
- gochecknoinits
69+
- goconst
70+
- gocritic
71+
- gocyclo
72+
- gofmt
73+
- goimports
74+
- gomnd
75+
- goprintffuncname
76+
- gosec
77+
- gosimple
78+
- govet
79+
- ineffassign
80+
- lll
81+
- misspell
82+
- nakedret
83+
- noctx
84+
- nolintlint
85+
- revive
86+
- rowserrcheck
87+
- staticcheck
88+
- structcheck
89+
- stylecheck
90+
- typecheck
91+
- unconvert
92+
- unparam
93+
- unused
94+
- varcheck
95+
- whitespace
96+
97+
# don't enable:
98+
# - asciicheck
99+
# - dupl
100+
# - scopelint
101+
# - gochecknoglobals
102+
# - gocognit
103+
# - godot
104+
# - godox
105+
# - goerr113
106+
# - interfacer
107+
# - maligned
108+
# - nestif
109+
# - prealloc
110+
# - testpackage
111+
# - revive
112+
# - wsl
113+
114+
issues:
115+
# Excluding configuration per-path, per-linter, per-text and per-source
116+
exclude-rules:
117+
- path: _test\.go
118+
linters:
119+
- gomnd
120+
121+
# https://github.com/go-critic/go-critic/issues/926
122+
- linters:
123+
- gocritic
124+
text: "unnecessaryDefer:"
125+
126+
run:
127+
skip-files:
128+
- _gen\.go

drone/client.go

+9
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const (
3131
pathFeed = "%s/api/user/feed"
3232
pathRepos = "%s/api/user/repos"
3333
pathIncomplete = "%s/api/builds/incomplete"
34+
pathIncompleteV2 = "%s/api/builds/incomplete/v2"
3435
pathReposAll = "%s/api/repos"
3536
pathRepo = "%s/api/repos/%s/%s"
3637
pathRepoMove = "%s/api/repos/%s/%s/move?to=%s"
@@ -168,6 +169,14 @@ func (c *client) Incomplete() ([]*Repo, error) {
168169
return out, err
169170
}
170171

172+
// IncompleteV2 returns a list of builds repos and any stages that are running/pending.
173+
func (c *client) IncompleteV2() ([]*RepoBuildStage, error) {
174+
var out []*RepoBuildStage
175+
uri := fmt.Sprintf(pathIncompleteV2, c.addr)
176+
err := c.get(uri, &out)
177+
return out, err
178+
}
179+
171180
// Repo returns a repository by name.
172181
func (c *client) Repo(owner string, name string) (*Repo, error) {
173182
out := new(Repo)

drone/client_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ func TestLogsPurge(t *testing.T) {
684684
//
685685
// mock server and testdata.
686686
//
687-
688687
func mockHandler(w http.ResponseWriter, r *http.Request) {
689688
routes := []struct {
690689
verb string
@@ -886,7 +885,7 @@ func mockHandler(w http.ResponseWriter, r *http.Request) {
886885
break
887886
}
888887
w.WriteHeader(route.code)
889-
w.Write(body)
888+
_, _ = w.Write(body)
890889
return
891890
}
892891
w.WriteHeader(404)

drone/interface.go

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ type Client interface {
5252
// Incomplete returns a list of incomplete builds.
5353
Incomplete() ([]*Repo, error)
5454

55+
// IncompleteV2 returns a list of builds/repos/stages that are running/pending.
56+
IncompleteV2() ([]*RepoBuildStage, error)
57+
5558
// Repo returns a repository by name.
5659
Repo(namespace, name string) (*Repo, error)
5760

drone/types.go

+29
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,35 @@ type (
7676
Build Build `json:"build,omitempty"`
7777
}
7878

79+
RepoBuildStage struct {
80+
RepoNamespace string `json:"repo_namespace"`
81+
RepoName string `json:"repo_name"`
82+
RepoSlug string `json:"repo_slug"`
83+
BuildNumber int64 `json:"build_number"`
84+
BuildAuthor string `json:"build_author"`
85+
BuildAuthorName string `json:"build_author_name"`
86+
BuildAuthorEmail string `json:"build_author_email"`
87+
BuildAuthorAvatar string `json:"build_author_avatar"`
88+
BuildSender string `json:"build_sender"`
89+
BuildStarted int64 `json:"build_started"`
90+
BuildFinished int64 `json:"build_finished"`
91+
BuildCreated int64 `json:"build_created"`
92+
BuildUpdated int64 `json:"build_updated"`
93+
StageName string `json:"stage_name"`
94+
StageKind string `json:"stage_kind"`
95+
StageType string `json:"stage_type"`
96+
StageStatus string `json:"stage_status"`
97+
StageMachine string `json:"stage_machine"`
98+
StageOS string `json:"stage_os"`
99+
StageArch string `json:"stage_arch"`
100+
StageVariant string `json:"stage_variant"`
101+
StageKernel string `json:"stage_kernel"`
102+
StageLimit string `json:"stage_limit"`
103+
StageLimitRepo string `json:"stage_limit_repo"`
104+
StageStarted int64 `json:"stage_started"`
105+
StageStopped int64 `json:"stage_stopped"`
106+
}
107+
79108
// RepoPatch defines a repository patch request.
80109
RepoPatch struct {
81110
Config *string `json:"config_path,omitempty"`

0 commit comments

Comments
 (0)