Skip to content

Commit

Permalink
Bugfix env vars (#175)
Browse files Browse the repository at this point in the history
* Add explicit EnvVar handling for Lambda

* Update root.go
  • Loading branch information
ChrisPates authored Mar 8, 2024
1 parent 1c30312 commit a2930a1
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"fmt"
"os"
"strings"

"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
Expand Down Expand Up @@ -192,7 +193,7 @@ func initConfig() {
}

func configLambda() {
s := session.Must(session.NewSession())
s := session.Must(session.NewSession())
svc := secretsmanager.New(s)
secrets := config.NewSecrets(svc)

Expand Down Expand Up @@ -232,9 +233,9 @@ func configLambda() {
}
cfg.IdentityStoreID = unwrap

unwrap = os.Getenv("LOG_LEVEL")
unwrap = os.Getenv("LOG_LEVEL")
if len([]rune(unwrap)) != 0 {
cfg.LogLevel = unwrap
cfg.LogLevel = unwrap
}

unwrap = os.Getenv("LOG_FORMAT")
Expand All @@ -246,6 +247,32 @@ func configLambda() {
if len([]rune(unwrap)) != 0 {
cfg.SyncMethod = unwrap
}

unwrap = os.Getenv("USER_MATCH")
if len([]rune(unwrap)) != 0 {
cfg.UserMatch = unwrap
}

unwrap = os.Getenv("GROUP_MATCH")
if len([]rune(unwrap)) != 0 {
cfg.GroupMatch = unwrap
}

unwrap = os.Getenv("IGNORE_GROUPS")
if len([]rune(unwrap)) != 0 {
cfg.IgnoreGroups = strings.Split(unwrap, ",")
}

unwrap = os.Getenv("IGNORE_USERS")
if len([]rune(unwrap)) != 0 {
cfg.IgnoreUsers = strings.Split(unwrap, ",")
}

unwrap = os.Getenv("INCLUDE_GROUPS")
if len([]rune(unwrap)) != 0 {
cfg.IncludeGroups = strings.Split(unwrap, ",")
}

}

func addFlags(cmd *cobra.Command, cfg *config.Config) {
Expand Down

0 comments on commit a2930a1

Please sign in to comment.