refact(e2e): Use envconfig's required property
This commit is contained in:
1 parent
da0fb9d38a
commit
0afef63dca
5 files changed
+20
-143
No files matched your search
@@ -2,7 +2,6 @@
|
||||
package vault
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
@@ -15,19 +14,8 @@ import (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
VaultAddr string `envconfig:"VAULT_ADDR"` // e.g. "http://127.0.0.1:8200"
|
||||
VaultToken string `envconfig:"VAULT_TOKEN"`
|
||||
}
|
||||
|
||||
func (c *config) validate() error {
|
||||
if c.VaultAddr == "" {
|
||||
return errors.New("VaultAddr is empty. Set environment variable: VAULT_ADDR")
|
||||
}
|
||||
if c.VaultToken == "" {
|
||||
return errors.New("VaultToken is empty. Set environment variable: VAULT_TOKEN")
|
||||
}
|
||||
|
||||
return nil
|
||||
VaultAddr string `envconfig:"VAULT_ADDR" required:"true"` // e.g. "http://127.0.0.1:8200"
|
||||
VaultToken string `envconfig:"VAULT_TOKEN" required:"true"`
|
||||
}
|
||||
|
||||
func loadConfig() (*config, error) {
|
||||
@@ -37,11 +25,6 @@ func loadConfig() (*config, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = c.validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &c, err
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user