Skip to content
Permalink
Browse files

Trim new-lines from tokens

To help out beginners the code that parses a token file is now
forcing a trim of any new-lines.

Fixes: #154

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Feb 4, 2020
1 parent 37aaf75 commit 969ffae856b36c8b92e22afd11c71d8ef9d8c173
Showing with 9 additions and 2 deletions.
  1. +4 −1 cmd/client.go
  2. +5 −1 cmd/server.go
@@ -99,7 +99,10 @@ func runClient(cmd *cobra.Command, _ []string) error {
if err != nil {
return errors.Wrap(err, fmt.Sprintf("unable to load file: %s", tokenFile))
}
token = string(fileData)

// new-lines will be stripped, this is not configurable and is to
// make the code foolproof for beginners
token = strings.TrimRight(string(fileData), "\n")
} else {
tokenVal, err := cmd.Flags().GetString("token")
if err != nil {
@@ -9,6 +9,7 @@ import (
"log"
"os"
"strconv"
"strings"

"github.com/inlets/inlets/pkg/server"
"github.com/pkg/errors"
@@ -59,7 +60,10 @@ func runServer(cmd *cobra.Command, _ []string) error {
if err != nil {
return errors.Wrap(err, fmt.Sprintf("unable to load file: %s", tokenFile))
}
token = string(fileData)

// new-lines will be stripped, this is not configurable and is to
// make the code foolproof for beginners
token = strings.TrimRight(string(fileData), "\n")
} else {
tokenVal, err := cmd.Flags().GetString("token")
if err != nil {

0 comments on commit 969ffae

Please sign in to comment.
You can’t perform that action at this time.