Skip to content

Commit b28e344

Browse files
committed
Merge branch 'n-rodriguez-add_parse_bool'
2 parents edec740 + 7af79e2 commit b28e344

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ For example, this is a JSON version of an emitted RuntimeContainer struct:
224224
* *`json $value`*: Returns the JSON representation of `$value` as a `string`.
225225
* *`keys $map`*: Returns the keys from `$map`. If `$map` is `nil`, a `nil` is returned. If `$map` is not a `map`, an error will be thrown.
226226
* *`last $array`*: Returns the last value of an array.
227+
* *`parseBool $string`*: parseBool returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error. Alias for [`strconv.ParseBool`](http://golang.org/pkg/strconv/#ParseBool)
227228
* *`replace $string $old $new $count`*: Replaces up to `$count` occurences of `$old` with `$new` in `$string`. Alias for [`strings.Replace`](http://golang.org/pkg/strings/#Replace)
228229
* *`sha1 $string`*: Returns the hexadecimal representation of the SHA1 hash of `$string`.
229230
* *`split $string $sep`*: Splits `$string` into a slice of substrings delimited by `$sep`. Alias for [`strings.Split`](http://golang.org/pkg/strings/#Split)

examples/docker-gen.service

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=A file generator that renders templates using Docker Container meta-data.
3+
Documentation=https://github.com/jwilder/docker-gen
4+
After=network.target docker.socket
5+
Requires=docker.socket
6+
7+
[Service]
8+
ExecStart=/usr/bin/docker-gen -config /etc/docker-gen.cfg
9+
10+
[Install]
11+
WantedBy=multi-user.target

template.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os"
1414
"path/filepath"
1515
"reflect"
16+
"strconv"
1617
"strings"
1718
"syscall"
1819
"text/template"
@@ -360,6 +361,7 @@ func newTemplate(name string) *template.Template {
360361
"keys": keys,
361362
"last": arrayLast,
362363
"replace": strings.Replace,
364+
"parseBool": strconv.ParseBool,
363365
"parseJson": unmarshalJson,
364366
"queryEscape": url.QueryEscape,
365367
"sha1": hashSha1,

0 commit comments

Comments
 (0)