Class: R10K::Environment::Git
- Includes:
- Logging
- Defined in:
- lib/r10k/environment/git.rb
Overview
This class implements an environment based on a Git branch.
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
- #puppetfile ⇒ Object readonly
- #ref ⇒ Object readonly
- #remote ⇒ Object readonly
- #working_dir ⇒ Object readonly
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(name, basedir, dirname, options = {}) ⇒ Git
constructor
Initialize the given SVN environment.
-
#modules ⇒ Array<R10K::Module::Base>
All modules defined in the Puppetfile associated with this environment.
-
#sync ⇒ void
Clone or update the given Git environment.
- #sync_modules ⇒ Object private
Methods included from Logging
formatter, included, level, level=, levels, #logger, #logger_name, outputter, parse_level
Constructor Details
#initialize(name, basedir, dirname, options = {}) ⇒ Git
Initialize the given SVN environment.
39 40 41 42 43 44 45 46 |
# File 'lib/r10k/environment/git.rb', line 39 def initialize(name, basedir, dirname, = {}) super @remote = [:remote] @ref = [:ref] @working_dir = R10K::Git::WorkingDir.new(@ref, @remote, @basedir, @dirname) @puppetfile = R10K::Puppetfile.new(@full_path) end |
Instance Attribute Details
#puppetfile ⇒ Object (readonly)
28 29 30 |
# File 'lib/r10k/environment/git.rb', line 28 def puppetfile @puppetfile end |
#ref ⇒ Object (readonly)
18 19 20 |
# File 'lib/r10k/environment/git.rb', line 18 def ref @ref end |
#remote ⇒ Object (readonly)
14 15 16 |
# File 'lib/r10k/environment/git.rb', line 14 def remote @remote end |
#working_dir ⇒ Object (readonly)
23 24 25 |
# File 'lib/r10k/environment/git.rb', line 23 def working_dir @working_dir end |
Instance Method Details
#modules ⇒ Array<R10K::Module::Base>
Returns All modules defined in the Puppetfile associated with this environment.
75 76 77 78 |
# File 'lib/r10k/environment/git.rb', line 75 def modules @puppetfile.load @puppetfile.modules end |
#sync ⇒ void
This method returns an undefined value.
Clone or update the given Git environment.
If the environment is being created for the first time, it will automatically update all modules to ensure that the environment is complete.
55 56 57 58 59 60 61 62 63 |
# File 'lib/r10k/environment/git.rb', line 55 def sync recursive_needed = !(@working_dir.cloned?) @working_dir.sync if recursive_needed logger.debug "Environment #{@full_path} is a fresh clone; automatically updating modules." sync_modules end end |
#sync_modules ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 69 70 71 |
# File 'lib/r10k/environment/git.rb', line 66 def sync_modules modules.each do |mod| logger.debug "Deploying module #{mod.name}" mod.sync end end |