Skip to content

Commit

Permalink
Fix cross compiling of docker libraries for beats
Browse files Browse the repository at this point in the history
When trying to cross compile beats with the most recent version of docker the following platforms fail:

* solaris/amd64
* netbsd/amd64
* netbsd/386
* netbsd/arm

The reason is some tools missing for these platforms. Some of the code is used for running docker as a terminal client which is not used in Beats. The `func (p *JSONProgress) String` method now returns always an empty string. The method `CanAcess`was completely removed. Remove this content also removes quite a few dependencies which is great.

This is branched off `v17.03.1-ce`.
  • Loading branch information
ruflin committed Mar 31, 2017
1 parent c6d412e commit f02993b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 67 deletions.
13 changes: 0 additions & 13 deletions pkg/idtools/idtools_unix.go
Expand Up @@ -70,19 +70,6 @@ func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll, chown
return nil
}

// CanAccess takes a valid (existing) directory and a uid, gid pair and determines
// if that uid, gid pair has access (execute bit) to the directory
func CanAccess(path string, uid, gid int) bool {
statInfo, err := system.Stat(path)
if err != nil {
return false
}
fileMode := os.FileMode(statInfo.Mode())
permBits := fileMode.Perm()
return accessible(statInfo.UID() == uint32(uid),
statInfo.GID() == uint32(gid), permBits)
}

func accessible(isOwner, isGroup bool, perms os.FileMode) bool {
if isOwner && (perms&0100 == 0100) {
return true
Expand Down
55 changes: 1 addition & 54 deletions pkg/jsonmessage/jsonmessage.go
Expand Up @@ -4,12 +4,9 @@ import (
"encoding/json"
"fmt"
"io"
"strings"
"time"

"github.com/docker/docker/pkg/jsonlog"
"github.com/docker/docker/pkg/term"
"github.com/docker/go-units"
)

// JSONError wraps a concrete Code and Message, `Code` is
Expand All @@ -35,57 +32,7 @@ type JSONProgress struct {
}

func (p *JSONProgress) String() string {
var (
width = 200
pbBox string
numbersBox string
timeLeftBox string
)

ws, err := term.GetWinsize(p.terminalFd)
if err == nil {
width = int(ws.Width)
}

if p.Current <= 0 && p.Total <= 0 {
return ""
}
current := units.HumanSize(float64(p.Current))
if p.Total <= 0 {
return fmt.Sprintf("%8v", current)
}
total := units.HumanSize(float64(p.Total))
percentage := int(float64(p.Current)/float64(p.Total)*100) / 2
if percentage > 50 {
percentage = 50
}
if width > 110 {
// this number can't be negative gh#7136
numSpaces := 0
if 50-percentage > 0 {
numSpaces = 50 - percentage
}
pbBox = fmt.Sprintf("[%s>%s] ", strings.Repeat("=", percentage), strings.Repeat(" ", numSpaces))
}

numbersBox = fmt.Sprintf("%8v/%v", current, total)

if p.Current > p.Total {
// remove total display if the reported current is wonky.
numbersBox = fmt.Sprintf("%8v", current)
}

if p.Current > 0 && p.Start > 0 && percentage < 50 {
fromStart := time.Now().UTC().Sub(time.Unix(p.Start, 0))
perEntry := fromStart / time.Duration(p.Current)
left := time.Duration(p.Total-p.Current) * perEntry
left = (left / time.Second) * time.Second

if width > 50 {
timeLeftBox = " " + left.String()
}
}
return pbBox + numbersBox + timeLeftBox
return ""
}

// JSONMessage defines a message struct. It describes
Expand Down

0 comments on commit f02993b

Please sign in to comment.