From 047505896ace981222fe16a1c01c0284db121a4b Mon Sep 17 00:00:00 2001 From: "jaehun.lee" Date: Tue, 10 Sep 2019 20:53:26 +0900 Subject: [PATCH 1/4] added contains template function test in template_test.go --- resource/template/template_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/resource/template/template_test.go b/resource/template/template_test.go index adafbea27..5cb845a16 100644 --- a/resource/template/template_test.go +++ b/resource/template/template_test.go @@ -787,6 +787,25 @@ keys = [ updateStore: func(tr *TemplateResource) { tr.store.Set("/test/count", "3") }, + }, templateTest{ + desc: "contains test", + toml: ` +[template] +src = "test.conf.tmpl" +dest = "./tmp/test.conf" +keys = [ + "/test/value/", +] +`, + tmpl: ` +isContainGolang = {{ contains "golang, java, python" (getv "/test/value") }} +`, + expected: ` +isContainGolang = true +`, + updateStore: func(tr *TemplateResource) { + tr.store.Set("/test/value", "golang") + }, }, } From 9378d64045c5f959ee1d794507b9e4f620eb7107 Mon Sep 17 00:00:00 2001 From: "jaehun.lee" Date: Tue, 10 Sep 2019 20:53:58 +0900 Subject: [PATCH 2/4] added contains template function in template docs --- docs/templates.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/templates.md b/docs/templates.md index c74f09ddc..e31ff3584 100644 --- a/docs/templates.md +++ b/docs/templates.md @@ -364,6 +364,20 @@ Alias for the [strconv.Atoi](https://golang.org/pkg/strconv/#Atoi) function. {{seq 1 (atoi (getv "/count"))}} ``` +### contains + +Alias for the [strings.Contains](https://golang.org/pkg/strings/#Contains) function. +Returns true or false. whether the argument is contained in a string. + +``` +isProgrammingLanguage = {{contains "golang, java, python" (getv "/programming/language")}} +``` + +Output +``` +isProgrammingLanguage = true +``` + ## Example Usage ```Bash From 0fcf87553d10cbab915c9a5baa2b895424e31d95 Mon Sep 17 00:00:00 2001 From: "jaehun.lee" Date: Tue, 10 Sep 2019 21:06:43 +0900 Subject: [PATCH 3/4] apply go format --- config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.go b/config.go index dcd36d5c1..54d91f611 100644 --- a/config.go +++ b/config.go @@ -44,7 +44,7 @@ func init() { flag.StringVar(&config.ClientCaKeys, "client-ca-keys", "", "client ca keys") flag.StringVar(&config.ClientCert, "client-cert", "", "the client cert") flag.StringVar(&config.ClientKey, "client-key", "", "the client key") - flag.BoolVar(&config.ClientInsecure, "client-insecure", false, "Allow connections to SSL sites without certs (only used with -backend=etcd)") + flag.BoolVar(&config.ClientInsecure, "client-insecure", false, "Allow connections to SSL sites without certs (only used with -backend=etcd)") flag.StringVar(&config.ConfDir, "confdir", "/etc/confd", "confd conf directory") flag.StringVar(&config.ConfigFile, "config-file", "/etc/confd/confd.toml", "the confd config file") flag.Var(&config.YAMLFile, "file", "the YAML file to watch for changes (only used with -backend=file)") From d4b238cf307693273bc633c1cdf8735e8607814f Mon Sep 17 00:00:00 2001 From: "jaehun.lee" Date: Tue, 10 Sep 2019 21:17:06 +0900 Subject: [PATCH 4/4] edit zookeeper url for travis CI --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0ec5ba096..40f292457 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ before_install: - sudo mv vault /bin/ - vault server -dev & # Install zookeeper - - wget http://www.eu.apache.org/dist/zookeeper/zookeeper-${ZOOKEEPER_VERSION}/zookeeper-${ZOOKEEPER_VERSION}.tar.gz + - wget https://archive.apache.org/dist/zookeeper/zookeeper-${ZOOKEEPER_VERSION}/zookeeper-${ZOOKEEPER_VERSION}.tar.gz - tar xzf zookeeper-${ZOOKEEPER_VERSION}.tar.gz - mkdir /tmp/zookeeper && cp integration/zookeeper/zoo.cfg zookeeper-${ZOOKEEPER_VERSION}/conf/zoo.cfg - zookeeper-${ZOOKEEPER_VERSION}/bin/zkServer.sh start