"vscode:/vscode.git/clone" did not exist on "95fc83a04f09169a8c2375b654671db8df3b4fff"
Commit a500d35c authored by liming6's avatar liming6
Browse files

fix pid_of_docker适应public_user

parent 4ff719ad
......@@ -54,7 +54,10 @@ func (c *Cinfo) Format() ([5]string, [5]int) {
return rs, rl
}
var RegUser = regexp.MustCompile(`^(?i)/public[0-9]*/home/([0-9a-z_]+)(?:|/.*)$`)
var (
RegUser = regexp.MustCompile(`^(?i)/public[0-9]*/home/([0-9a-z_]+)(?:|/.*)$`)
RegUserPublic = regexp.MustCompile(`^(?i)/public[0-9]*/home/(?:public_user|locauser|localuser)/([0-9a-z_]+)(?:|/.*)$`)
)
func main() {
cli, err := docker.GetDockerClient()
......@@ -83,7 +86,12 @@ func main() {
} else {
c.User = make([]string, 0, 4)
for _, v := range i.Mounts {
if RegUser.MatchString(v.Source) {
if RegUserPublic.MatchString(v.Source) {
f := RegUserPublic.FindStringSubmatch(v.Source)
if len(f) >= 2 {
c.User = append(c.User, f[1])
}
} else if RegUser.MatchString(v.Source) {
f := RegUser.FindStringSubmatch(v.Source)
if len(f) >= 2 {
c.User = append(c.User, f[1])
......
......@@ -220,11 +220,11 @@ func TestSplitN(t *testing.T) {
}
func TestReg(t *testing.T) {
var RegUser = regexp.MustCompile(`^(?i)/public[0-9]*/([0-9a-z]+)(?:|/.*)$`)
test := []string{"/public2/liming6", "/Public/Liming6/hello"}
var RegUserPublic = regexp.MustCompile(`^(?i)/public[0-9]*/home/(?:public_user|locauser|localuser)/([0-9a-z_]+)(?:|/.*)$`)
test := []string{"/public/home/public_user/chenxi/WAN", "/Public/Liming6/hello"}
for _, v := range test {
if RegUser.MatchString(v) {
f := RegUser.FindStringSubmatch(v)
if RegUserPublic.MatchString(v) {
f := RegUserPublic.FindStringSubmatch(v)
t.Logf("match %s, %v", v, f)
} else {
t.Logf("not match %s", v)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment