Skip to content

Commit 08d45c8

Browse files
committed
Merge pull request #96 from viranch/emit-struct
Move docker-gen emit struct from wiki to readme
2 parents 9e95c26 + 95a4065 commit 08d45c8

File tree

1 file changed

+95
-1
lines changed

1 file changed

+95
-1
lines changed

README.md

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,101 @@ If no `<dest>` file is specified, the output is sent to stdout. Mainly useful f
109109

110110
The templates used by docker-gen are written using the Go [text/template](http://golang.org/pkg/text/template/) language. In addition to the [built-in functions](http://golang.org/pkg/text/template/#hdr-Functions) supplied by Go, docker-gen provides a number of additional functions to make it simpler (or possible) to generate your desired output.
111111

112-
Within those templates, the object emitted by docker-gen will have [this structure](https://github.com/jwilder/docker-gen/wiki/Docker-Gen-Emit-Structure).
112+
#### Emit Structure
113+
114+
Within the templates, the object emitted by docker-gen will be a structure consisting of following Go structs:
115+
116+
```go
117+
type RuntimeContainer struct {
118+
ID string
119+
Addresses []Address
120+
Gateway string
121+
Name string
122+
Hostname string
123+
Image DockerImage
124+
Env map[string]string
125+
Volumes map[string]Volume
126+
Node SwarmNode
127+
Labels map[string]string
128+
IP string
129+
}
130+
131+
type Address struct {
132+
IP string
133+
Port string
134+
HostPort string
135+
Proto string
136+
HostIP string
137+
}
138+
139+
type DockerImage struct {
140+
Registry string
141+
Repository string
142+
Tag string
143+
}
144+
145+
type Volume struct {
146+
Path string
147+
HostPath string
148+
ReadWrite bool
149+
}
150+
151+
type SwarmNode struct {
152+
ID string
153+
Name string
154+
Address Address
155+
}
156+
```
157+
158+
For example, this is a JSON version of an emitted RuntimeContainer struct:
159+
160+
```json
161+
{
162+
"ID":"71e9768075836eb38557adcfc71a207386a0c597dbeda240cf905df79b18cebf",
163+
"Addresses":[
164+
{
165+
"IP":"172.17.0.4",
166+
"Port":"22",
167+
"Proto":"tcp",
168+
"HostIP":"192.168.10.24",
169+
"HostPort":"2222"
170+
}
171+
],
172+
"Gateway":"172.17.42.1",
173+
"Node": {
174+
"ID":"I2VY:P7PF:TZD5:PGWB:QTI7:QDSP:C5UD:DYKR:XKKK:TRG2:M2BL:DFUN",
175+
"Name":"docker-test",
176+
"Address": {
177+
"IP":"192.168.10.24"
178+
}
179+
},
180+
"Labels": {
181+
"operatingsystem":"Ubuntu 14.04.2 LTS",
182+
"storagedriver":"devicemapper",
183+
"anything_foo":"something_bar"
184+
},
185+
"IP":"172.17.0.4",
186+
"Name":"docker_register",
187+
"Hostname":"71e976807583",
188+
"Image":{
189+
"Registry":"jwilder",
190+
"Repository":"docker-register"
191+
},
192+
"Env":{
193+
"ETCD_HOST":"172.17.42.1:4001",
194+
"PATH":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
195+
"DOCKER_HOST":"unix:///var/run/docker.sock",
196+
"HOST_IP":"172.17.42.1"
197+
},
198+
"Volumes":{
199+
"/mnt":{
200+
"Path":"/mnt",
201+
"HostPath":"/Users/joebob/tmp",
202+
"ReadWrite":true
203+
}
204+
}
205+
}
206+
```
113207

114208
#### Functions
115209

0 commit comments

Comments
 (0)