Merge "Remove unused extract_id function"

This commit is contained in:
Zuul 2022-05-25 17:20:44 +00:00 committed by Gerrit Code Review
commit d0846b34df
2 changed files with 0 additions and 23 deletions

View File

@ -1,17 +0,0 @@
# Custom function to extract the index from a list.
# The list are a list of hostname, and the index is the n'th
# position of the host in list
Puppet::Functions.create_function(:extract_id) do
dispatch :extract_id do
param 'Variant[Array, String]', :hosts
param 'String', :hostname
end
def extract_id(hosts, hostname)
if hosts.class != Array
hosts = [hosts]
end
hash = Hash[hosts.map.with_index.to_a]
return hash[hostname].to_i + 1
end
end

View File

@ -1,6 +0,0 @@
require 'spec_helper'
describe 'extract_id' do
it { should run.with_params('127.0.0.1', '127.0.0.1').and_return(1) }
it { should run.with_params(["127.0.0.1", "127.0.0.2"], "127.0.0.2").and_return(2) }
end