Class: R10K::Environment::Git
- Inherits:
-
WithModules
- Object
- Base
- WithModules
- R10K::Environment::Git
- Includes:
- Util::Purgeable, Util::Setopts
- Defined in:
- lib/r10k/environment/git.rb
Overview
This class implements an environment based on a Git branch.
Constant Summary
Constants included from Util::Purgeable
Util::Purgeable::FN_MATCH_OPTS, Util::Purgeable::HIDDEN_FILE
Constants included from Logging
Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP
Instance Attribute Summary collapse
- #ref ⇒ Object readonly
- #remote ⇒ Object readonly
- #repo ⇒ Object readonly
Attributes inherited from WithModules
Attributes inherited from Base
#basedir, #dirname, #loader, #managed_directories, #name, #path, #puppetfile, #puppetfile_name
Instance Method Summary collapse
-
#desired_contents ⇒ Array<String>
Returns an array of the full paths to all the content being managed.
-
#initialize(name, basedir, dirname, options = {}) ⇒ Git
constructor
Initialize the given Git environment.
-
#signature ⇒ String
Return a sting which uniquely identifies (per source) the current state of the environment.
- #status ⇒ Object
-
#sync ⇒ void
Clone or update the given Git environment.
Methods included from Util::Purgeable
#current_contents, #logger, #managed_directories, #matches?, #pending_contents, #potentially_purgeable, #purge!, #stale_contents
Methods included from Logging
add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Methods inherited from WithModules
#accept, #add_module, #cleanpath, #deploy, #load_modules, #module_conflicts?, #modules, #purge_exclusions, #resolve_path, #validate_install_path
Methods inherited from Base
#accept, #deploy, #determine_purge_exclusions, #generate_types!, #info, #load_puppetfile_modules, #module_conflicts?, #modules, #purge_exclusions, #whitelist
Constructor Details
#initialize(name, basedir, dirname, options = {}) ⇒ Git
Initialize the given Git environment.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/r10k/environment/git.rb', line 38 def initialize(name, basedir, dirname, = {}) super setopts(, { # Standard option interface :version => :ref, :source => :remote, :type => ::R10K::Util::Setopts::Ignore, # Type-specific options :ref => :self, :remote => :self, }, raise_on_unhandled: false) # TODO: in r10k 4.0.0, a major version bump, stop allowing garbage options. # We only allow them now, here, on this object, because prior to adopting # setopts in the constructor, this object type didn't do any validation # checking of options passed, and would permit garbage parameters. @repo = R10K::Git::StatefulRepository.new(@remote, @basedir, @dirname) end |
Instance Attribute Details
#ref ⇒ Object (readonly)
20 21 22 |
# File 'lib/r10k/environment/git.rb', line 20 def ref @ref end |
#remote ⇒ Object (readonly)
16 17 18 |
# File 'lib/r10k/environment/git.rb', line 16 def remote @remote end |
#repo ⇒ Object (readonly)
25 26 27 |
# File 'lib/r10k/environment/git.rb', line 25 def repo @repo end |
Instance Method Details
#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.
88 89 90 91 92 |
# File 'lib/r10k/environment/git.rb', line 88 def desired_contents desired = [File.join(@full_path, '.git')] desired += @repo.tracked_paths.map { |entry| File.join(@full_path, entry) } desired += super end |
#signature ⇒ String
Return a sting which uniquely identifies (per source) the current state of the environment.
79 80 81 |
# File 'lib/r10k/environment/git.rb', line 79 def signature @repo.head end |
#status ⇒ Object
70 71 72 |
# File 'lib/r10k/environment/git.rb', line 70 def status @repo.status(@ref) 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.
66 67 68 |
# File 'lib/r10k/environment/git.rb', line 66 def sync @repo.sync(@ref) end |