voxpupuli / onceover

Your gateway drug to automated infrastructure testing with Puppet
Apache License 2.0
142 stars 45 forks source link

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

Open cdenneen opened 3 years ago

cdenneen commented 3 years ago

This will allow for r10k.yaml to be added the the project root and read r10k specific configurations:

---
forge: {baseurl: 'https://artifactory.example.com/api/puppet/puppet'}

@barrymw added this in #166 so trying to get it into upstream for use now. Hacking controlrepo.rb isn't desired.

cdenneen commented 3 years ago

@dylanratcliffe I do not see a reason in this PR why these tests would fail. Can you check your full_tests?

dylanratcliffe commented 3 years ago

Hey so the testing is showing a legitimate error. If someone doesn't have an r10k.yaml file they get the following:

$ bundle exec onceover show puppetfile --debug --trace                                                                                                                                  

DEBUG    -> Reading /Users/dylan/git/puppet_controlrepo/environment.conf
DEBUG    -> Reading puppetfile from /Users/dylan/git/puppet_controlrepo

Error while running: #<R10K::Settings::Loader::ConfigError: Couldn't load config file: No such file or directory @ rb_sysopen - r10k.yaml>
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/r10k-3.8.0/lib/r10k/settings/loader.rb:69:in `rescue in read'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/r10k-3.8.0/lib/r10k/settings/loader.rb:66:in `read'
/Users/dylan/git/onceover/lib/onceover/controlrepo.rb:222:in `settings_from_config'
/Users/dylan/git/onceover/lib/onceover/controlrepo.rb:233:in `print_puppetfile_table'
/Users/dylan/git/onceover/lib/onceover/cli/show.rb:66:in `block (2 levels) in command'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/cri-2.15.11/lib/cri/command.rb:362:in `run_this'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/cri-2.15.11/lib/cri/command.rb:298:in `run'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/cri-2.15.11/lib/cri/command.rb:316:in `run'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/cri-2.15.11/lib/cri/command.rb:316:in `run'
/Users/dylan/git/onceover/bin/onceover:7:in `<top (required)>'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/bin/onceover:23:in `load'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/bin/onceover:23:in `<top (required)>'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `load'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:28:in `run'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/cli.rb:463:in `exec'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/cli.rb:27:in `dispatch'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/cli.rb:18:in `start'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/exe/bundle:30:in `block in <top (required)>'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/Users/dylan/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/exe/bundle:22:in `<top (required)>'
/Users/dylan/.rbenv/versions/2.5.7/bin/bundle:23:in `load'
/Users/dylan/.rbenv/versions/2.5.7/bin/bundle:23:in `<main>'

Seems like it's trying to read from the r10k.yaml file without checking to see if it exists first. Ideally it would use the r10k_config_file method to determine both the config file location, and whether or not it exists. That method implements the r10k config logic described in the readme which would mean it would match the behaviour of onceover run spec from an R10k perspective