Skip to content

Commit

Permalink
Merge pull request #16 from jordiprats/master
Browse files Browse the repository at this point in the history
retcode2bool
  • Loading branch information
jordiprats authored Apr 6, 2018
2 parents ec97c6f + 339a67f commit b182053
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.1.15

* added **retcode2bool** function

## 0.1.14

* added **eypconf_projectid**
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ Transform a boolean (it can also be a string) to **yes** or **no**. Other values

Transform a boolean (it can also be a string) to **y** or **n**. Other values through.

#### retcode2bool

Transform a return code to a bool (0: true, other values: false)


## Development

Expand Down
27 changes: 27 additions & 0 deletions lib/puppet/parser/functions/retcode2bool.rb
Original file line number Diff line number Diff line change
@@ -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: [email protected]
#
#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
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit b182053

Please sign in to comment.