diff --git a/lib/librarian/puppet/cli.rb b/lib/librarian/puppet/cli.rb index afb8e88c..1359dcd4 100644 --- a/lib/librarian/puppet/cli.rb +++ b/lib/librarian/puppet/cli.rb @@ -47,6 +47,7 @@ def init option "destructive", :type => :boolean, :default => false option "local", :type => :boolean, :default => false option "use-v1-api", :type => :boolean, :default => true + option "use-forge", :type => :boolean def install ensure! @@ -63,6 +64,9 @@ def install end environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil + unless options["use-forge"].nil? + environment.config_db.local['use-forge'] = options['use-forge'].to_s + end environment.config_db.local['mode'] = options['local'] ? 'local' : nil resolve! @@ -84,6 +88,7 @@ def update(*names) option "strip-dot-git", :type => :boolean option "path", :type => :string option "destructive", :type => :boolean, :default => false + option "use-forge", :type => :boolean def package environment.vendor! install diff --git a/lib/librarian/puppet/environment.rb b/lib/librarian/puppet/environment.rb index d5024159..7890ebc9 100644 --- a/lib/librarian/puppet/environment.rb +++ b/lib/librarian/puppet/environment.rb @@ -57,6 +57,10 @@ def local? def use_v1_api config_db['use-v1-api'] end + + def use_forge + config_db['use-forge'].to_s == 'false' ? false : true + end end end end diff --git a/lib/librarian/puppet/source/local.rb b/lib/librarian/puppet/source/local.rb index 4a3744ce..615ae9f7 100644 --- a/lib/librarian/puppet/source/local.rb +++ b/lib/librarian/puppet/source/local.rb @@ -13,13 +13,23 @@ def install!(manifest) name, version = manifest.name, manifest.version found_path = found_path(name) - raise Error, "Path for #{name} doesn't contain a puppet module" if found_path.nil? - unless name.include? '/' or name.include? '-' - warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" } + # We only care about this if we're fetching from a Forge + if found_path || self.is_a?(Librarian::Puppet::Source::Forge) + raise Error, "Path for #{name} doesn't contain a puppet module" if found_path.nil? + + unless name.include? '/' or name.include? '-' + warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" } + end + + install_path = environment.install_path.join(module_name(name)) + elsif !repository_cached + raise Error, "Could not find cached version of #{name} for installation" + else + found_path = repository_cache_path + install_path = environment.project_path + path.to_s end - install_path = environment.install_path.join(module_name(name)) if install_path.exist? && rsync? != true debug { "Deleting #{relative_path_to(install_path)}" } install_path.rmtree @@ -43,9 +53,13 @@ def fetch_dependencies(name, version, extra) end parsed_metadata['dependencies'].each do |d| - gem_requirement = Librarian::Dependency::Requirement.new(d['version_requirement']).to_gem_requirement - new_dependency = Dependency.new(d['name'], gem_requirement, forge_source) - dependencies << new_dependency + if environment.use_forge + gem_requirement = Librarian::Dependency::Requirement.new(d['version_requirement']).to_gem_requirement + new_dependency = Dependency.new(d['name'], gem_requirement, forge_source) + dependencies << new_dependency + end + + dependencies end dependencies