Add plugin hiera files support
* Put plugun files to hiera/plugins/$yaml_name/ Change-Id: I21389dcb9bf065a3a6f09753e423fdf942afb767
This commit is contained in:
parent
9c48a9799e
commit
d8c88d2d9d
|
@ -217,6 +217,18 @@ the override file name *firewall-firewall.yaml* and
|
|||
*openstack-controller-keystone.yaml* if these files are found in the
|
||||
override folders.
|
||||
|
||||
Using hiera plugin overrides
|
||||
----------------------------
|
||||
|
||||
If you have several additional YAML files that should be applied on top of
|
||||
the base Hiera files, for example, files, provided or generated by plugins
|
||||
or the other tasks, you can use the plugin override system. Any files which
|
||||
have been placed to the *hiera/plugins/${yaml_base_name}/* folder will be
|
||||
applied on top of this YAML file when it will be used in the Noop tests.
|
||||
|
||||
Multiple files inside this directory will be ordered alphabetically with
|
||||
the former letters having the higher priority.
|
||||
|
||||
Working with report files
|
||||
-------------------------
|
||||
|
||||
|
|
|
@ -32,5 +32,15 @@ module Noop
|
|||
def self.default_hiera_file_name
|
||||
Pathname.new 'novanet-primary-controller.yaml'
|
||||
end
|
||||
|
||||
# @return [Pathname]
|
||||
def self.file_name_hiera_plugins
|
||||
Pathname.new 'plugins'
|
||||
end
|
||||
|
||||
# @return [Pathname]
|
||||
def self.file_path_hiera_plugins
|
||||
Noop::Config.dir_path_hiera + file_name_hiera_plugins
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ module Noop
|
|||
def hiera_file_names
|
||||
return @hiera_file_names if @hiera_file_names
|
||||
error "No #{Noop::Config.dir_path_hiera} directory!" unless Noop::Config.dir_path_hiera.directory?
|
||||
exclude = [ Noop::Config.dir_name_hiera_override, Noop::Config.dir_name_globals ]
|
||||
exclude = [ Noop::Config.dir_name_hiera_override, Noop::Config.dir_name_globals, Noop::Config.file_name_hiera_plugins ]
|
||||
@hiera_file_names = find_files(Noop::Config.dir_path_hiera, Noop::Config.dir_path_hiera, exclude) do |file|
|
||||
file.to_s.end_with? '.yaml'
|
||||
end
|
||||
|
@ -393,6 +393,27 @@ module Noop
|
|||
@task_list
|
||||
end
|
||||
|
||||
# Collect all hiera plugins into a data structure.
|
||||
# Used only for debugging purposes.
|
||||
# @return [Hash<String => Pathname>]
|
||||
def hiera_plugins
|
||||
return @hiera_plugins if @hiera_plugins
|
||||
@hiera_plugins = {}
|
||||
return @hiera_plugins unless Noop::Config.file_path_hiera_plugins.directory?
|
||||
Noop::Config.file_path_hiera_plugins.children.each do |hiera|
|
||||
next unless hiera.directory?
|
||||
hiera_name = hiera.basename.to_s
|
||||
hiera.children.each do |file|
|
||||
next unless file.file?
|
||||
next unless file.to_s.end_with? '.yaml'
|
||||
file = file.relative_path_from Noop::Config.dir_path_hiera
|
||||
@hiera_plugins[hiera_name] = [] unless @hiera_plugins[hiera_name]
|
||||
@hiera_plugins[hiera_name] << file
|
||||
end
|
||||
end
|
||||
@hiera_plugins
|
||||
end
|
||||
|
||||
# Loop through all task files and find those that
|
||||
# do not have a corresponding spec file present
|
||||
# @return [Array<Pathname>]
|
||||
|
|
|
@ -60,6 +60,27 @@ module Noop
|
|||
Noop::Config.dir_name_hiera_override + override_file.sub_ext('')
|
||||
end
|
||||
|
||||
# @return [Pathname]
|
||||
def dir_path_task_hiera_plugins
|
||||
Noop::Config.file_path_hiera_plugins + file_base_hiera
|
||||
end
|
||||
|
||||
# @return [Array<Pathname>]
|
||||
def list_hiera_plugins
|
||||
return @list_hiera_plugins if @list_hiera_plugins
|
||||
@list_hiera_plugins = [] unless @list_hiera_plugins
|
||||
return @list_hiera_plugins unless dir_path_task_hiera_plugins.directory?
|
||||
dir_path_task_hiera_plugins.children.each do |file|
|
||||
next unless file.file?
|
||||
next unless file.to_s.end_with? '.yaml'
|
||||
file = file.relative_path_from Noop::Config.dir_path_hiera
|
||||
file = file.sub_ext('')
|
||||
@list_hiera_plugins << file
|
||||
end
|
||||
@list_hiera_plugins.sort!
|
||||
@list_hiera_plugins
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def hiera_logger
|
||||
if ENV['SPEC_PUPPET_DEBUG']
|
||||
|
@ -72,9 +93,10 @@ module Noop
|
|||
# @return [Array<String>]
|
||||
def hiera_hierarchy
|
||||
elements = []
|
||||
elements += list_hiera_plugins.map(&:to_s) if list_hiera_plugins.any?
|
||||
elements << element_hiera_override.to_s if file_present_hiera_override?
|
||||
elements << element_hiera.to_s if file_present_hiera?
|
||||
elements << element_globals.to_s if file_present_globals?
|
||||
elements << element_hiera.to_s if file_present_hiera?
|
||||
elements
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue