lint: lint the code

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>

Former-commit-id: 984c56e0b9a9169b10c6017fbd68ab4fbd3868d7 [formerly 27c43314222c723a220b9b1d2141e1509ed05627] [formerly 0a9f6c47bff2d653035c93765ea08ade73ec450c [formerly b7fdcc3ee9]]
Former-commit-id: c27e7fa41f20f433a9a0a97ecc40ab78968b43dc [formerly 185db4a17969cd4fb76cc2b06bd58221c9c6c100]
Former-commit-id: 9b26d1b0642c61cd38f7cdf422f95b2bf9a9614d
This commit is contained in:
Henrique Dias 2019-04-20 14:15:28 +01:00
parent 4a1e21baec
commit fa86894550
7 changed files with 34 additions and 35 deletions

View file

@ -2,11 +2,12 @@ package settings
import (
"errors"
"github.com/spf13/afero"
"log"
"os"
"regexp"
"strings"
"github.com/spf13/afero"
)
var (
@ -15,10 +16,11 @@ var (
dashes = regexp.MustCompile(`[\-]+`)
)
func CreateUserDir(username, userScope, serverRoot string, settings *Settings) (string, error) {
// MakeUserDir makes the user directory according to settings.
func (settings *Settings) MakeUserDir(username, userScope, serverRoot string) (string, error) {
var err error
userScope = strings.TrimSpace(userScope)
if userScope == "" || userScope == "./" {
if userScope == "" || userScope == "./" {
userScope = "."
}
@ -56,10 +58,9 @@ func CreateUserDir(username, userScope, serverRoot string, settings *Settings) (
} else {
log.Printf("create user: mkdir user home dir: [%s] successfully.", userHome)
}
return userHome,err
return userHome, err
}
func cleanUsername(s string) string {
// Remove any trailing space to avoid ending on -
@ -74,4 +75,4 @@ func cleanUsername(s string) string {
s = dashes.ReplaceAllString(s, "-")
return s
}
}

View file

@ -12,15 +12,15 @@ type AuthMethod string
// Settings contain the main settings of the application.
type Settings struct {
Key []byte `json:"key"`
Signup bool `json:"signup"`
CreateUserDir bool `json:"createUserDir"`
Defaults UserDefaults `json:"defaults"`
AuthMethod AuthMethod `json:"authMethod"`
Branding Branding `json:"branding"`
Commands map[string][]string `json:"commands"`
Shell []string `json:"shell"`
Rules []rules.Rule `json:"rules"`
Key []byte `json:"key"`
Signup bool `json:"signup"`
CreateUserDir bool `json:"createUserDir"`
Defaults UserDefaults `json:"defaults"`
AuthMethod AuthMethod `json:"authMethod"`
Branding Branding `json:"branding"`
Commands map[string][]string `json:"commands"`
Shell []string `json:"shell"`
Rules []rules.Rule `json:"rules"`
}
// GetRules implements rules.Provider.