mirror of
https://github.com/openziti/zrok.git
synced 2024-12-23 07:09:12 +01:00
better disable cleanup; keep frontend identity around after disable
This commit is contained in:
parent
462025f5fa
commit
201982f25f
@ -55,11 +55,16 @@ func (cmd *disableCommand) run(_ *cobra.Command, args []string) {
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
if err := zrokdir.Delete(); err != nil {
|
||||
if err := zrokdir.DeleteEnvironment(); err != nil {
|
||||
if !panicInstead {
|
||||
showError("error removing local zrok directory", err)
|
||||
showError("error removing zrok environment", err)
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
if err := zrokdir.DeleteZitiIdentity("backend"); err != nil {
|
||||
if !panicInstead {
|
||||
showError("error removing zrok backend identity", err)
|
||||
}
|
||||
}
|
||||
fmt.Printf("zrok environment '%v' disabled for '%v'\n", env.ZitiIdentityId, env.ZrokToken)
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
if err := zrokdir.WriteZitiIdentity("environment", resp.Payload.Cfg); err != nil {
|
||||
if err := zrokdir.SaveZitiIdentity("backend", resp.Payload.Cfg); err != nil {
|
||||
if !panicInstead {
|
||||
showError("there was an error writing the environment file", err)
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
zif, err := zrokdir.ZitiIdentityFile("environment")
|
||||
zif, err := zrokdir.ZitiIdentityFile("backend")
|
||||
if err != nil {
|
||||
ui.Close()
|
||||
if !panicInstead {
|
||||
|
@ -14,17 +14,6 @@ type Environment struct {
|
||||
ApiEndpoint string `json:"api_endpoint"`
|
||||
}
|
||||
|
||||
func Delete() error {
|
||||
path, err := zrokDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func LoadEnvironment() (*Environment, error) {
|
||||
ef, err := environmentFile()
|
||||
if err != nil {
|
||||
@ -59,7 +48,27 @@ func SaveEnvironment(env *Environment) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func WriteZitiIdentity(name, data string) error {
|
||||
func DeleteEnvironment() error {
|
||||
ef, err := environmentFile()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting environment file")
|
||||
}
|
||||
if err := os.Remove(ef); err != nil {
|
||||
return errors.Wrap(err, "error removing environment file")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ZitiIdentityFile(name string) (string, error) {
|
||||
zrd, err := zrokDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(zrd, "identities", fmt.Sprintf("%v.json", name)), nil
|
||||
}
|
||||
|
||||
func SaveZitiIdentity(name, data string) error {
|
||||
zif, err := ZitiIdentityFile(name)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -73,12 +82,15 @@ func WriteZitiIdentity(name, data string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ZitiIdentityFile(name string) (string, error) {
|
||||
zrd, err := zrokDir()
|
||||
func DeleteZitiIdentity(name string) error {
|
||||
zif, err := ZitiIdentityFile(name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return errors.Wrapf(err, "error getting ziti identity file path for '%v'", name)
|
||||
}
|
||||
return filepath.Join(zrd, "identities", fmt.Sprintf("%v.json", name)), nil
|
||||
if err := os.Remove(zif); err != nil {
|
||||
return errors.Wrapf(err, "error removing ziti identity file '%v'", zif)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func environmentFile() (string, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user