Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-runner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Seipel
gitlab-runner
Commits
c8c82b32
Unverified
Commit
c8c82b32
authored
8 years ago
by
Tomasz Maczukin
Browse files
Options
Downloads
Patches
Plain Diff
Add "info" command
parent
cf673a22
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
commands/builds_helper.go
+4
-0
4 additions, 0 deletions
commands/builds_helper.go
commands/info.go
+50
-0
50 additions, 0 deletions
commands/info.go
commands/multi.go
+1
-1
1 addition, 1 deletion
commands/multi.go
with
55 additions
and
1 deletion
commands/builds_helper.go
+
4
−
0
View file @
c8c82b32
...
@@ -91,3 +91,7 @@ func (b *buildsHelper) removeBuild(deleteBuild *common.Build) bool {
...
@@ -91,3 +91,7 @@ func (b *buildsHelper) removeBuild(deleteBuild *common.Build) bool {
}
}
return
false
return
false
}
}
func
(
b
*
buildsHelper
)
buildsCount
()
int
{
return
len
(
b
.
builds
)
}
This diff is collapsed.
Click to expand it.
commands/info.go
0 → 100644
+
50
−
0
View file @
c8c82b32
package
commands
import
(
"encoding/json"
"fmt"
log
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/common"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/helpers"
)
type
InfoData
struct
{
BuildsCount
int
`json:"builds_count"`
RunnersBuildsCounts
map
[
string
]
int
`json:"runners_builds_counts"`
VersionInfo
common
.
AppVersionInfo
`json:"version_info"`
}
type
InfoCommand
struct
{
buildsHelper
buildsHelper
data
InfoData
}
func
(
c
*
InfoCommand
)
prepare
()
{
c
.
data
.
BuildsCount
=
c
.
buildsHelper
.
buildsCount
()
c
.
data
.
VersionInfo
=
common
.
AppVersion
runnersBuildsCounts
:=
map
[
string
]
int
{}
for
token
,
count
:=
range
c
.
buildsHelper
.
counts
{
runnersBuildsCounts
[
helpers
.
ShortenToken
(
token
)]
=
count
}
c
.
data
.
RunnersBuildsCounts
=
runnersBuildsCounts
}
func
(
c
*
InfoCommand
)
Execute
(
context
*
cli
.
Context
)
{
c
.
prepare
()
bytes
,
err
:=
json
.
Marshal
(
c
.
data
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Errorln
(
"Error with InfoData marshalling to JSON"
)
return
}
fmt
.
Print
(
string
(
bytes
))
}
func
init
()
{
common
.
RegisterCommand2
(
"info"
,
"show statistic and debuging data"
,
&
InfoCommand
{})
}
This diff is collapsed.
Click to expand it.
commands/multi.go
+
1
−
1
View file @
c8c82b32
...
@@ -56,7 +56,7 @@ type RunCommand struct {
...
@@ -56,7 +56,7 @@ type RunCommand struct {
}
}
func
(
mr
*
RunCommand
)
log
()
*
log
.
Entry
{
func
(
mr
*
RunCommand
)
log
()
*
log
.
Entry
{
return
log
.
WithField
(
"builds"
,
len
(
mr
.
buildsHelper
.
builds
))
return
log
.
WithField
(
"builds"
,
mr
.
buildsHelper
.
builds
Count
(
))
}
}
func
(
mr
*
RunCommand
)
feedRunner
(
runner
*
common
.
RunnerConfig
,
runners
chan
*
common
.
RunnerConfig
)
{
func
(
mr
*
RunCommand
)
feedRunner
(
runner
*
common
.
RunnerConfig
,
runners
chan
*
common
.
RunnerConfig
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment