Skip to content

Commit

Permalink
bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
psycofdj committed Jul 7, 2021
1 parent 787a343 commit c9d346d
Show file tree
Hide file tree
Showing 219 changed files with 9,717 additions and 17,461 deletions.
2 changes: 1 addition & 1 deletion boshupdate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package boshupdate
import (
"encoding/json"
"fmt"
"github.com/prometheus/common/log"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
"io"
"io/ioutil"
Expand Down
42 changes: 23 additions & 19 deletions boshupdate/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/cppforlife/go-patch/patch"
"github.com/google/go-github/github"
"github.com/pkg/errors"
"github.com/prometheus/common/log"
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"gopkg.in/yaml.v2"
"io/ioutil"
Expand Down Expand Up @@ -47,7 +47,7 @@ func NewManager(config Config) (*Manager, error) {

// GetBoshDeployments -
func (a *Manager) GetBoshDeployments() ([]BoshDeploymentData, error) {
entry := log.With("name", "deployments")
entry := log.WithField("name", "deployments")
entry.Debugf("processing bosh deployments")

res := []BoshDeploymentData{}
Expand Down Expand Up @@ -121,10 +121,11 @@ func (a *Manager) GetBoshDeployments() ([]BoshDeploymentData, error) {
func (a *Manager) GetGenericReleases() []GenericReleaseData {
results := []GenericReleaseData{}
for name, item := range a.config.Github.GenericReleases {
entry := log.
With("name", name).
With("repo", item.Repo).
With("owner", item.Owner)
entry := log.WithFields(log.Fields{
"name": name,
"repo": item.Repo,
"owner": item.Owner,
})
entry.Debugf("processing github release")

results = append(results, NewGenericReleaseData(*item, name))
Expand Down Expand Up @@ -159,10 +160,11 @@ func (a *Manager) GetManifestReleases() []ManifestReleaseData {
results = append(results, NewManifestReleaseData(*item, name))
target := &results[len(results)-1]

entry := log.
With("deployment", name).
With("repo", item.Repo).
With("owner", item.Owner)
entry := log.WithFields(log.Fields{
"deployment": name,
"repo": item.Repo,
"owner": item.Owner,
})
entry.Debugf("processing bosh deployment")

entry.Debugf("fetching release list")
Expand All @@ -182,11 +184,12 @@ func (a *Manager) GetManifestReleases() []ManifestReleaseData {
target.Versions = a.createVersions(refs, *lastRef, item.GenericReleaseConfig)
target.LatestVersion = NewVersion(lastRef.Ref, item.Format.Format(lastRef.Ref), lastRef.Time)

entry = log.
With("deployment", name).
With("repo", item.Repo).
With("owner", item.Owner).
With("version", target.LatestVersion.Version)
entry = log.WithFields(log.Fields{
"deployment": name,
"repo": item.Repo,
"owner": item.Owner,
"version": target.LatestVersion.Version,
})

if len(item.Manifest) == 0 {
continue
Expand Down Expand Up @@ -331,10 +334,11 @@ func (a *Manager) createVersions(refs []GithubRef, last GithubRef, item GenericR

// RenderManifest -
func (a *Manager) RenderManifest(manifest []byte, item ManifestReleaseData) ([]byte, error) {
entry := log.
With("name", item.Name).
With("repo", item.Repo).
With("owner", item.Owner)
entry := log.WithFields(log.Fields{
"name": item.Name,
"repo": item.Repo,
"owner": item.Owner,
})
entry.Debugf("rendering final manifest")

tpl := boshtpl.NewTemplate(manifest)
Expand Down
29 changes: 21 additions & 8 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/orange-cloudfoundry/boshupdate_exporter/boshupdate"
"github.com/prometheus/common/log"
log "github.com/sirupsen/logrus"
"github.com/prometheus/common/version"
"gopkg.in/alecthomas/kingpin.v2"
"gopkg.in/yaml.v2"
Expand All @@ -12,21 +12,34 @@ import (

var (
configFile = kingpin.Flag("config", "Configuration file path").Required().File()
logLevel = kingpin.Flag(
"log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]",
).Default("info").String()
logStream = kingpin.Flag(
"log.stream", "Write log to given stream. Valid streams: [stdout, stderr]",
).Default("stderr").String()
logJson = kingpin.Flag(
"log.json", "When given, write log in json format",
).Bool()
)

func main() {
kingpin.Version(version.Print("boshupdate_cli"))
kingpin.HelpFlag.Short('h')
kingpin.Parse()

log.Base().SetFormat("logger://stderr")
log.Base().SetLevel("error")

config := boshupdate.NewConfig(*configFile)
log.Base().SetLevel(config.Log.Level)
if config.Log.JSON {
log.Base().SetFormat("logger://stderr?json=true")
log.SetLevel(log.ErrorLevel)
if lvl, err := log.ParseLevel(*logLevel); err == nil {
log.SetLevel(lvl)
}
log.SetOutput(os.Stderr)
if *logStream == "stdout" {
log.SetOutput(os.Stdout)
}
if *logJson {
log.SetFormatter(&log.JSONFormatter{})
}
config := boshupdate.NewConfig(*configFile)

var content []byte
manager, err := boshupdate.NewManager(*config)
Expand Down
2 changes: 1 addition & 1 deletion exporter/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/orange-cloudfoundry/boshupdate_exporter/boshupdate"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/common/log"
log "github.com/sirupsen/logrus"
"time"
)

Expand Down
25 changes: 23 additions & 2 deletions exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"github.com/orange-cloudfoundry/boshupdate_exporter/boshupdate"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
log "github.com/sirupsen/logrus"
"github.com/prometheus/common/version"
"gopkg.in/alecthomas/kingpin.v2"
"net/http"
Expand Down Expand Up @@ -47,6 +47,16 @@ var (
tlsKeyFile = kingpin.Flag(
"web.tls.key_file", "Path to a file that contains the TLS private key (PEM format) ($BOSHUPDATE_EXPORTER_WEB_TLS_KEYFILE)",
).Envar("BOSHUPDATE_EXPORTER_WEB_TLS_KEYFILE").ExistingFile()

logLevel = kingpin.Flag(
"log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]",
).Default("info").String()
logStream = kingpin.Flag(
"log.stream", "Write log to given stream. Valid streams: [stdout, stderr]",
).Default("stderr").String()
logJson = kingpin.Flag(
"log.json", "When given, write log in json format",
).Bool()
)

type basicAuthHandler struct {
Expand Down Expand Up @@ -79,11 +89,22 @@ func prometheusHandler() http.Handler {
}

func main() {
log.AddFlags(kingpin.CommandLine)
kingpin.Version(version.Print("boshupdate_exporter"))
kingpin.HelpFlag.Short('h')
kingpin.Parse()

log.SetLevel(log.ErrorLevel)
if lvl, err := log.ParseLevel(*logLevel); err == nil {
log.SetLevel(lvl)
}
log.SetOutput(os.Stderr)
if *logStream == "stdout" {
log.SetOutput(os.Stdout)
}
if *logJson {
log.SetFormatter(&log.JSONFormatter{})
}

log.Infoln("Starting boshupdate_exporter", version.Info())
log.Infoln("Build context", version.BuildContext())

Expand Down
17 changes: 7 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 // indirect
github.com/cloudfoundry/bosh-cli v6.4.1+incompatible
github.com/cloudfoundry/bosh-utils v0.0.0-20210320100230-b112c198f4b7
github.com/cloudfoundry/bosh-utils v0.0.264
github.com/cppforlife/go-patch v0.2.0
github.com/cppforlife/go-semi-semantic v0.0.0-20160921010311-576b6af77ae4 // indirect
github.com/golang/protobuf v1.5.1 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.1.0 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.10.0
github.com/prometheus/common v0.20.0
github.com/sirupsen/logrus v1.8.1 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/net v0.0.0-20210324051636-2c4c8ecb7826 // indirect
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 // indirect
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/common v0.29.0
github.com/prometheus/procfs v0.7.0 // indirect
github.com/sirupsen/logrus v1.8.1
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/yaml.v2 v2.4.0
)
Loading

0 comments on commit c9d346d

Please sign in to comment.