From 2d44c7b775fc7c36334a6be2f1ba4e297661f604 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Fri, 6 Apr 2018 11:47:12 +0200 Subject: [PATCH] ret2bool --- CHANGELOG.md | 4 +++ lib/puppet/parser/functions/retcode2bool.rb | 27 +++++++++++++++++++++ metadata.json | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 lib/puppet/parser/functions/retcode2bool.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ef7d13..4d3faab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.1.15 + +* added **retcode2bool** function + ## 0.1.14 * added **eypconf_projectid** diff --git a/lib/puppet/parser/functions/retcode2bool.rb b/lib/puppet/parser/functions/retcode2bool.rb new file mode 100644 index 0000000..fad44bc --- /dev/null +++ b/lib/puppet/parser/functions/retcode2bool.rb @@ -0,0 +1,27 @@ +# shamesly stolen from: https://github.com/puppetlabs/puppetlabs-apache/blob/master/lib/puppet/parser/functions/bool2httpd.rb +# with minor changes +# +# +#Copyright (C) 2012 Puppet Labs Inc +# +#Puppet Labs can be contacted at: info@puppetlabs.com +# +#Licensed under the Apache License, Version 2.0 (the "License"); +# +# +Puppet::Parser::Functions::newfunction(:retcode2bool, :type => :rvalue, :doc => <<-EOS +Tranform a return code to a bool: +0: true +other return codes: false +EOS +) do |args| + raise(Puppet::ParseError, "retcode2bool() wrong number of arguments. #{args.size} vs 1)") if args.size != 1 + + arg = args[0] + + if arg == 0 + return true + else + return false + end +end diff --git a/metadata.json b/metadata.json index 8835ae9..2df4f1a 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-eyplib", - "version": "0.1.14", + "version": "0.1.15", "author": "eyp", "summary": "Utility functions for puppet modules", "license": "Apache-2.0",