more prg nil checks

This commit is contained in:
Michael Quigley 2023-02-15 21:06:00 -05:00
parent 03af25ff60
commit 405e1c847c
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -104,24 +104,32 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
cmd.endpointError(zrd.ApiEndpoint())
os.Exit(1)
}
if err != nil {
prg.Send("writing the environment details...")
}
apiEndpoint, _ := zrd.ApiEndpoint()
zrd.Env = &zrokdir.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}
if err := zrd.Save(); err != nil {
if prg != nil {
prg.Send(fmt.Sprintf("there was an error saving the new environment: %v", err))
prg.Quit()
}
<-done
os.Exit(1)
}
if err := zrokdir.SaveZitiIdentity("backend", resp.Payload.Cfg); err != nil {
if prg != nil {
prg.Send(fmt.Sprintf("there was an error writing the environment: %v", err))
prg.Quit()
}
<-done
os.Exit(1)
}
if prg != nil {
prg.Send(fmt.Sprintf("the zrok environment was successfully enabled..."))
prg.Quit()
}
<-done
}