lint: lint the code
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
1 parent
c4bef0d616
commit
b7fdcc3ee9
7 files changed
+34
-35
No files matched your search
+7
-6
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user