-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: settings, default logging and go-core support (#14)
- Loading branch information
Showing
15 changed files
with
849 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/sirupsen/logrus" | ||
"github.com/ydataai/aws-quota-provider/pkg/common" | ||
"github.com/kelseyhightower/envconfig" | ||
) | ||
|
||
type configuration struct { | ||
logLevel logrus.Level | ||
awsRegion string | ||
// Configuration defines all env vars required for the application | ||
type Configuration struct { | ||
AWSRegion string `envconfig:"REGION" required:"true"` | ||
} | ||
|
||
func (c *configuration) LoadEnvVars() error { | ||
logLevel, err := common.VariableFromEnvironment("LOG_LEVEL") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
awsRegion, err := common.VariableFromEnvironment("REGION") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
level, err := logrus.ParseLevel(logLevel) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
c.logLevel = level | ||
c.awsRegion = awsRegion | ||
|
||
return nil | ||
// LoadEnvVars reads all env vars required for the server package | ||
func (c *Configuration) LoadFromEnvVars() error { | ||
return envconfig.Process("", c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.