Class: PDK::Context::ControlRepo

Inherits:
AbstractContext show all
Defined in:
lib/pdk/context/control_repo.rb

Overview

Represents a context for a directory based Control Repository

Instance Attribute Summary

Attributes inherited from AbstractContext

#context_path

Instance Method Summary collapse

Methods inherited from AbstractContext

#parent_context, #root_path, #to_debug_log, #to_s

Constructor Details

#initialize(repo_root, context_path) ⇒ ControlRepo

Returns a new instance of ControlRepo.

Parameters:

  • repo_root (String)

    The root path for the control repo.

  • context_path (String)

    The path where this context was created from e.g. Dir.pwd

See Also:



10
11
12
13
14
# File 'lib/pdk/context/control_repo.rb', line 10

def initialize(repo_root, context_path)
  super(context_path)
  @root_path = repo_root
  @environment_conf = nil
end

Instance Method Details

#actualized_module_pathsArray[String]

The relative module_paths that exist on disk.

Returns:

  • (Array[String])

    The relative module paths on disk

See Also:



40
41
42
43
# File 'lib/pdk/context/control_repo.rb', line 40

def actualized_module_paths
  @actualized_module_paths ||= module_paths.reject { |path| path.start_with?('$') }
                                           .select { |path| PDK::Util::Filesystem.directory?(PDK::Util::Filesystem.expand_path(File.join(root_path, path))) }
end

#display_nameObject

:nocov:

See Also:

  • AbstractContext.display_name


47
48
49
# File 'lib/pdk/context/control_repo.rb', line 47

def display_name
  'a Control Repository context'
end

#module_pathsArray[String]

The modulepath setting for this control repository as an array of strings. These paths are relative and may contain interpolation strings (e.g. $basemodulepath)

Returns:

  • (Array[String])

    The modulepath setting for this control repository

See Also:



27
28
29
30
31
32
33
34
35
# File 'lib/pdk/context/control_repo.rb', line 27

def module_paths
  return @module_paths unless @module_paths.nil?

  value = environment_conf['modulepath'] || ''
  # We have to use a hardcoded value here because File::PATH_SEPARATOR is ';' on Windows.
  # As the environment.conf is only used on Puppet Server, it's always ':'
  # Based on - https://github.com/puppetlabs/puppet/blob/f3e6d7e6d87f46408943a8e2176afb82ff6ea096/lib/puppet/settings/environment_conf.rb#L98-L106
  @module_paths = value.split(':')
end

#pdk_compatible?Boolean

Returns:

  • (Boolean)

See Also:

  • AbstractContext.pdk_compatible?


17
18
19
20
21
# File 'lib/pdk/context/control_repo.rb', line 17

def pdk_compatible?
  # Currently there is nothing to determine compatibility with the PDK for a
  # Control Repo. For now assume everything is compatible
  true
end