m/c/metroctl: add configurable credentials path

This lets metroctl users provide an alternative path to their cluster
credentials. This will be used by the upcoming metroctl test harness.

Change-Id: I49647e3b9d038c230b9678ebb73ba19da038a6d7
Reviewed-on: https://review.monogon.dev/c/monogon/+/833
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/cli/metroctl/main.go b/metropolis/cli/metroctl/main.go
index 9224598..7c1e050 100644
--- a/metropolis/cli/metroctl/main.go
+++ b/metropolis/cli/metroctl/main.go
@@ -1,6 +1,9 @@
 package main
 
 import (
+	"path/filepath"
+
+	"github.com/adrg/xdg"
 	"github.com/spf13/cobra"
 )
 
@@ -16,6 +19,8 @@
 	clusterEndpoints []string
 	// proxyAddr is a SOCKS5 proxy address the cluster will be accessed through.
 	proxyAddr string
+	// configPath overrides the default XDG config path
+	configPath string
 }
 
 var flags metroctlFlags
@@ -23,6 +28,7 @@
 func init() {
 	rootCmd.PersistentFlags().StringArrayVar(&flags.clusterEndpoints, "endpoints", nil, "A list of the target cluster's endpoints.")
 	rootCmd.PersistentFlags().StringVar(&flags.proxyAddr, "proxy", "", "SOCKS5 proxy address")
+	rootCmd.PersistentFlags().StringVar(&flags.configPath, "config", filepath.Join(xdg.ConfigHome, "metroctl"), "An alternative cluster config path")
 }
 
 func main() {