Skip to content

Commit cebbe5b

Browse files
authored
Trimming token file after reading it (#191)
1 parent 6c3ec6c commit cebbe5b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cmd/humioctl/root.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"net/url"
2020
"os"
2121
"path"
22+
"strings"
2223

2324
"github.com/humio/cli/internal/api"
2425
"github.com/humio/cli/internal/viperkey"
@@ -186,8 +187,9 @@ func initConfig() {
186187
if tokenFile != "" {
187188
// #nosec G304
188189
tokenFileContent, err := os.ReadFile(tokenFile)
190+
tokenFileContentStr := strings.TrimSpace(string(tokenFileContent))
189191
exitOnError(rootCmd, err, "Error loading token file")
190-
viper.Set(viperkey.Token, string(tokenFileContent))
192+
viper.Set(viperkey.Token, tokenFileContentStr)
191193
}
192194

193195
if caCertificateFile != "" {

0 commit comments

Comments
 (0)