mirror of
https://github.com/openziti/zrok.git
synced 2024-11-21 23:53:19 +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")
|
||||
|
||||
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"))
|
||||
} else {
|
||||
_, _ = fmt.Fprintf(os.Stdout, tui.Code.Render("Environment")+":\n\n")
|
||||
|
@ -33,7 +33,11 @@ type Root interface {
|
||||
}
|
||||
|
||||
func LoadRoot() (Root, error) {
|
||||
return env_v0_3.Load()
|
||||
if assert, err := env_v0_3.Assert(); assert && err == nil {
|
||||
return env_v0_3.Load()
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func ListRoots() ([]*env_core.Metadata, error) {
|
||||
|
@ -16,6 +16,21 @@ type Root struct {
|
||||
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) {
|
||||
r := &Root{}
|
||||
exists, err := rootExists()
|
||||
@ -62,7 +77,7 @@ func rootExists() (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, err
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func assertMetadata() error {
|
||||
|
Loading…
Reference in New Issue
Block a user