From 408dec4a8a57d53314d3627fe802aeb77b907d4b Mon Sep 17 00:00:00 2001 From: Mihmet Akpinar Date: Fri, 21 Jun 2024 12:54:04 +0200 Subject: [PATCH] use confine instead of if statement --- lib/facter/vault_version.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/facter/vault_version.rb b/lib/facter/vault_version.rb index d1ac06d..8826e38 100644 --- a/lib/facter/vault_version.rb +++ b/lib/facter/vault_version.rb @@ -5,11 +5,10 @@ # Purpose: Retrieve vault version if installed # Facter.add(:vault_version) do + confine {Facter::Util::Resolution.which('vault')} setcode do - if Facter::Util::Resolution.which('vault') - vault_server_version_output = Facter::Util::Resolution.exec('vault version') - match = vault_server_version_output.match(%r{Vault v(\d+\.\d+\.\d+)}) - match&.captures&.first - end + vault_server_version_output = Facter::Util::Resolution.exec('vault version') + match = vault_server_version_output.match(%r{Vault v(\d+\.\d+\.\d+)}) + match&.captures&.first end end