Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrachev committed Apr 23, 2019
1 parent f90b51b commit 8e9ff3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions crane/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"sync"
)

const netBridge = "bridge"

type Container interface {
ContainerInfo
Exists() bool
Expand Down Expand Up @@ -250,7 +252,7 @@ func (c *container) Dependencies() *Dependencies {
dependencies.Requires = append(dependencies.Requires, required)
}
}
if c.Net() == "bridge" {
if c.Net() == netBridge {
// links are strict dependencies only on bridge networks
for _, link := range c.Link() {
linkName := strings.Split(link, ":")[0]
Expand Down Expand Up @@ -704,8 +706,8 @@ func (c *container) ActualNet() string {
if len(netParam) == 0 {
return ""
}
if netParam == "bridge" {
return "bridge"
if netParam == netBridge {
return netBridge
} else if netParam == "none" {
return "none"
}
Expand Down Expand Up @@ -943,7 +945,7 @@ func (c *container) Create(cmds []string) {
}
msg := "Creating container %s"
if adHoc {
msg = msg + " (ad-hoc)"
msg += " (ad-hoc)"
}
fmt.Fprintf(c.CommandsOut(), msg+" ...\n", c.ActualName(adHoc))

Expand All @@ -964,7 +966,7 @@ func (c *container) Run(cmds []string, targeted bool, detachFlag bool) {
}
msg := "Running container %s"
if adHoc {
msg = msg + " (ad-hoc)"
msg += " (ad-hoc)"
}
fmt.Fprintf(c.CommandsOut(), msg+" ...\n", c.ActualName(adHoc))

Expand Down Expand Up @@ -1249,7 +1251,7 @@ func (c *container) createArgs(cmds []string) []string {
}
// Net
netParam := c.ActualNet()
if len(netParam) > 0 && netParam != "bridge" {
if len(netParam) > 0 && netParam != netBridge {
args = append(args, "--net", netParam)
}
// NetAlias
Expand Down
4 changes: 2 additions & 2 deletions crane/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (containers Containers) Logs(follow bool, timestamps bool, tail string, col
}
appendSources(log.Stdout, stdoutColor, log.Name, "|")
appendSources(log.Stderr, stderrColor, log.Name, "*")
counter = counter + 1
counter += 1
}
}
if len(sources) > 0 {
Expand Down Expand Up @@ -191,7 +191,7 @@ func write(prefix string, color *ansi.Color, timestamps bool) func(dest io.Write
if string(token[0]) == "[" {
// it seems that timestamps are wrapped in [] for events
// streamed in real time during a `docker logs -f`
strip = strip + 2
strip += 2
}
token = token[strip:]
}
Expand Down

0 comments on commit 8e9ff3c

Please sign in to comment.