Class: R10K::Puppetfile
- Inherits:
-
Object
- Object
- R10K::Puppetfile
- Includes:
- Logging, Settings::Mixin, Util::Purgeable
- Defined in:
- lib/r10k/puppetfile.rb
Overview
Deprecated, use R10K::ModuleLoader::Puppetfile#load to load content, provide the ‘:modules` key of the returned Hash to R10K::ContentSynchronizer (either the `serial_sync` or `concurrent_sync`) and the remaining keys (`:managed_directories`, `:desired_contents`, and `:purge_exclusions`) to R10K::Util::Cleaner.
Constant Summary
Constants included from Util::Purgeable
Util::Purgeable::FN_MATCH_OPTS, Util::Purgeable::HIDDEN_FILE
Constants included from Logging
Instance Attribute Summary collapse
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#force ⇒ Boolean
Overwrite any locally made changes.
-
#forge ⇒ Object
readonly
Returns the value of attribute forge.
-
#loader ⇒ Object
readonly
Returns the value of attribute loader.
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #add_module(name, args) ⇒ Object
-
#desired_contents ⇒ Array<String>
Returns an array of the full paths to all the content being managed.
-
#initialize(basedir, options_or_moduledir = nil, deprecated_path_arg = nil, deprecated_name_arg = nil, deprecated_force_arg = nil) ⇒ Puppetfile
constructor
A new instance of Puppetfile.
- #load(default_branch_override = nil) ⇒ Object
- #load!(default_branch_override = nil) ⇒ Object
- #loaded? ⇒ Boolean
- #managed_directories ⇒ Object
- #moduledir ⇒ Object
- #modules ⇒ Object
- #puppetfile_path ⇒ Object
- #purge_exclusions ⇒ Object
- #set_forge(forge) ⇒ Object
- #set_moduledir(dir) ⇒ Object
- #sync ⇒ Object
Methods included from Util::Purgeable
#current_contents, #logger, #matches?, #pending_contents, #potentially_purgeable, #purge!, #stale_contents
Methods included from Logging
debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Methods included from Settings::Mixin
Constructor Details
#initialize(basedir, options_or_moduledir = nil, deprecated_path_arg = nil, deprecated_name_arg = nil, deprecated_force_arg = nil) ⇒ Puppetfile
Returns a new instance of Puppetfile.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/r10k/puppetfile.rb', line 55 def initialize(basedir, = nil, deprecated_path_arg = nil, deprecated_name_arg = nil, deprecated_force_arg = nil) @basedir = basedir if .is_a? Hash = deprecated_moduledir_arg = nil else = {} deprecated_moduledir_arg = end @force = deprecated_force_arg || .delete(:force) || false @moduledir = deprecated_moduledir_arg || .delete(:moduledir) || File.join(basedir, 'modules') puppetfile_name = deprecated_name_arg || .delete(:puppetfile_name) || 'Puppetfile' puppetfile_path = deprecated_path_arg || .delete(:puppetfile_path) @puppetfile = puppetfile_path || puppetfile_name @environment = .delete(:environment) @overrides = .delete(:overrides) || {} @default_branch_override = @overrides.dig(:environments, :default_branch_override) @forge = 'forgeapi.puppetlabs.com' @loader = ::R10K::ModuleLoader::Puppetfile.new( basedir: @basedir, moduledir: @moduledir, puppetfile: @puppetfile, forge: @forge, overrides: @overrides, environment: @environment ) @loaded_content = { modules: [], managed_directories: [], desired_contents: [], purge_exclusions: [] } @loaded = false end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
31 32 33 |
# File 'lib/r10k/puppetfile.rb', line 31 def basedir @basedir end |
#environment ⇒ Object
Returns the value of attribute environment.
35 36 37 |
# File 'lib/r10k/puppetfile.rb', line 35 def environment @environment end |
#force ⇒ Boolean
Returns Overwrite any locally made changes.
39 40 41 |
# File 'lib/r10k/puppetfile.rb', line 39 def force @force end |
#forge ⇒ Object (readonly)
Returns the value of attribute forge.
27 28 29 |
# File 'lib/r10k/puppetfile.rb', line 27 def forge @forge end |
#loader ⇒ Object (readonly)
Returns the value of attribute loader.
47 48 49 |
# File 'lib/r10k/puppetfile.rb', line 47 def loader @loader end |
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
43 44 45 |
# File 'lib/r10k/puppetfile.rb', line 43 def overrides @overrides end |
Instance Method Details
#accept(visitor) ⇒ Object
186 187 188 189 190 191 192 193 |
# File 'lib/r10k/puppetfile.rb', line 186 def accept(visitor) pool_size = self.settings[:pool_size] if pool_size > 1 R10K::ContentSynchronizer.concurrent_accept(modules, visitor, self, pool_size, logger) else R10K::ContentSynchronizer.serial_accept(modules, visitor, self) end end |
#add_module(name, args) ⇒ Object
138 139 140 |
# File 'lib/r10k/puppetfile.rb', line 138 def add_module(name, args) @loader.add_module(name, args) end |
#desired_contents ⇒ Array<String>
This implements a required method for the Purgeable mixin
Returns an array of the full paths to all the content being managed.
174 175 176 177 178 |
# File 'lib/r10k/puppetfile.rb', line 174 def desired_contents self.load @loaded_content[:desired_contents] end |
#load(default_branch_override = nil) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/r10k/puppetfile.rb', line 100 def load(default_branch_override = nil) if self.loaded? return @loaded_content else if !File.readable?(puppetfile_path) logger.debug _("Puppetfile %{path} missing or unreadable") % {path: puppetfile_path.inspect} else self.load!(default_branch_override) end end end |
#load!(default_branch_override = nil) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/r10k/puppetfile.rb', line 116 def load!(default_branch_override = nil) if default_branch_override && (default_branch_override != @default_branch_override) logger.warn("Mismatch between passed and initialized default branch overrides, preferring passed value.") @loader.default_branch_override = default_branch_override end @loaded_content = @loader.load @loaded = true @loaded_content end |
#loaded? ⇒ Boolean
129 130 131 |
# File 'lib/r10k/puppetfile.rb', line 129 def loaded? @loaded end |
#managed_directories ⇒ Object
165 166 167 168 169 |
# File 'lib/r10k/puppetfile.rb', line 165 def managed_directories self.load @loaded_content[:managed_directories] end |
#moduledir ⇒ Object
150 151 152 |
# File 'lib/r10k/puppetfile.rb', line 150 def moduledir @loader.moduledir end |
#modules ⇒ Object
133 134 135 |
# File 'lib/r10k/puppetfile.rb', line 133 def modules @loaded_content[:modules] end |
#puppetfile_path ⇒ Object
154 155 156 |
# File 'lib/r10k/puppetfile.rb', line 154 def puppetfile_path @loader.puppetfile_path end |
#purge_exclusions ⇒ Object
180 181 182 183 184 |
# File 'lib/r10k/puppetfile.rb', line 180 def purge_exclusions self.load @loaded_content[:purge_exclusions] end |
#set_forge(forge) ⇒ Object
146 147 148 |
# File 'lib/r10k/puppetfile.rb', line 146 def set_forge(forge) @loader.set_forge(forge) end |
#set_moduledir(dir) ⇒ Object
142 143 144 |
# File 'lib/r10k/puppetfile.rb', line 142 def set_moduledir(dir) @loader.set_moduledir(dir) end |
#sync ⇒ Object
195 196 197 198 199 200 201 202 |
# File 'lib/r10k/puppetfile.rb', line 195 def sync pool_size = self.settings[:pool_size] if pool_size > 1 R10K::ContentSynchronizer.concurrent_sync(modules, pool_size, logger) else R10K::ContentSynchronizer.serial_sync(modules) end end |