{"id":13778044,"url":"https://github.com/binford2k/puppet-function-updater","last_synced_at":"2025-04-23T03:04:02.112Z","repository":{"id":145176657,"uuid":"224527790","full_name":"binford2k/puppet-function-updater","owner":"binford2k","description":"Automagically update legacy Puppet functions to the modern API (ruby)","archived":false,"fork":false,"pushed_at":"2020-01-04T00:04:49.000Z","size":46,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T21:31:50.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://binford2k.com/2019/11/27/automagic-function-port/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binford2k.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-11-27T22:30:59.000Z","updated_at":"2020-02-28T11:50:46.000Z","dependencies_parsed_at":"2023-06-25T22:19:22.417Z","dependency_job_id":null,"html_url":"https://github.com/binford2k/puppet-function-updater","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binford2k%2Fpuppet-function-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binford2k%2Fpuppet-function-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binford2k%2Fpuppet-function-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binford2k%2Fpuppet-function-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binford2k","download_url":"https://codeload.github.com/binford2k/puppet-function-updater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250360479,"owners_count":21417720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:00:50.724Z","updated_at":"2025-04-23T03:04:02.094Z","avatar_url":"https://github.com/binford2k.png","language":"Ruby","funding_links":[],"categories":["Puppet Tools"],"sub_categories":[],"readme":"# Puppet Function Updater\n\nPort legacy Puppet 3.x functions to the new function API automatically.\n\nRun this command with a space separated list of either function file paths, or\ndirectories containing functions. If omitted, it will default to porting all the\nlegacy functions, so you can just run this in the root of a Puppet module and it\nwill do the right thing.\n\n\n## Installation\n\n```\n$ gem install puppet-function-updater\n```\n\n\n## Usage\n\nRun the command puppet_function_updater in the root of a Puppet module, then\ninspect all the generated functions for suitability when it’s done. If you pass\nthe --clean argument it will **delete the legacy function file from disk** after\nvalidating that the new function works.\n\nYou might see some warnings. Many can be ignored. For example, the following\nwarning just means that the function attempted to require a library file outside\nof the the function block. You might evaluate whether you could remove the call\nor move it inside the function declaration so it's lazily loaded.\n\n```\nINFO: Creating lib/puppet/functions/stdlib/deep_merge.rb\nWARN: The function attempted to load libraries outside the function block.\nWARN: cannot load such file -- puppet/parser/functions (ignored)\n```\n\nOn the other hand, errors like below indicate that the function code doesn't parse\nproperly after porting. It's generally an issue with the original source code.\n\n```\nINFO: Creating lib/puppet/functions/stdlib/validate_x509_rsa_key_pair.rb\nERROR: Oh crap; the generated function isn't valid Ruby code!\nERROR: \u003ccompiled\u003e:47: dynamic constant assignment\n    NUM_ARGS = 2 unless defined? NUM_ARGS\n             ^\n```\n\n### After porting\n\nTwo files will be generated, the function file and the spec test for that function.\n\n* `lib/puppet/functions/\u003cnamespace\u003e/\u003cfunction\u003e.rb`\n* `spec/functions/\u003cnamespace\u003e_\u003cfunction\u003e_spec.rb`\n\nAfter porting, you should inspect the generated files. At a minimum, you'll want\nto clean up the documentation comments, but I'd also suggest reading a bit on the\nnew function API and writing better dispatches to provide proper type checking\nand reduce the amount of manual argument validation your function must do.\n\nThe test simply validates that the function compiles and defines a function\nproperly, so you'll also want to write more test cases. If your legacy function\nhas unit tests, you might consider porting them to the new function, following\nthe examples provided as comments.\n\nSee a [tutorial](https://binford2k.com/2019/11/27/automagic-function-port/) on its usage on my blog.\n\n\n### Example:\n\n```\n[~/Projects/puppetlabs-stdlib]$ puppet_function_updater --verbose\nINFO: Creating lib/puppet/functions/stdlib/abs.rb\nINFO: Creating lib/puppet/functions/stdlib/any2array.rb\nINFO: Creating lib/puppet/functions/stdlib/any2bool.rb\nINFO: Creating lib/puppet/functions/stdlib/assert_private.rb\nINFO: Creating lib/puppet/functions/stdlib/base64.rb\nINFO: Creating lib/puppet/functions/stdlib/basename.rb\nINFO: Creating lib/puppet/functions/stdlib/bool2num.rb\nINFO: Creating lib/puppet/functions/stdlib/bool2str.rb\nINFO: Creating lib/puppet/functions/stdlib/camelcase.rb\nINFO: Creating lib/puppet/functions/stdlib/capitalize.rb\nINFO: Creating lib/puppet/functions/stdlib/ceiling.rb\nINFO: Creating lib/puppet/functions/stdlib/chomp.rb\nINFO: Creating lib/puppet/functions/stdlib/chop.rb\nINFO: Creating lib/puppet/functions/stdlib/clamp.rb\nINFO: Creating lib/puppet/functions/stdlib/concat.rb\nINFO: Creating lib/puppet/functions/stdlib/convert_base.rb\nINFO: Creating lib/puppet/functions/stdlib/count.rb\nINFO: Creating lib/puppet/functions/stdlib/deep_merge.rb\nWARN: The function attempted to load libraries outside the function block.\nWARN: cannot load such file -- puppet/parser/functions (ignored)\nINFO: Creating lib/puppet/functions/stdlib/defined_with_params.rb\nINFO: Creating lib/puppet/functions/stdlib/delete.rb\nINFO: Creating lib/puppet/functions/stdlib/delete_at.rb\nINFO: Creating lib/puppet/functions/stdlib/delete_regex.rb\nINFO: Creating lib/puppet/functions/stdlib/delete_undef_values.rb\nINFO: Creating lib/puppet/functions/stdlib/delete_values.rb\nINFO: Creating lib/puppet/functions/stdlib/deprecation.rb\nINFO: Creating lib/puppet/functions/stdlib/difference.rb\nINFO: Creating lib/puppet/functions/stdlib/dig.rb\nINFO: Creating lib/puppet/functions/stdlib/dig44.rb\nINFO: Creating lib/puppet/functions/stdlib/dirname.rb\nINFO: Creating lib/puppet/functions/stdlib/dos2unix.rb\nINFO: Creating lib/puppet/functions/stdlib/downcase.rb\nINFO: Creating lib/puppet/functions/stdlib/empty.rb\nINFO: Creating lib/puppet/functions/stdlib/enclose_ipv6.rb\nINFO: Creating lib/puppet/functions/stdlib/ensure_packages.rb\nWARN: The function attempted to load libraries outside the function block.\nWARN: cannot load such file -- puppet/parser/functions (ignored)\nINFO: Creating lib/puppet/functions/stdlib/ensure_resource.rb\nWARN: The function attempted to load libraries outside the function block.\nWARN: cannot load such file -- puppet/parser/functions (ignored)\nINFO: Creating lib/puppet/functions/stdlib/ensure_resources.rb\nINFO: Creating lib/puppet/functions/stdlib/flatten.rb\nINFO: Creating lib/puppet/functions/stdlib/floor.rb\nINFO: Creating lib/puppet/functions/stdlib/fqdn_rand_string.rb\nINFO: Creating lib/puppet/functions/stdlib/fqdn_rotate.rb\nINFO: Creating lib/puppet/functions/stdlib/fqdn_uuid.rb\nINFO: Creating lib/puppet/functions/stdlib/get_module_path.rb\nWARN: The function attempted to load libraries outside the function block.\nWARN: cannot load such file -- puppet/parser/functions (ignored)\nINFO: Creating lib/puppet/functions/stdlib/getparam.rb\nINFO: Creating lib/puppet/functions/stdlib/getvar.rb\nINFO: Creating lib/puppet/functions/stdlib/glob.rb\nINFO: Creating lib/puppet/functions/stdlib/grep.rb\nINFO: Creating lib/puppet/functions/stdlib/has_interface_with.rb\nINFO: Creating lib/puppet/functions/stdlib/has_ip_address.rb\nINFO: Creating lib/puppet/functions/stdlib/has_ip_network.rb\nINFO: Creating lib/puppet/functions/stdlib/has_key.rb\nINFO: Creating lib/puppet/functions/stdlib/hash.rb\nINFO: Creating lib/puppet/functions/stdlib/intersection.rb\nINFO: Creating lib/puppet/functions/stdlib/is_absolute_path.rb\nINFO: Creating lib/puppet/functions/stdlib/is_array.rb\nINFO: Creating lib/puppet/functions/stdlib/is_bool.rb\nINFO: Creating lib/puppet/functions/stdlib/is_domain_name.rb\nINFO: Creating lib/puppet/functions/stdlib/is_email_address.rb\nINFO: Creating lib/puppet/functions/stdlib/is_float.rb\nINFO: Creating lib/puppet/functions/stdlib/is_function_available.rb\nINFO: Creating lib/puppet/functions/stdlib/is_hash.rb\nINFO: Creating lib/puppet/functions/stdlib/is_integer.rb\nINFO: Creating lib/puppet/functions/stdlib/is_ip_address.rb\nINFO: Creating lib/puppet/functions/stdlib/is_ipv4_address.rb\nINFO: Creating lib/puppet/functions/stdlib/is_ipv6_address.rb\nINFO: Creating lib/puppet/functions/stdlib/is_mac_address.rb\nINFO: Creating lib/puppet/functions/stdlib/is_numeric.rb\nINFO: Creating lib/puppet/functions/stdlib/is_string.rb\nINFO: Creating lib/puppet/functions/stdlib/join.rb\nINFO: Creating lib/puppet/functions/stdlib/join_keys_to_values.rb\nINFO: Creating lib/puppet/functions/stdlib/keys.rb\nINFO: Creating lib/puppet/functions/stdlib/load_module_metadata.rb\nINFO: Creating lib/puppet/functions/stdlib/loadjson.rb\nINFO: Creating lib/puppet/functions/stdlib/loadyaml.rb\nINFO: Creating lib/puppet/functions/stdlib/lstrip.rb\nINFO: Creating lib/puppet/functions/stdlib/max.rb\nINFO: Creating lib/puppet/functions/stdlib/member.rb\nINFO: Creating lib/puppet/functions/stdlib/merge.rb\nINFO: Creating lib/puppet/functions/stdlib/min.rb\nINFO: Creating lib/puppet/functions/stdlib/num2bool.rb\nINFO: Creating lib/puppet/functions/stdlib/parsejson.rb\nINFO: Creating lib/puppet/functions/stdlib/parseyaml.rb\nINFO: Creating lib/puppet/functions/stdlib/pick.rb\nINFO: Creating lib/puppet/functions/stdlib/pick_default.rb\nINFO: Creating lib/puppet/functions/stdlib/prefix.rb\nINFO: Creating lib/puppet/functions/stdlib/private.rb\nINFO: Creating lib/puppet/functions/stdlib/pry.rb\nINFO: Creating lib/puppet/functions/stdlib/pw_hash.rb\nINFO: Creating lib/puppet/functions/stdlib/range.rb\nINFO: Creating lib/puppet/functions/stdlib/regexpescape.rb\nINFO: Creating lib/puppet/functions/stdlib/reject.rb\nINFO: Creating lib/puppet/functions/stdlib/reverse.rb\nINFO: Creating lib/puppet/functions/stdlib/round.rb\nINFO: Creating lib/puppet/functions/stdlib/rstrip.rb\nINFO: Creating lib/puppet/functions/stdlib/seeded_rand.rb\nINFO: Creating lib/puppet/functions/stdlib/shell_escape.rb\nINFO: Creating lib/puppet/functions/stdlib/shell_join.rb\nINFO: Creating lib/puppet/functions/stdlib/shell_split.rb\nINFO: Creating lib/puppet/functions/stdlib/shuffle.rb\nINFO: Creating lib/puppet/functions/stdlib/size.rb\nINFO: Creating lib/puppet/functions/stdlib/sort.rb\nINFO: Creating lib/puppet/functions/stdlib/squeeze.rb\nINFO: Creating lib/puppet/functions/stdlib/str2bool.rb\nINFO: Creating lib/puppet/functions/stdlib/str2saltedsha512.rb\nINFO: Creating lib/puppet/functions/stdlib/strftime.rb\nINFO: Creating lib/puppet/functions/stdlib/strip.rb\nINFO: Creating lib/puppet/functions/stdlib/suffix.rb\nINFO: Creating lib/puppet/functions/stdlib/swapcase.rb\nINFO: Creating lib/puppet/functions/stdlib/time.rb\nINFO: Creating lib/puppet/functions/stdlib/to_bytes.rb\nINFO: Creating lib/puppet/functions/stdlib/try_get_value.rb\nINFO: Creating lib/puppet/functions/stdlib/type.rb\nINFO: Creating lib/puppet/functions/stdlib/type3x.rb\nINFO: Creating lib/puppet/functions/stdlib/union.rb\nINFO: Creating lib/puppet/functions/stdlib/unique.rb\nINFO: Creating lib/puppet/functions/stdlib/unix2dos.rb\nINFO: Creating lib/puppet/functions/stdlib/upcase.rb\nINFO: Creating lib/puppet/functions/stdlib/uriescape.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_absolute_path.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_array.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_augeas.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_bool.rb\nWARN: The function attempted to load libraries outside the function block.\nWARN: cannot load such file -- puppet/util/execution (ignored)\nINFO: Creating lib/puppet/functions/stdlib/validate_cmd.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_domain_name.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_email_address.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_hash.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_integer.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_ip_address.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_ipv4_address.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_ipv6_address.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_numeric.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_re.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_slength.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_string.rb\nINFO: Creating lib/puppet/functions/stdlib/validate_x509_rsa_key_pair.rb\nERROR: Oh crap; the generated function isn't valid Ruby code!\nERROR: \u003ccompiled\u003e:47: dynamic constant assignment\n    NUM_ARGS = 2 unless defined? NUM_ARGS\n             ^\nINFO: Creating lib/puppet/functions/stdlib/values.rb\nINFO: Creating lib/puppet/functions/stdlib/values_at.rb\nINFO: Creating lib/puppet/functions/stdlib/zip.rb\nINFO: Functions generated. Please inspect for suitability and then\nINFO: update any Puppet code with the new function names.\nINFO: See https://puppet.com/docs/puppet/latest/custom_functions_ruby.html\nINFO: for more information about Puppet's modern Ruby function API.\n```\n\n\n## Limitations\n\nThis is super early in development and has not yet been battle tested.\n\n\n## Disclaimer\n\nI take no liability for the use of this tool.\n\n\nContact\n-------\n\nbinford2k@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinford2k%2Fpuppet-function-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinford2k%2Fpuppet-function-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinford2k%2Fpuppet-function-updater/lists"}