~mfoord/juju-core/tests-replset

« back to all changes in this revision

Viewing changes to names/user.go

  • Committer: Michael Foord
  • Date: 2014-05-22 15:16:56 UTC
  • mfrom: (2745.1.30 juju-core)
  • Revision ID: michael.foord@canonical.com-20140522151656-1l0z4p9puke9drsp
Merge existing rsyslog work

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
package names
5
5
 
6
6
import (
7
 
        "strings"
 
7
        "regexp"
8
8
)
9
9
 
 
10
var validName = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9.-]*[a-zA-Z0-9]$")
 
11
 
10
12
// IsUser returns whether id is a valid user id.
11
 
// TODO(rog) stricter constraints
12
13
func IsUser(name string) bool {
13
 
        return !strings.Contains(name, "/") && name != ""
 
14
        return validName.MatchString(name)
14
15
}
15
16
 
16
17
// UserTag returns the tag for the user with the given name.