Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to allow r10k.yaml configuration settings. (work of @barrymw) #310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/onceover/controlrepo.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'r10k/puppetfile'
require 'r10k/initializers'
require 'r10k/settings/loader'
require 'erb'
require 'yaml'
require 'find'
Expand Down Expand Up @@ -214,6 +216,12 @@ def facts(filter = nil, key = 'values')
return all_facts
end

def settings_from_config(override_path)
loader = R10K::Settings::Loader.new
path = loader.search(override_path)
loader.read(path)
end

def print_puppetfile_table
require 'terminal-table'
require 'versionomy'
Expand All @@ -222,6 +230,9 @@ def print_puppetfile_table

# Load up the Puppetfile using R10k
logger.debug "Reading puppetfile from #{@root}"
@settings = R10K::Settings.global_settings.evaluate(settings_from_config('r10k.yaml'))
R10K::Initializers::GlobalInitializer.new(@settings).call
logger.debug "Settings: #{@settings}"
puppetfile = R10K::Puppetfile.new(@root)
logger.debug "Loading modules from Puppetfile"
puppetfile.load!
Expand Down Expand Up @@ -250,7 +261,11 @@ def print_puppetfile_table
end

row << mod.v3_module.endorsement
superseded_by = mod.v3_module.superseded_by
begin
superseded_by = mod.v3_module.superseded_by
rescue NoMethodError
superseded_by = nil
end
row << (superseded_by.nil? ? '' : superseded_by[:slug])
else
row << "N/A"
Expand All @@ -275,6 +290,8 @@ def update_puppetfile

# Read in the Puppetfile as a string and as an object
puppetfile_string = File.read(@puppetfile).split("\n")
@settings = R10K::Settings.global_settings.evaluate(settings_from_config('r10k.yaml'))
R10K::Initializers::GlobalInitializer.new(@settings).call
puppetfile = R10K::Puppetfile.new(@root)
puppetfile.load!

Expand Down