Method: Onceover::VendoredModules#puppetfile_missing_vendored

Defined in:
lib/onceover/vendored_modules.rb

#puppetfile_missing_vendored(puppetfile) ⇒ Object

Currently expects to be passed a R10K::Puppetfile object. ex: R10K::ModuleLoader::Puppetfile.new(basedir: ‘.’)



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/onceover/vendored_modules.rb', line 120

def puppetfile_missing_vendored(puppetfile)
  puppetfile.load
  @vendored_references.each do |mod|
    # Extract name and slug from url
    mod_slug = mod['url'].match(/.*(puppetlabs-\w+)\.git/)[1]
    mod_name = mod_slug.match(/^puppetlabs-(\w+)$/)[1]
    # Array of modules whos names match
    existing = puppetfile.modules.select { |e_mod| e_mod.name == mod_name }
    if existing.empty?
      # Change url to https instead of ssh to allow anonymous git clones
      # so that users do not need to have an ssh keypair associated with a Github account
      url = mod['url'].gsub('[email protected]:', 'https://github.com/')
      @missing_vendored << { mod_slug => { git: url, ref: mod['ref'] } }
      logger.debug "#{mod_name} found to be missing in Puppetfile"
    else
      logger.debug "#{mod_name} found in Puppetfile. Using the specified version"
    end
  end
end