Skip to content
Snippets Groups Projects
Commit a8175080 authored by Erick Hitter's avatar Erick Hitter
Browse files

Merge branch 'fix/go-mod' into 'master'

Add go.mod

See merge request !5
parents 654dc412 a6a4ee7f
1 merge request!5Add go.mod
Pipeline #4759 passed with stages
in 7 minutes and 27 seconds
...@@ -21,7 +21,7 @@ before_script: ...@@ -21,7 +21,7 @@ before_script:
- cd $GOPATH/src/$REPO_NAME - cd $GOPATH/src/$REPO_NAME
- cp config-sample.json config.json - cp config-sample.json config.json
- export CC=clang-5.0 - export CC=clang
- make dep - make dep
...@@ -63,4 +63,4 @@ build: ...@@ -63,4 +63,4 @@ build:
- make - make
artifacts: artifacts:
paths: paths:
- gitlab-runner-do-monitor/ - gitlab-runner-do-monitor/
\ No newline at end of file
...@@ -30,7 +30,7 @@ dep: ...@@ -30,7 +30,7 @@ dep:
@go get github.com/mitchellh/gox @go get github.com/mitchellh/gox
build: dep build: dep
@gox -output="${CI_PROJECT_DIR}/${PROJECT_NAME}/{{.Dir}}_{{.OS}}_{{.Arch}}" -parallel=6 @gox -output="${CI_PROJECT_DIR}/${PROJECT_NAME}/{{.Dir}}_{{.OS}}_{{.Arch}}" -parallel=6 -osarch '!darwin/386'
clean: clean:
@rm -f $(PROJECT_NAME) @rm -f $(PROJECT_NAME)
......
...@@ -30,8 +30,7 @@ type tokenSource struct { ...@@ -30,8 +30,7 @@ type tokenSource struct {
var ( var (
configPath string configPath string
logger *log.Logger logger *log.Logger
logDest string
apiKey string apiKey string
threshold int threshold int
...@@ -42,7 +41,7 @@ var ( ...@@ -42,7 +41,7 @@ var (
client *godo.Client client *godo.Client
) )
func init() { func initConfig() {
flag.StringVar(&configPath, "config", "./config.json", "Path to configuration file") flag.StringVar(&configPath, "config", "./config.json", "Path to configuration file")
flag.Parse() flag.Parse()
...@@ -64,8 +63,7 @@ func init() { ...@@ -64,8 +63,7 @@ func init() {
threshold = cfg.Threshold threshold = cfg.Threshold
deleteStale = cfg.DeleteStale deleteStale = cfg.DeleteStale
logDest = cfg.LogDest setUpLogger(cfg.LogDest)
setUpLogger()
logger.Printf("Starting GitLab Runner monitoring with config %s", configPath) logger.Printf("Starting GitLab Runner monitoring with config %s", configPath)
...@@ -77,6 +75,7 @@ func init() { ...@@ -77,6 +75,7 @@ func init() {
} }
func main() { func main() {
initConfig()
authenticate() authenticate()
checkAPI() checkAPI()
...@@ -193,7 +192,7 @@ func deleteDroplet(droplet godo.Droplet) bool { ...@@ -193,7 +192,7 @@ func deleteDroplet(droplet godo.Droplet) bool {
return err == nil return err == nil
} }
func setUpLogger() { func setUpLogger(logDest string) {
logOpts := log.Ldate | log.Ltime | log.LUTC | log.Lshortfile logOpts := log.Ldate | log.Ltime | log.LUTC | log.Lshortfile
if logDest == "os.Stdout" { if logDest == "os.Stdout" {
......
...@@ -8,6 +8,9 @@ import ( ...@@ -8,6 +8,9 @@ import (
) )
func TestCheckDropletAge(t *testing.T) { func TestCheckDropletAge(t *testing.T) {
threshold = 3600
setUpLogger("os.Stdout")
staleDroplet := godo.Droplet{ staleDroplet := godo.Droplet{
ID: 1234, ID: 1234,
Name: "very-old", Name: "very-old",
......
go.mod 0 → 100644
module git.ethitter.com/debian/gitlab-runner-do-monitor
go 1.17
require (
github.com/digitalocean/godo v1.75.0
github.com/dustin/go-humanize v1.0.0
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
)
require (
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-querystring v1.0.0 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)
go.sum 0 → 100644
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment