1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Update "tini --version" parsing to be more forgiving of Tini's output format (release build vs git build)

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
This commit is contained in:
Tianon Gravi 2017-03-28 15:18:39 -07:00
parent 8098bf3896
commit 87f9362975

View file

@ -56,20 +56,23 @@ func (daemon *Daemon) FillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
v.InitCommit.Expected = dockerversion.InitCommitID v.InitCommit.Expected = dockerversion.InitCommitID
if rv, err := exec.Command(DefaultInitBinary, "--version").Output(); err == nil { if rv, err := exec.Command(DefaultInitBinary, "--version").Output(); err == nil {
// examples of how Tini outputs version info:
// "tini version 0.13.0 - git.949e6fa"
// "tini version 0.13.2"
parts := strings.Split(strings.TrimSpace(string(rv)), " - ") parts := strings.Split(strings.TrimSpace(string(rv)), " - ")
if len(parts) == 2 {
if dockerversion.InitCommitID[0] == 'v' { v.InitCommit.ID = ""
vs := strings.TrimPrefix(parts[0], "tini version ") if v.InitCommit.ID == "" && len(parts) >= 2 {
v.InitCommit.ID = "v" + vs gitParts := strings.Split(parts[1], ".")
} else { if len(gitParts) == 2 && gitParts[0] == "git" {
// Get the sha1 v.InitCommit.ID = gitParts[1]
gitParts := strings.Split(parts[1], ".") v.InitCommit.Expected = dockerversion.InitCommitID[0:len(v.InitCommit.ID)]
if len(gitParts) == 2 && gitParts[0] == "git" {
v.InitCommit.ID = gitParts[1]
v.InitCommit.Expected = dockerversion.InitCommitID[0:len(gitParts[1])]
}
} }
} }
if v.InitCommit.ID == "" && len(parts) >= 1 {
vs := strings.TrimPrefix(parts[0], "tini version ")
v.InitCommit.ID = "v" + vs
}
if v.InitCommit.ID == "" { if v.InitCommit.ID == "" {
logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultInitBinary, string(rv)) logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultInitBinary, string(rv))