m/cli/metroctl: add flag for k8s context name

Change-Id: I57b261e7fdb0ceef63f8ce5f098ecb322ed85874
Reviewed-on: https://review.monogon.dev/c/monogon/+/2825
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/cli/metroctl/cmd_takeownership.go b/metropolis/cli/metroctl/cmd_takeownership.go
index 18ad367..dd4bfb4 100644
--- a/metropolis/cli/metroctl/cmd_takeownership.go
+++ b/metropolis/cli/metroctl/cmd_takeownership.go
@@ -28,10 +28,15 @@
 }
 
 func doTakeOwnership(cmd *cobra.Command, _ []string) {
+	ctx := clicontext.WithInterrupt(context.Background())
 	if len(flags.clusterEndpoints) != 1 {
 		log.Fatalf("takeownership requires a single cluster endpoint to be provided with the --endpoints parameter.")
 	}
-	ctx := clicontext.WithInterrupt(context.Background())
+
+	contextName, err := cmd.Flags().GetString("context")
+	if err != nil || contextName == "" {
+		log.Fatalf("takeownership requires a valid context name to be provided with the --context parameter.")
+	}
 
 	ca, err := core.GetClusterCAWithTOFU(ctx, connectOptions())
 	if err != nil {
@@ -94,5 +99,6 @@
 }
 
 func init() {
+	takeownershipCommand.Flags().String("context", "metroctl", "The name for the kubernetes context to configure")
 	rootCmd.AddCommand(takeownershipCommand)
 }