mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +01:00
environment load assert chain (#369); get rid of warnings in zrok status
This commit is contained in:
parent
4713243e2c
commit
af77de015a
@ -50,7 +50,6 @@ func (cmd *statusCommand) run(_ *cobra.Command, _ []string) {
|
|||||||
_, _ = fmt.Fprintf(os.Stderr, "\n")
|
_, _ = fmt.Fprintf(os.Stderr, "\n")
|
||||||
|
|
||||||
if !env.IsEnabled() {
|
if !env.IsEnabled() {
|
||||||
tui.Warning("Unable to load your local environment!\n")
|
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "To create a local environment use the %v command.\n", tui.Code.Render("zrok enable"))
|
_, _ = fmt.Fprintf(os.Stderr, "To create a local environment use the %v command.\n", tui.Code.Render("zrok enable"))
|
||||||
} else {
|
} else {
|
||||||
_, _ = fmt.Fprintf(os.Stdout, tui.Code.Render("Environment")+":\n\n")
|
_, _ = fmt.Fprintf(os.Stdout, tui.Code.Render("Environment")+":\n\n")
|
||||||
|
@ -33,7 +33,11 @@ type Root interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func LoadRoot() (Root, error) {
|
func LoadRoot() (Root, error) {
|
||||||
|
if assert, err := env_v0_3.Assert(); assert && err == nil {
|
||||||
return env_v0_3.Load()
|
return env_v0_3.Load()
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListRoots() ([]*env_core.Metadata, error) {
|
func ListRoots() ([]*env_core.Metadata, error) {
|
||||||
|
@ -16,6 +16,21 @@ type Root struct {
|
|||||||
env *env_core.Environment
|
env *env_core.Environment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Assert() (bool, error) {
|
||||||
|
exists, err := rootExists()
|
||||||
|
if err != nil {
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
meta, err := loadMetadata()
|
||||||
|
if err != nil {
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
return meta.V == V, nil
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
func Load() (*Root, error) {
|
func Load() (*Root, error) {
|
||||||
r := &Root{}
|
r := &Root{}
|
||||||
exists, err := rootExists()
|
exists, err := rootExists()
|
||||||
@ -62,7 +77,7 @@ func rootExists() (bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return true, err
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertMetadata() error {
|
func assertMetadata() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user