Remove os_any2array function
This function was implemented instead of using the any2array function that stdlib exposes because before people were using older versions of stdlib. This function has now been available since stdlib 4.0.0 which is ealier 2013, we should now assume that people have a sufficient version of stdlib and can remove the custom os_any2array function we were carrying. Change-Id: Ia1df93e480ec3137c138ee87d39f5d0ce432722c
This commit is contained in:
parent
cb39f96a86
commit
a0f8f374b8
@ -1,34 +0,0 @@
|
||||
#
|
||||
# os_any2array.rb
|
||||
#
|
||||
# TODO: Remove this function when puppetlabs-stdlib 4.0.0 is in wider use
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:os_any2array, :type => :rvalue, :doc => <<-EOS
|
||||
This converts any object to an array containing that object. Empty argument
|
||||
lists are converted to an empty array. Arrays are left untouched. Hashes are
|
||||
converted to arrays of alternating keys and values.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if arguments.empty?
|
||||
return []
|
||||
end
|
||||
|
||||
if arguments.length == 1
|
||||
if arguments[0].kind_of?(Array)
|
||||
return arguments[0]
|
||||
elsif arguments[0].kind_of?(Hash)
|
||||
result = []
|
||||
arguments[0].each do |key, value|
|
||||
result << key << value
|
||||
end
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
return arguments
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
@ -217,7 +217,7 @@ class horizon::wsgi::apache (
|
||||
|
||||
$default_vhost_conf_no_ip = {
|
||||
servername => $servername,
|
||||
serveraliases => os_any2array($server_aliases),
|
||||
serveraliases => any2array($server_aliases),
|
||||
docroot => '/var/www/',
|
||||
access_log_file => 'horizon_access.log',
|
||||
error_log_file => 'horizon_error.log',
|
||||
|
7
releasenotes/notes/any2array-64602422742c9abe.yaml
Normal file
7
releasenotes/notes/any2array-64602422742c9abe.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The os_any2array function that the Horizon module used internally is now
|
||||
removed and it instead uses the any2array function exposed by the stdlib
|
||||
module. The stdlib module introduced the any2array function in 2013 so we
|
||||
are now expecting that you are using atleast stdlib >= 4.0.0
|
@ -1,55 +0,0 @@
|
||||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper'
|
||||
|
||||
describe "the os_any2array function" do
|
||||
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
||||
|
||||
it "should exist" do
|
||||
expect(Puppet::Parser::Functions.function("os_any2array")).to eq("function_os_any2array")
|
||||
end
|
||||
|
||||
it "should return an empty array if there is less than 1 argument" do
|
||||
result = scope.function_os_any2array([])
|
||||
expect(result).to(eq([]))
|
||||
end
|
||||
|
||||
it "should convert boolean true to [ true ] " do
|
||||
result = scope.function_os_any2array([true])
|
||||
expect(result).to(eq([true]))
|
||||
end
|
||||
|
||||
it "should convert one object to [object]" do
|
||||
result = scope.function_os_any2array(['one'])
|
||||
expect(result).to(eq(['one']))
|
||||
end
|
||||
|
||||
it "should convert multiple objects to [objects]" do
|
||||
result = scope.function_os_any2array(['one', 'two'])
|
||||
expect(result).to(eq(['one', 'two']))
|
||||
end
|
||||
|
||||
it "should return empty array it was called with" do
|
||||
result = scope.function_os_any2array([[]])
|
||||
expect(result).to(eq([]))
|
||||
end
|
||||
|
||||
it "should return one-member array it was called with" do
|
||||
result = scope.function_os_any2array([['string']])
|
||||
expect(result).to(eq(['string']))
|
||||
end
|
||||
|
||||
it "should return multi-member array it was called with" do
|
||||
result = scope.function_os_any2array([['one', 'two']])
|
||||
expect(result).to(eq(['one', 'two']))
|
||||
end
|
||||
|
||||
it "should return members of a hash it was called with" do
|
||||
result = scope.function_os_any2array([{ 'key' => 'value' }])
|
||||
expect(result).to(eq(['key', 'value']))
|
||||
end
|
||||
|
||||
it "should return an empty array if it was called with an empty hash" do
|
||||
result = scope.function_os_any2array([{ }])
|
||||
expect(result).to(eq([]))
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user