mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +01: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)
|
||||
}
|
||||
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 !panicInstead {
|
||||
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)
|
||||
}
|
||||
|
||||
_, _ = 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 {
|
||||
_, _ = 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"))
|
||||
} else {
|
||||
_, _ = fmt.Fprintf(os.Stdout, codeStyle.Render("Environment"+":\n"))
|
||||
_, _ = fmt.Fprintf(os.Stdout, "\n")
|
||||
_, _ = fmt.Fprintf(os.Stdout, codeStyle.Render("Environment")+":\n\n")
|
||||
|
||||
t := table.NewWriter()
|
||||
t.SetOutputMirror(os.Stdout)
|
||||
t.SetStyle(table.StyleColoredDark)
|
||||
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{"Ziti Identity", zrd.Env.ZId})
|
||||
t.Render()
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(os.Stderr, "\n")
|
||||
_, _ = fmt.Fprintf(os.Stdout, "\n")
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func (zrd *ZrokDir) Client() (*rest_client_zrok.Zrok, error) {
|
||||
apiEndpoint := zrd.ApiEndpoint()
|
||||
apiEndpoint, _ := zrd.ApiEndpoint()
|
||||
apiUrl, err := url.Parse(apiEndpoint)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
func (zrd *ZrokDir) ApiEndpoint() string {
|
||||
apiEndpoint := "https://api.zrok.io"
|
||||
func (zrd *ZrokDir) ApiEndpoint() (apiEndpoint string, from string) {
|
||||
apiEndpoint = "https://api.zrok.io"
|
||||
from = "binary"
|
||||
|
||||
if zrd.Cfg != nil && zrd.Cfg.ApiEndpoint != "" {
|
||||
apiEndpoint = zrd.Cfg.ApiEndpoint
|
||||
from = "config"
|
||||
}
|
||||
|
||||
env := os.Getenv("ZROK_API_ENDPOINT")
|
||||
if env != "" {
|
||||
apiEndpoint = env
|
||||
from = "ZROK_API_ENDPOINT"
|
||||
}
|
||||
|
||||
if zrd.Env != nil && zrd.Env.ApiEndpoint != "" {
|
||||
apiEndpoint = zrd.Env.ApiEndpoint
|
||||
from = "env"
|
||||
}
|
||||
|
||||
return apiEndpoint
|
||||
return apiEndpoint, from
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user