Skip to content

Commit

Permalink
Autorequire provider in smartproxy type
Browse files Browse the repository at this point in the history
With this it's sufficient to include foreman::providers where prior to
this the caller was responsible for ensuring the correct dependency.
  • Loading branch information
ekohl committed Jul 2, 2021
1 parent e16eaa3 commit caec823
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/puppet/type/foreman_smartproxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def is_to_s(value)
defaultto 500
end

autorequire(:anchor) do
['foreman::providers::oauth']
end

def refresh
if @parameters[:ensure].retrieve == :present
provider.refresh_features! if provider.respond_to?(:refresh_features!)
Expand Down
3 changes: 2 additions & 1 deletion manifests/providers.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
) inherits foreman::providers::params {
if $oauth {
ensure_packages([$oauth_package])
Anchor <| title == 'foreman::repo' |> -> Package[$oauth_package]
anchor { 'foreman::providers::oauth': }
Anchor <| title == 'foreman::repo' |> -> Package[$oauth_package] -> Anchor['foreman::providers::oauth']
}
}
10 changes: 9 additions & 1 deletion spec/classes/foreman_providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

context 'with defaults' do
it { should compile.with_all_deps }
it { should contain_package(oauth_os) }
it { should contain_package(oauth_os).that_comes_before('Anchor[foreman::providers::oauth]') }
it { should contain_anchor('foreman::providers::oauth]') }
end

context 'with oauth => false' do
Expand All @@ -34,6 +35,13 @@
it { is_expected.to compile.with_all_deps }
it { should contain_package(oauth_os).that_comes_before('Class[foreman]') }
end

context 'with foreman_smartproxy' do
let(:pre_condition) { "foreman_smartproxy { 'myproxy.example.com': }" }

it { is_expected.to compile.with_all_deps }
it { should contain_package(oauth_os).that_comes_before('Foreman_smartproxy[myproxy.example.com]') }
end
end
end
end

0 comments on commit caec823

Please sign in to comment.