Skip to content

Commit a2930a1

Browse files
authored
Bugfix env vars (#175)
* Add explicit EnvVar handling for Lambda * Update root.go
1 parent 1c30312 commit a2930a1

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

cmd/root.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020
"fmt"
2121
"os"
22+
"strings"
2223

2324
"github.com/aws/aws-lambda-go/events"
2425
"github.com/aws/aws-lambda-go/lambda"
@@ -192,7 +193,7 @@ func initConfig() {
192193
}
193194

194195
func configLambda() {
195-
s := session.Must(session.NewSession())
196+
s := session.Must(session.NewSession())
196197
svc := secretsmanager.New(s)
197198
secrets := config.NewSecrets(svc)
198199

@@ -232,9 +233,9 @@ func configLambda() {
232233
}
233234
cfg.IdentityStoreID = unwrap
234235

235-
unwrap = os.Getenv("LOG_LEVEL")
236+
unwrap = os.Getenv("LOG_LEVEL")
236237
if len([]rune(unwrap)) != 0 {
237-
cfg.LogLevel = unwrap
238+
cfg.LogLevel = unwrap
238239
}
239240

240241
unwrap = os.Getenv("LOG_FORMAT")
@@ -246,6 +247,32 @@ func configLambda() {
246247
if len([]rune(unwrap)) != 0 {
247248
cfg.SyncMethod = unwrap
248249
}
250+
251+
unwrap = os.Getenv("USER_MATCH")
252+
if len([]rune(unwrap)) != 0 {
253+
cfg.UserMatch = unwrap
254+
}
255+
256+
unwrap = os.Getenv("GROUP_MATCH")
257+
if len([]rune(unwrap)) != 0 {
258+
cfg.GroupMatch = unwrap
259+
}
260+
261+
unwrap = os.Getenv("IGNORE_GROUPS")
262+
if len([]rune(unwrap)) != 0 {
263+
cfg.IgnoreGroups = strings.Split(unwrap, ",")
264+
}
265+
266+
unwrap = os.Getenv("IGNORE_USERS")
267+
if len([]rune(unwrap)) != 0 {
268+
cfg.IgnoreUsers = strings.Split(unwrap, ",")
269+
}
270+
271+
unwrap = os.Getenv("INCLUDE_GROUPS")
272+
if len([]rune(unwrap)) != 0 {
273+
cfg.IncludeGroups = strings.Split(unwrap, ",")
274+
}
275+
249276
}
250277

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

0 commit comments

Comments
 (0)