From f60f06dde8656563bcb294c2ab5914b889bc9d0d Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 2 Sep 2022 13:13:59 -0400 Subject: [PATCH] protect against a second enabling (#49) --- cmd/zrok/enable.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/zrok/enable.go b/cmd/zrok/enable.go index 9d69a03a..a44aa243 100644 --- a/cmd/zrok/enable.go +++ b/cmd/zrok/enable.go @@ -6,6 +6,7 @@ import ( "github.com/openziti-test-kitchen/zrok/rest_client_zrok/identity" "github.com/openziti-test-kitchen/zrok/rest_model_zrok" "github.com/openziti-test-kitchen/zrok/zrokdir" + "github.com/pkg/errors" "github.com/shirou/gopsutil/v3/host" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -34,6 +35,11 @@ func newEnableCommand() *enableCommand { } func (cmd *enableCommand) run(_ *cobra.Command, args []string) { + env, err := zrokdir.LoadEnvironment() + if err == nil { + panic(errors.Errorf("environment '%v' already enabled!", env.ZitiIdentityId)) + } + token := args[0] hostName, hostDetail, err := getHost()