(DRON-124) add Incomplete V2 (#65)

pull/67/head
TP Honey 3 years ago committed by GitHub
parent dd4f57e66e
commit 69f4ddb192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,128 @@
linters-settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gci:
local-prefixes: github.com/golangci/golangci-lint
goconst:
min-len: 3
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
govet:
check-shadowing: true
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 200
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- errcheck
- exportloopref
- exhaustive
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- noctx
- nolintlint
- revive
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
# don't enable:
# - asciicheck
# - dupl
# - scopelint
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - interfacer
# - maligned
# - nestif
# - prealloc
# - testpackage
# - revive
# - wsl
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
run:
skip-files:
- _gen\.go

@ -31,6 +31,7 @@ const (
pathFeed = "%s/api/user/feed"
pathRepos = "%s/api/user/repos"
pathIncomplete = "%s/api/builds/incomplete"
pathIncompleteV2 = "%s/api/builds/incomplete/v2"
pathReposAll = "%s/api/repos"
pathRepo = "%s/api/repos/%s/%s"
pathRepoMove = "%s/api/repos/%s/%s/move?to=%s"
@ -168,6 +169,14 @@ func (c *client) Incomplete() ([]*Repo, error) {
return out, err
}
// IncompleteV2 returns a list of builds repos and any stages that are running/pending.
func (c *client) IncompleteV2() ([]*RepoBuildStage, error) {
var out []*RepoBuildStage
uri := fmt.Sprintf(pathIncompleteV2, 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)

@ -684,7 +684,6 @@ func TestLogsPurge(t *testing.T) {
//
// mock server and testdata.
//
func mockHandler(w http.ResponseWriter, r *http.Request) {
routes := []struct {
verb string
@ -886,7 +885,7 @@ func mockHandler(w http.ResponseWriter, r *http.Request) {
break
}
w.WriteHeader(route.code)
w.Write(body)
_, _ = w.Write(body)
return
}
w.WriteHeader(404)

@ -52,6 +52,9 @@ type Client interface {
// Incomplete returns a list of incomplete builds.
Incomplete() ([]*Repo, error)
// IncompleteV2 returns a list of builds/repos/stages that are running/pending.
IncompleteV2() ([]*RepoBuildStage, error)
// Repo returns a repository by name.
Repo(namespace, name string) (*Repo, error)

@ -76,6 +76,35 @@ type (
Build Build `json:"build,omitempty"`
}
RepoBuildStage 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"`
BuildStarted int64 `json:"build_started"`
BuildFinished int64 `json:"build_finished"`
BuildCreated int64 `json:"build_created"`
BuildUpdated int64 `json:"build_updated"`
StageName string `json:"stage_name"`
StageKind string `json:"stage_kind"`
StageType string `json:"stage_type"`
StageStatus string `json:"stage_status"`
StageMachine string `json:"stage_machine"`
StageOS string `json:"stage_os"`
StageArch string `json:"stage_arch"`
StageVariant string `json:"stage_variant"`
StageKernel string `json:"stage_kernel"`
StageLimit string `json:"stage_limit"`
StageLimitRepo string `json:"stage_limit_repo"`
StageStarted int64 `json:"stage_started"`
StageStopped int64 `json:"stage_stopped"`
}
// RepoPatch defines a repository patch request.
RepoPatch struct {
Config *string `json:"config_path,omitempty"`

Loading…
Cancel
Save