adding metadata tests back to integration tests (#185)

* adding metadata tests back to integration tests and fixing resulting bugs

* fix onbuild and default env

* removing old test files

* adding the ArgsEscaped boolean on CMD commands

* fix onbuild test

* ignore failing test until container-diff is fixed

* code comments

* adding todo to remove uncomment failing test
This commit is contained in:
Sharif Elgamal
2018-05-24 11:28:32 -07:00
committed by GitHub
parent 0881b7c320
commit 5e6b60f46e
16 changed files with 119 additions and 425 deletions
+41
View File
@@ -26,6 +26,7 @@ import (
"net/http"
"net/url"
"os"
"os/user"
"path/filepath"
"strings"
)
@@ -273,3 +274,43 @@ Loop:
config.Env = envArray
return nil
}
func GetUserFromUsername(userStr string, groupStr string) (string, string, error) {
// Lookup by username
userObj, err := user.Lookup(userStr)
if err != nil {
if _, ok := err.(user.UnknownUserError); ok {
// Lookup by id
userObj, err = user.LookupId(userStr)
if err != nil {
return "", "", err
}
} else {
return "", "", err
}
}
// Same dance with groups
var group *user.Group
if groupStr != "" {
group, err = user.LookupGroup(groupStr)
if err != nil {
if _, ok := err.(user.UnknownGroupError); ok {
group, err = user.LookupGroupId(groupStr)
if err != nil {
return "", "", err
}
} else {
return "", "", err
}
}
}
uid := userObj.Uid
gid := ""
if group != nil {
gid = group.Gid
}
return uid, gid, nil
}