From 71f73adb93f565ce749ab7798b7fd97bda91281f Mon Sep 17 00:00:00 2001 From: Maggie Dreyer Date: Fri, 31 Jan 2020 09:22:32 -0800 Subject: [PATCH] (RK-360) Allow overriding the cachedir in `deploy module` Previously, we added the ability to configure the cachedir from the CLI for the `deploy environment` command, since Code Manager configures a separate cachedir for each of its r10k workers. Now that we are also using the `deploy module` command in Code Manager, it needs to respect these special cachedirs the same way. The `--cachedir` flag can now be used with the `deploy module` command. --- lib/r10k/action/deploy/module.rb | 6 +++++- spec/unit/action/deploy/module_spec.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/r10k/action/deploy/module.rb b/lib/r10k/action/deploy/module.rb index ff2b8a4d4..6e3415351 100644 --- a/lib/r10k/action/deploy/module.rb +++ b/lib/r10k/action/deploy/module.rb @@ -72,7 +72,11 @@ def visit_module(mod) end def allowed_initialize_opts - super.merge(environment: true, 'no-force': :self, 'generate-types': :self, 'puppet-path': :self) + super.merge(environment: true, + cachedir: :self, + 'no-force': :self, + 'generate-types': :self, + 'puppet-path': :self) end end end diff --git a/spec/unit/action/deploy/module_spec.rb b/spec/unit/action/deploy/module_spec.rb index daa719828..82e1115b2 100644 --- a/spec/unit/action/deploy/module_spec.rb +++ b/spec/unit/action/deploy/module_spec.rb @@ -25,6 +25,10 @@ it 'can accept a puppet-path option' do described_class.new({ 'puppet-path': '/nonexistent' }, []) end + + it 'can accept a cachedir option' do + described_class.new({ cachedir: '/nonexistent' }, []) + end end describe "with no-force" do @@ -123,4 +127,13 @@ expect(subject.instance_variable_get(:@puppet_path)).to eq('/nonexistent') end end + + describe 'with cachedir' do + + subject { described_class.new({ config: '/some/nonexistent/path', cachedir: '/nonexistent' }, []) } + + it 'sets puppet_path' do + expect(subject.instance_variable_get(:@cachedir)).to eq('/nonexistent') + end + end end