mirror of
https://github.com/openziti/zrok.git
synced 2025-06-14 13:56:57 +02:00
zrok status now shows origination for api endpoint (#136)
This commit is contained in:
parent
434943c964
commit
5bd11e46a5
@ -69,7 +69,8 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
zrd.Env = &zrokdir.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: zrd.ApiEndpoint()}
|
apiEndpoint, _ := zrd.ApiEndpoint()
|
||||||
|
zrd.Env = &zrokdir.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}
|
||||||
if err := zrd.Save(); err != nil {
|
if err := zrd.Save(); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("there was an error saving the new environment", err)
|
showError("there was an error saving the new environment", err)
|
||||||
|
@ -36,22 +36,29 @@ func (cmd *statusCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
showError("unable to load zrokdir", err)
|
showError("unable to load zrokdir", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, _ = fmt.Fprintf(os.Stdout, codeStyle.Render("Config")+":\n\n")
|
||||||
|
t := table.NewWriter()
|
||||||
|
t.SetOutputMirror(os.Stdout)
|
||||||
|
t.SetStyle(table.StyleColoredDark)
|
||||||
|
t.AppendHeader(table.Row{"Property", "Value", "Source"})
|
||||||
|
apiEndpoint, from := zrd.ApiEndpoint()
|
||||||
|
t.AppendRow(table.Row{"API Endpoint", apiEndpoint, from})
|
||||||
|
t.Render()
|
||||||
|
_, _ = fmt.Fprintf(os.Stderr, "\n")
|
||||||
|
|
||||||
if zrd.Env == nil {
|
if zrd.Env == nil {
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "%v: Unable to load your local environment!\n\n", warningLabel)
|
_, _ = fmt.Fprintf(os.Stderr, "%v: Unable to load your local environment!\n\n", warningLabel)
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "To create a local environment use the %v command.\n", codeStyle.Render("zrok enable"))
|
_, _ = fmt.Fprintf(os.Stderr, "To create a local environment use the %v command.\n", codeStyle.Render("zrok enable"))
|
||||||
} else {
|
} else {
|
||||||
_, _ = fmt.Fprintf(os.Stdout, codeStyle.Render("Environment"+":\n"))
|
_, _ = fmt.Fprintf(os.Stdout, codeStyle.Render("Environment")+":\n\n")
|
||||||
_, _ = fmt.Fprintf(os.Stdout, "\n")
|
|
||||||
|
|
||||||
t := table.NewWriter()
|
t := table.NewWriter()
|
||||||
t.SetOutputMirror(os.Stdout)
|
t.SetOutputMirror(os.Stdout)
|
||||||
t.SetStyle(table.StyleColoredDark)
|
t.SetStyle(table.StyleColoredDark)
|
||||||
t.AppendHeader(table.Row{"Property", "Value"})
|
t.AppendHeader(table.Row{"Property", "Value"})
|
||||||
t.AppendRow(table.Row{"API Endpoint", zrd.Env.ApiEndpoint})
|
|
||||||
t.AppendRow(table.Row{"Secret Token", zrd.Env.Token})
|
t.AppendRow(table.Row{"Secret Token", zrd.Env.Token})
|
||||||
t.AppendRow(table.Row{"Ziti Identity", zrd.Env.ZId})
|
t.AppendRow(table.Row{"Ziti Identity", zrd.Env.ZId})
|
||||||
t.Render()
|
t.Render()
|
||||||
}
|
}
|
||||||
|
_, _ = fmt.Fprintf(os.Stdout, "\n")
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "\n")
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (zrd *ZrokDir) Client() (*rest_client_zrok.Zrok, error) {
|
func (zrd *ZrokDir) Client() (*rest_client_zrok.Zrok, error) {
|
||||||
apiEndpoint := zrd.ApiEndpoint()
|
apiEndpoint, _ := zrd.ApiEndpoint()
|
||||||
apiUrl, err := url.Parse(apiEndpoint)
|
apiUrl, err := url.Parse(apiEndpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error parsing api endpoint '%v'", zrd)
|
return nil, errors.Wrapf(err, "error parsing api endpoint '%v'", zrd)
|
||||||
@ -34,21 +34,25 @@ func (zrd *ZrokDir) Client() (*rest_client_zrok.Zrok, error) {
|
|||||||
return zrok, nil
|
return zrok, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (zrd *ZrokDir) ApiEndpoint() string {
|
func (zrd *ZrokDir) ApiEndpoint() (apiEndpoint string, from string) {
|
||||||
apiEndpoint := "https://api.zrok.io"
|
apiEndpoint = "https://api.zrok.io"
|
||||||
|
from = "binary"
|
||||||
|
|
||||||
if zrd.Cfg != nil && zrd.Cfg.ApiEndpoint != "" {
|
if zrd.Cfg != nil && zrd.Cfg.ApiEndpoint != "" {
|
||||||
apiEndpoint = zrd.Cfg.ApiEndpoint
|
apiEndpoint = zrd.Cfg.ApiEndpoint
|
||||||
|
from = "config"
|
||||||
}
|
}
|
||||||
|
|
||||||
env := os.Getenv("ZROK_API_ENDPOINT")
|
env := os.Getenv("ZROK_API_ENDPOINT")
|
||||||
if env != "" {
|
if env != "" {
|
||||||
apiEndpoint = env
|
apiEndpoint = env
|
||||||
|
from = "ZROK_API_ENDPOINT"
|
||||||
}
|
}
|
||||||
|
|
||||||
if zrd.Env != nil && zrd.Env.ApiEndpoint != "" {
|
if zrd.Env != nil && zrd.Env.ApiEndpoint != "" {
|
||||||
apiEndpoint = zrd.Env.ApiEndpoint
|
apiEndpoint = zrd.Env.ApiEndpoint
|
||||||
|
from = "env"
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiEndpoint
|
return apiEndpoint, from
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user