protect against a second enabling (#49)

This commit is contained in:
Michael Quigley 2022-09-02 13:13:59 -04:00
parent e2c376e5ca
commit f60f06dde8
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -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()