diff --git a/email/template.go b/email/template.go index 988fe2f..71ceebe 100644 --- a/email/template.go +++ b/email/template.go @@ -4,10 +4,9 @@ import ( "bytes" "html/template" "io" - "os" - "path" "time" + "github.com/spf13/viper" "github.com/waisbrot/birdweather_daily_email/birdweather" ) @@ -23,12 +22,7 @@ type StationTemplate struct { } func readTemplate() *template.Template { - exePath, err := os.Executable() - if err != nil { - panic(err) - } - execDir := path.Dir(exePath) - templateFile := path.Join(execDir, "countEmail.tmpl") + templateFile := viper.GetString("email.template") template, err := template.New("countEmail.tmpl").ParseFiles(templateFile) if err != nil { panic(err) diff --git a/example_config.yaml b/example_config.yaml index db90b11..886dc8d 100644 --- a/example_config.yaml +++ b/example_config.yaml @@ -9,6 +9,7 @@ email: port: 123 user: baz@example.com pass: setecastronomy + template: /path/to/template stations: - 123 - 456 diff --git a/metrics/influx.go b/metrics/influx.go index a1a6236..e91928c 100644 --- a/metrics/influx.go +++ b/metrics/influx.go @@ -2,8 +2,6 @@ package metrics import ( "context" - "crypto/tls" - "crypto/x509" "time" influxdb "github.com/influxdata/influxdb-client-go/v2" @@ -17,16 +15,8 @@ var writeAPI influxapi.WriteAPIBlocking var invokeTime time.Time func initInflux() { + influxdb.DefaultOptions().AddDefaultTag("application", "birdweather_digest") influxClient = influxdb.NewClient(viper.GetString("influx.url"), viper.GetString("influx.token")) - rootCas, err := x509.SystemCertPool() - if err != nil { - panic(err) - } - config := &tls.Config{ - RootCAs: rootCas, - InsecureSkipVerify: true, - } - influxdb.DefaultOptions().AddDefaultTag("application", "birdweather_digest").SetTLSConfig(config) writeAPI = influxClient.WriteAPIBlocking(viper.GetString("influx.org"), viper.GetString("influx.bucket")) produceMetrics = true }