mirror of
https://github.com/openziti/zrok.git
synced 2025-06-13 13:26:46 +02:00
store api endpoint in zrokdir (#47)
This commit is contained in:
parent
65209caa53
commit
f3f887e535
@ -46,7 +46,7 @@ func (cmd *createAccountCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
fmt.Println("entered emails do not match... aborting!")
|
fmt.Println("entered emails do not match... aborting!")
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := newZrokClient()
|
zrok, err := newZrokClient(apiEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func (cmd *disableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
zrok, err := newZrokClient()
|
zrok, err := newZrokClient(env.ApiEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
cmd.description = fmt.Sprintf("%v@%v", user.Username, hostName)
|
cmd.description = fmt.Sprintf("%v@%v", user.Username, hostName)
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := newZrokClient()
|
zrok, err := newZrokClient(apiEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
if err := zrokdir.WriteZitiIdentity("environment", resp.Payload.Cfg); err != nil {
|
if err := zrokdir.WriteZitiIdentity("environment", resp.Payload.Cfg); err != nil {
|
||||||
|
@ -69,7 +69,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
|||||||
EndpointAddress: args[0],
|
EndpointAddress: args[0],
|
||||||
}
|
}
|
||||||
|
|
||||||
zrok, err := newZrokClient()
|
zrok, err := newZrokClient(env.ApiEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newZrokClient() (*rest_client_zrok.Zrok, error) {
|
func newZrokClient(endpoint string) (*rest_client_zrok.Zrok, error) {
|
||||||
apiUrl, err := url.Parse(apiEndpoint)
|
apiUrl, err := url.Parse(endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error parsing api endpoint '%v'", apiEndpoint)
|
return nil, errors.Wrapf(err, "error parsing api endpoint '%v'", apiEndpoint)
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
type Environment struct {
|
type Environment struct {
|
||||||
ZrokToken string `json:"zrok_token"`
|
ZrokToken string `json:"zrok_token"`
|
||||||
ZitiIdentityId string `json:"ziti_identity"`
|
ZitiIdentityId string `json:"ziti_identity"`
|
||||||
|
ApiEndpoint string `json:"api_endpoint"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Delete() error {
|
func Delete() error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user