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 |
# 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, 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
185 186 187 188 189 190 191 192 |
# File 'lib/r10k/puppetfile.rb', line 185 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
137 138 139 |
# File 'lib/r10k/puppetfile.rb', line 137 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.
173 174 175 176 177 |
# File 'lib/r10k/puppetfile.rb', line 173 def desired_contents self.load @loaded_content[:desired_contents] end |
#load(default_branch_override = nil) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/r10k/puppetfile.rb', line 99 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
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/r10k/puppetfile.rb', line 115 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
128 129 130 |
# File 'lib/r10k/puppetfile.rb', line 128 def loaded? @loaded end |
#managed_directories ⇒ Object
164 165 166 167 168 |
# File 'lib/r10k/puppetfile.rb', line 164 def managed_directories self.load @loaded_content[:managed_directories] end |
#moduledir ⇒ Object
149 150 151 |
# File 'lib/r10k/puppetfile.rb', line 149 def moduledir @loader.moduledir end |
#modules ⇒ Object
132 133 134 |
# File 'lib/r10k/puppetfile.rb', line 132 def modules @loaded_content[:modules] end |
#puppetfile_path ⇒ Object
153 154 155 |
# File 'lib/r10k/puppetfile.rb', line 153 def puppetfile_path @loader.puppetfile_path end |
#purge_exclusions ⇒ Object
179 180 181 182 183 |
# File 'lib/r10k/puppetfile.rb', line 179 def purge_exclusions self.load @loaded_content[:purge_exclusions] end |
#set_forge(forge) ⇒ Object
145 146 147 |
# File 'lib/r10k/puppetfile.rb', line 145 def set_forge(forge) @loader.set_forge(forge) end |
#set_moduledir(dir) ⇒ Object
141 142 143 |
# File 'lib/r10k/puppetfile.rb', line 141 def set_moduledir(dir) @loader.set_moduledir(dir) end |
#sync ⇒ Object
194 195 196 197 198 199 200 201 |
# File 'lib/r10k/puppetfile.rb', line 194 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 |