Merge pull request #32187 from tianon/tini-version-parsing
Update "tini --version" parsing to be more forgiving of Tini's output format (release build vs git build)
This commit is contained in:
commit
d9c4261964
1 changed files with 14 additions and 11 deletions
|
@ -56,20 +56,23 @@ func (daemon *Daemon) FillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
|
|||
|
||||
v.InitCommit.Expected = dockerversion.InitCommitID
|
||||
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)), " - ")
|
||||
if len(parts) == 2 {
|
||||
if dockerversion.InitCommitID[0] == 'v' {
|
||||
vs := strings.TrimPrefix(parts[0], "tini version ")
|
||||
v.InitCommit.ID = "v" + vs
|
||||
} else {
|
||||
// Get the sha1
|
||||
gitParts := strings.Split(parts[1], ".")
|
||||
if len(gitParts) == 2 && gitParts[0] == "git" {
|
||||
v.InitCommit.ID = gitParts[1]
|
||||
v.InitCommit.Expected = dockerversion.InitCommitID[0:len(gitParts[1])]
|
||||
}
|
||||
|
||||
v.InitCommit.ID = ""
|
||||
if v.InitCommit.ID == "" && len(parts) >= 2 {
|
||||
gitParts := strings.Split(parts[1], ".")
|
||||
if len(gitParts) == 2 && gitParts[0] == "git" {
|
||||
v.InitCommit.ID = gitParts[1]
|
||||
v.InitCommit.Expected = dockerversion.InitCommitID[0:len(v.InitCommit.ID)]
|
||||
}
|
||||
}
|
||||
if v.InitCommit.ID == "" && len(parts) >= 1 {
|
||||
vs := strings.TrimPrefix(parts[0], "tini version ")
|
||||
v.InitCommit.ID = "v" + vs
|
||||
}
|
||||
|
||||
if v.InitCommit.ID == "" {
|
||||
logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultInitBinary, string(rv))
|
||||
|
|
Loading…
Reference in a new issue