Module: PDK::ControlRepo
- Defined in:
- lib/pdk/control_repo.rb
Constant Summary collapse
- CONTROL_REPO_FILES =
['environment.conf', 'Puppetfile'].freeze
- DEFAULT_IGNORED =
[ '/pkg/', '~*', '/coverage', # Strictly speaking this isn't default but if people have tricked older PDK into thinking that a # Control Repo is a module, they may have recursive symlinks in spec/fixtures/modules '/spec/fixtures/modules/', '/vendor/' ].freeze
Class Method Summary collapse
-
.control_repo_root?(path = Dir.pwd) ⇒ boolean
Returns true or false depending on if any of the common files in a Control Repo are found in the specified directory.
- .default_ignored_pathspec(ignore_dotfiles = true) ⇒ Object
-
.environment_conf_as_config(path) ⇒ PDK::Config::IniFile
Returns a PDK::Config::Namespace for the specified environment.conf file.
-
.find_control_repo_root(strict_check = false) ⇒ String?
Returns path to the root of the Control Repo being worked on.
Class Method Details
.control_repo_root?(path = Dir.pwd) ⇒ boolean
Returns true or false depending on if any of the common files in a Control Repo are found in the specified directory. If a directory is not specified, the current working directory is used.
54 55 56 |
# File 'lib/pdk/control_repo.rb', line 54 def control_repo_root?(path = Dir.pwd) CONTROL_REPO_FILES.any? { |file| PDK::Util::Filesystem.file?(File.join(path, file)) } end |
.default_ignored_pathspec(ignore_dotfiles = true) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/pdk/control_repo.rb', line 80 def default_ignored_pathspec(ignore_dotfiles = true) require 'pathspec' PathSpec.new(DEFAULT_IGNORED).tap do |ps| ps.add('.*') if ignore_dotfiles end end |
.environment_conf_as_config(path) ⇒ PDK::Config::IniFile
Returns a PDK::Config::Namespace for the specified environment.conf file. Note there is no validation of the path.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pdk/control_repo.rb', line 65 def environment_conf_as_config(path) PDK::Config::IniFile.new('environment', file: path) do setting :modulepath do # As per https://puppet.com/docs/puppet/latest/config_file_environment.html#allowed-settings default_to { 'modules:$basemodulepath' } end setting :manifest do # As per https://puppet.com/docs/puppet/latest/config_file_environment.html#allowed-settings default_to { 'manifests/' } end end end |
.find_control_repo_root(strict_check = false) ⇒ String?
Returns path to the root of the Control Repo being worked on.
An environment.conf is required for a PDK compatible Control Repo, whereas Puppetfile is optional.
Note - A Bolt Project can also be a Control Repo.
Note - Non-Directory environments can exist however directory based environments are the supported/preferred way.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pdk/control_repo.rb', line 35 def find_control_repo_root(strict_check = false) environment_conf_path = PDK::Util.find_upwards('environment.conf') path = if environment_conf_path File.dirname(environment_conf_path) elsif control_repo_root?(Dir.pwd) Dir.pwd end return path if path.nil? || !strict_check PDK::Bolt.bolt_project_root?(path) ? nil : path end |