From c53f24c562a7d0950cb8a18197c65efc0cee325d Mon Sep 17 00:00:00 2001 From: Patrick Jahns Date: Tue, 28 Apr 2020 04:26:24 +0200 Subject: [PATCH] feat: ability to specify cli flags via env variables --- pkg/command/command.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/command/command.go b/pkg/command/command.go index 6c60240..91317a1 100644 --- a/pkg/command/command.go +++ b/pkg/command/command.go @@ -48,6 +48,7 @@ func Run() error { Aliases: []string{"web.listen-address"}, Value: "0.0.0.0:9176", Usage: "Address to bind the metrics server", + EnvVars: []string{"OPENVPN_EXPORTER_WEB_ADDRESS"}, Destination: &cfg.Server.Addr, }, &cli.StringFlag{ @@ -55,27 +56,32 @@ func Run() error { Aliases: []string{"web.telemetry-path"}, Value: "/metrics", Usage: "Path to bind the metrics server", + EnvVars: []string{"OPENVPN_EXPORTER_WEB_PATH"}, Destination: &cfg.Server.Path, }, &cli.StringFlag{ Name: "web.root", Value: "/", Usage: "Root path to exporter endpoints", + EnvVars: []string{"OPENVPN_EXPORTER_WEB_ROOT"}, Destination: &cfg.Server.Root, }, &cli.StringSliceFlag{ Name: "status-file", Usage: "The OpenVPN status file(s) to export (example test:./example/version1.status )", + EnvVars: []string{"OPENVPN_EXPORTER_STATUS_FILE"}, Required: true, }, &cli.BoolFlag{ Name: "disable-client-metrics", Usage: "Disables per client (bytes_received, bytes_sent, connected_since) metrics", + EnvVars: []string{"OPENVPN_EXPORTER_DISABLE_CLIENT_METRICS"}, }, &cli.BoolFlag{ Name: "enable-golang-metrics", Value: false, Usage: "Enables golang and process metrics for the exporter) ", + EnvVars: []string{"OPENVPN_EXPORTER_ENABLE_GOLANG_METRICS"}, Destination: &cfg.ExportGoMetrics, }, }