Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gitlab-runner-do-monitor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
Server Tools
gitlab-runner-do-monitor
Merge requests
!1
Initial release
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Initial release
fix/1-initial-release
into
master
Overview
0
Commits
14
Pipelines
8
Changes
1
Merged
Erick Hitter
requested to merge
fix/1-initial-release
into
master
6 years ago
Overview
0
Commits
14
Pipelines
8
Changes
1
Expand
Fixes
#1 (closed)
Edited
6 years ago
by
Erick Hitter
0
0
Merge request reports
Viewing commit
58a1bbae
Prev
Next
Show latest version
1 file
+
11
−
9
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
58a1bbae
Linting
· 58a1bbae
Erick Hitter
authored
6 years ago
glrdomon.go
+
11
−
9
Options
@@ -19,12 +19,12 @@ import (
type
config
struct
{
DebugDest
string
`json:"debug-dest"`
Debug
bool
`json:"debug"`
A
pi
Key
string
`json:"api-key"`
A
PI
Key
string
`json:"api-key"`
Threshold
int
`json:"threshold"`
Schedule
string
`json:"schedule"`
}
type
T
okenSource
struct
{
type
t
okenSource
struct
{
AccessToken
string
}
@@ -65,7 +65,7 @@ func init() {
debugDest
=
cfg
.
DebugDest
debug
=
cfg
.
Debug
apiKey
=
cfg
.
A
pi
Key
apiKey
=
cfg
.
A
PI
Key
threshold
=
cfg
.
Threshold
schedule
=
cfg
.
Schedule
@@ -92,7 +92,7 @@ func main() {
}
func
authenticate
()
{
tokenSource
:=
&
T
okenSource
{
tokenSource
:=
&
t
okenSource
{
AccessToken
:
apiKey
,
}
@@ -100,22 +100,24 @@ func authenticate() {
client
=
godo
.
NewClient
(
oauthClient
)
}
func
(
t
*
TokenSource
)
Token
()
(
*
oauth2
.
Token
,
error
)
{
// oAuth token
func
(
t
*
tokenSource
)
Token
()
(
*
oauth2
.
Token
,
error
)
{
token
:=
&
oauth2
.
Token
{
AccessToken
:
t
.
AccessToken
,
}
return
token
,
nil
}
func
startCron
()
{
c
:=
cron
.
New
()
c
.
AddFunc
(
schedule
,
checkA
pi
)
c
.
AddFunc
(
schedule
,
checkA
PI
)
c
.
Start
()
}
func
checkA
pi
()
{
c
ontex
t
:=
context
.
TODO
()
droplets
,
err
:=
listDroplets
(
c
ontex
t
,
client
)
func
checkA
PI
()
{
ct
x
:=
context
.
TODO
()
droplets
,
err
:=
listDroplets
(
ct
x
,
client
)
if
err
!=
nil
{
logger
.
Fatal
(
"Failed to retrieve droplet list"
)
}
Loading