Skip to content

Commit

Permalink
refactor: Ensure to trim spaces in admin users
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Jan 2, 2024
1 parent bfcf2b5 commit bf4c52e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/jobstats/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (b *BatchJobStatsServer) Main() {
).Default("").String()
adminUsers = b.App.Flag(
"web.admin-users",
"Comma separated list of admin users.",
"Comma separated list of admin users (example: \"admin1,admin2\").",
).Default("").String()
dataPath = b.App.Flag(
"data.path",
Expand Down Expand Up @@ -140,6 +140,12 @@ func (b *BatchJobStatsServer) Main() {
jobstatDBPath := filepath.Join(absDataPath, *jobstatDBFile)
jobsLastTimeStampFile := filepath.Join(absDataPath, "lastjobsupdatetime")

// Get slice of admin users
var adminUsersList []string
for _, user := range(strings.Split(*adminUsers, ",")) {
adminUsersList = append(adminUsersList, strings.TrimSpace(user))
}

// Create context that listens for the interrupt signal from the OS.
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer stop()
Expand All @@ -162,7 +168,7 @@ func (b *BatchJobStatsServer) Main() {
WebSystemdSocket: *systemdSocket,
WebConfigFile: *webConfigFile,
DBConfig: *dbConfig,
AdminUsers: strings.Split(*adminUsers, ","),
AdminUsers: adminUsersList,
}

// Create server instance
Expand Down

0 comments on commit bf4c52e

Please sign in to comment.