Skip to content

Commit

Permalink
feat: print version
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenschneider committed Sep 28, 2021
1 parent 9707422 commit 529cc31
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
11 changes: 8 additions & 3 deletions cmd/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ var configPathPreferences = []string{
}

func main() {
util.InitLogging()

metrics.Version.WithLabelValues(internal.BuildVersion, internal.CommitHash, internal.BuildTime).SetToCurrentTime()
metrics.Version.WithLabelValues(internal.BuildVersion, internal.CommitHash).SetToCurrentTime()
defaultConfigPath := checkDefaultConfigFiles()
configPath := flag.String("config", defaultConfigPath, "Path to the config file")
once := flag.Bool("once", false, "Path to the config file")
version := flag.Bool("version", false, "Print version and exit")
flag.Parse()

if *version {
fmt.Printf("%s (commit: %s)", internal.BuildVersion, internal.CommitHash)
os.Exit(0)
}

util.InitLogging()
if nil == configPath {
log.Fatal().Msgf("No config path supplied")
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"dyndns/conf"
"dyndns/internal"
"dyndns/internal/common"
"dyndns/internal/events/mqtt"
"dyndns/internal/metrics"
Expand All @@ -11,6 +12,7 @@ import (
"dyndns/server/vault"
"encoding/json"
"flag"
"fmt"
"github.com/aws/aws-sdk-go/aws/credentials"
paho "github.com/eclipse/paho.mqtt.golang"
"github.com/rs/zerolog/log"
Expand All @@ -25,11 +27,17 @@ const notificationTopic = "dyndns/+"
var requestsChannel = make(chan common.Envelope)

func main() {
util.InitLogging()

metrics.Version.WithLabelValues(internal.BuildVersion, internal.CommitHash).SetToCurrentTime()
configPath := flag.String("config", defaultConfigPath, "Path to the config file")
version := flag.Bool("version", false, "Print version and exit")
flag.Parse()

if *version {
fmt.Printf("%s (commit: %s)", internal.BuildVersion, internal.CommitHash)
os.Exit(0)
}

util.InitLogging()
if nil == configPath {
log.Fatal().Msgf("No config path supplied")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
Version = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "version",
}, []string{"version", "hash", "built_at"})
}, []string{"version", "hash"})

DnsPropagationRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Expand Down

0 comments on commit 529cc31

Please sign in to comment.