store api endpoint in zrokdir (#47)

This commit is contained in:
Michael Quigley 2022-09-21 15:09:12 -04:00
parent 65209caa53
commit f3f887e535
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
6 changed files with 8 additions and 7 deletions

View File

@ -46,7 +46,7 @@ func (cmd *createAccountCommand) run(_ *cobra.Command, _ []string) {
fmt.Println("entered emails do not match... aborting!")
}
zrok, err := newZrokClient()
zrok, err := newZrokClient(apiEndpoint)
if err != nil {
panic(err)
}

View File

@ -33,7 +33,7 @@ func (cmd *disableCommand) run(_ *cobra.Command, args []string) {
if err != nil {
panic(err)
}
zrok, err := newZrokClient()
zrok, err := newZrokClient(env.ApiEndpoint)
if err != nil {
panic(err)
}

View File

@ -55,7 +55,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
cmd.description = fmt.Sprintf("%v@%v", user.Username, hostName)
}
zrok, err := newZrokClient()
zrok, err := newZrokClient(apiEndpoint)
if err != nil {
panic(err)
}
@ -69,7 +69,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
if err != nil {
panic(err)
}
if err := zrokdir.SaveEnvironment(&zrokdir.Environment{ZrokToken: token, ZitiIdentityId: resp.Payload.Identity}); err != nil {
if err := zrokdir.SaveEnvironment(&zrokdir.Environment{ZrokToken: token, ZitiIdentityId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}); err != nil {
panic(err)
}
if err := zrokdir.WriteZitiIdentity("environment", resp.Payload.Cfg); err != nil {

View File

@ -69,7 +69,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
EndpointAddress: args[0],
}
zrok, err := newZrokClient()
zrok, err := newZrokClient(env.ApiEndpoint)
if err != nil {
panic(err)
}

View File

@ -49,8 +49,8 @@ func main() {
}
}
func newZrokClient() (*rest_client_zrok.Zrok, error) {
apiUrl, err := url.Parse(apiEndpoint)
func newZrokClient(endpoint string) (*rest_client_zrok.Zrok, error) {
apiUrl, err := url.Parse(endpoint)
if err != nil {
return nil, errors.Wrapf(err, "error parsing api endpoint '%v'", apiEndpoint)
}

View File

@ -11,6 +11,7 @@ import (
type Environment struct {
ZrokToken string `json:"zrok_token"`
ZitiIdentityId string `json:"ziti_identity"`
ApiEndpoint string `json:"api_endpoint"`
}
func Delete() error {