Skip to content

Commit

Permalink
Fix -only-exposed
Browse files Browse the repository at this point in the history
-only-exposed is supposed filter container that are actually exposed and
published on the host.
  • Loading branch information
jwilder committed May 9, 2014
1 parent 73d3712 commit 3dd18b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docker-gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ func (r *RuntimeContainer) Equals(o RuntimeContainer) bool {
return r.ID == o.ID && r.Image == o.Image
}

func (r *RuntimeContainer) PublishedAddresses() []Address {
mapped := []Address{}
for _, address := range r.Addresses {
if address.HostPort != "" {
mapped = append(mapped, address)
}
}
return mapped
}

func usage() {
println("Usage: docker-gen [-config file] [-watch=false] [-notify=\"restart xyz\"] [-interval=0] [-endpoint tcp|unix://..] <template> [<dest>]")
}
Expand Down
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func generateFile(config Config, containers []*RuntimeContainer) bool {
filteredContainers := []*RuntimeContainer{}
if config.OnlyExposed {
for _, container := range containers {
if len(container.Addresses) > 0 {
if len(container.PublishedAddresses()) > 0 {
filteredContainers = append(filteredContainers, container)
}
}
Expand Down

0 comments on commit 3dd18b8

Please sign in to comment.