Skip to content

Commit

Permalink
fix #695 Finish refactoring function API 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed May 30, 2022
1 parent 7d5d346 commit daf5d5c
Show file tree
Hide file tree
Showing 27 changed files with 1,060 additions and 383 deletions.
34 changes: 34 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# devcontainer


For format details, see https://aka.ms/devcontainer.json.

For config options, see the README at:
https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet

``` json
{
"name": "Puppet Development Kit (Community)",
"dockerFile": "Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"puppet.puppet-vscode",
"rebornix.Ruby"
]

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pdk --version",
}
```



16 changes: 5 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet
{
"name": "Puppet Development Kit (Community)",
"dockerFile": "Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
}
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"puppet.puppet-vscode",
"rebornix.Ruby"
]

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pdk --version",
}
1 change: 1 addition & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--relative
--no-140chars-check
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AllCops:
- "**/Puppetfile"
- "**/Vagrantfile"
- "**/Guardfile"
- "lib/puppet_x/**/*"
- lib/puppet_x/**/*.rb
Layout/LineLength:
Description: People have wide screens, use them.
Max: 200
Expand Down Expand Up @@ -518,3 +518,4 @@ Style/RedundantArgument:
Enabled: false
Style/SwapValues:
Enabled: false

1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ end
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_relative')


if Bundler.rubygems.find_name('github_changelog_generator').any?
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html
#
# ---- original file header ----
require File.join(File.dirname(__FILE__), '../../..', 'puppet_x/icinga2/utils.rb')
require_relative '../../../puppet_x/icinga2/utils.rb'

# ---- original file header ----
#
# @summary
# Summarise what the function does here
#
Puppet::Functions.create_function(:'icinga2::icinga2_attributes') do
Puppet::Functions.create_function(:'icinga2::attributes') do
# @param args
# The original array of arguments. Port this to individually managed params
# to get the full benefit of the modern function API.
Expand All @@ -28,7 +28,7 @@
end

def default_impl(*args)
raise Puppet::ParseError, 'icinga2_atributes(): Must provide at least one argument.' if args.length > 4 || args.empty?
raise Puppet::ParseError, 'icinga2::atributes(): Must provide at least one argument.' if args.length > 4 || args.empty?

indent = if args[1]
args[1]
Expand All @@ -37,17 +37,17 @@ def default_impl(*args)
end

globals = if args[2]
args[2].concat(lookupvar('::icinga2::_reserved'))
closure_scope['::icinga2::_reserved'].concat(args[2])
else
lookupvar('::icinga2::_reserved')
closure_scope['::icinga2::_reserved']
end

constants = if args[3]
args[3].merge(lookupvar('::icinga2::_constants'))
closure_scope['::icinga2::_constants'].merge(args[3])
else
lookupvar('::icinga2::_constants')
closure_scope['::icinga2::_constants']
end

Puppet::Icinga2::Utils.attributes(args[0], globals, constants, indent)
PuppetX::Icinga2::Utils.attributes(args[0], globals, constants, indent)
end
end
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# frozen_string_literal: true

require File.join(File.dirname(__FILE__), '../../..', 'puppet_x/icinga2/pbkdf2.rb')
# @summary
# Summarise what the function does here
#
Puppet::Functions.create_function(:'icinga2::icinga2_ticket_id') do
Puppet::Functions.create_function(:'icinga2::ticket_id') do
# @param cn
# The common name of the Icinga host certificate.
#
Expand Down
10 changes: 10 additions & 0 deletions lib/puppet/functions/icinga2_attributes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @summary DEPRECATED. Use the namespaced function [`icinga2::attributes`](#attributes) instead.
Puppet::Functions.create_function(:icinga2_attributes) do
dispatch :deprecation_gen do
repeated_param 'Any', :args
end
def deprecation_gen(*args)
call_function('deprecation', 'icinga2_attributes', 'This method is deprecated, please use icinga2::attributes instead.')
call_function('icinga2::attributes', *args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/icinga2_ticket_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @summary DEPRECATED. Use the namespaced function [`icinga2::ticket_id`](#ticket_id) instead.
Puppet::Functions.create_function(:icinga2_ticket_id) do
dispatch :deprecation_gen do
repeated_param 'Any', :args
end
def deprecation_gen(*args)
call_function('deprecation', 'icinga2_ticket_id', 'This method is deprecated, please use icinga2::ticket_id instead.')
call_function('icinga2::ticket_id', *args)
end
end
33 changes: 0 additions & 33 deletions lib/puppet/parser/functions/icinga2_attributes.rb

This file was deleted.

25 changes: 0 additions & 25 deletions lib/puppet/parser/functions/icinga2_ticket_id.rb

This file was deleted.

4 changes: 4 additions & 0 deletions lib/puppet_x/icinga2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'puppet_x'

# common PuppetX::Icinga2 module definition
module PuppetX::Icinga2; end
Loading

0 comments on commit daf5d5c

Please sign in to comment.