Add some config through flag/env
This commit is contained in:
parent
c60b4ddf73
commit
d0b59cb411
6 changed files with 120 additions and 6 deletions
21
config/env.go
Normal file
21
config/env.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// FromEnv analyzes all the environment variables to find each one
|
||||
// starting by MINIFAAS_
|
||||
func (c *Config) FromEnv() error {
|
||||
for _, line := range os.Environ() {
|
||||
if strings.HasPrefix(line, "MINIFAAS_") {
|
||||
err := c.parseLine(line)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error in environment (%q): %w", line, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in a new issue