mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-04 13:21:45 +00:00
fix: ENCRYPTION_KEY needed for version and help commands (#1256)
This commit is contained in:
@@ -129,6 +129,10 @@ func parseEnvConfig() error {
|
|||||||
|
|
||||||
// ValidateEnvConfig checks the EnvConfig for required fields and valid values
|
// ValidateEnvConfig checks the EnvConfig for required fields and valid values
|
||||||
func ValidateEnvConfig(config *EnvConfigSchema) error {
|
func ValidateEnvConfig(config *EnvConfigSchema) error {
|
||||||
|
if shouldSkipEnvValidation(os.Args) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := sloggin.ParseLevel(config.LogLevel); err != nil {
|
if _, err := sloggin.ParseLevel(config.LogLevel); err != nil {
|
||||||
return errors.New("invalid LOG_LEVEL value. Must be 'debug', 'info', 'warn' or 'error'")
|
return errors.New("invalid LOG_LEVEL value. Must be 'debug', 'info', 'warn' or 'error'")
|
||||||
}
|
}
|
||||||
@@ -210,6 +214,17 @@ func ValidateEnvConfig(config *EnvConfigSchema) error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shouldSkipEnvValidation(args []string) bool {
|
||||||
|
for _, arg := range args[1:] {
|
||||||
|
switch arg {
|
||||||
|
case "-h", "--help", "help", "version":
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// prepareEnvConfig processes special options for EnvConfig fields
|
// prepareEnvConfig processes special options for EnvConfig fields
|
||||||
func prepareEnvConfig(config *EnvConfigSchema) error {
|
func prepareEnvConfig(config *EnvConfigSchema) error {
|
||||||
val := reflect.ValueOf(config).Elem()
|
val := reflect.ValueOf(config).Elem()
|
||||||
|
|||||||
Reference in New Issue
Block a user