cmd/microproxy: add a quick hack for some malformed variables.

Signed-off-by: David Anderson <danderson@tailscale.com>
reviewable/pr684/r1
David Anderson 4 years ago
parent 5a0c37aafd
commit c2b63ba363

@ -19,6 +19,7 @@ import (
"net/http/httputil" "net/http/httputil"
"net/url" "net/url"
"path/filepath" "path/filepath"
"strings"
"sync" "sync"
"time" "time"
@ -88,7 +89,16 @@ func promPrint(w io.Writer, prefix string, obj map[string]interface{}) {
case map[string]interface{}: case map[string]interface{}:
promPrint(w, k, v) promPrint(w, k, v)
case float64: case float64:
const saveConfigReject = "control_save_config_rejected_"
const saveConfig = "control_save_config_"
switch {
case strings.HasPrefix(k, saveConfigReject):
fmt.Fprintf(w, "control_save_config_rejected{reason=%q} %f\n", k[len(saveConfigReject):], v)
case strings.HasPrefix(k, saveConfig):
fmt.Fprintf(w, "control_save_config{reason=%q} %f\n", k[len(saveConfig):], v)
default:
fmt.Fprintf(w, "%s %f\n", k, v) fmt.Fprintf(w, "%s %f\n", k, v)
}
default: default:
fmt.Fprintf(w, "# Skipping key %q, unhandled type %T\n", k, v) fmt.Fprintf(w, "# Skipping key %q, unhandled type %T\n", k, v)
} }

Loading…
Cancel
Save