Skip to content

Commit 7468db0

Browse files
authored
Merge pull request #1429 from puppetlabs/CONT-904-Fix_onlyif_exists
(CONT-904) - Removal of tech debt
2 parents 87fab00 + 224a8c4 commit 7468db0

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

manifests/server/grant.pp

+5-2
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@
432432
default: {
433433
$_granted_object = $_object_name
434434
$_togrant_object = $_object_name
435+
# if $_togrant_object_only not set, set it to a default value $_togrant_object
436+
# allows an Array or String to be passed as $_object_name i.e. [$schema, $table] or $table
437+
$_togrant_object_only = $_togrant_object
435438
}
436439
}
437440

@@ -449,9 +452,9 @@
449452

450453
$_onlyif = $onlyif_function ? {
451454
'table_exists' => "SELECT true FROM pg_tables WHERE tablename = '${_togrant_object_only}'",
452-
'language_exists' => "SELECT true from pg_language WHERE lanname = '${_togrant_object_only}}'",
455+
'language_exists' => "SELECT true from pg_language WHERE lanname = '${_togrant_object_only}'",
453456
'role_exists' => "SELECT 1 FROM pg_roles WHERE rolname = '${role}' or '${role}' = 'PUBLIC'",
454-
'function_exists' => "SELECT true FROM pg_proc WHERE (oid::regprocedure)::text = '${_togrant_object_only}}${arguments}'",
457+
'function_exists' => "SELECT true FROM pg_proc WHERE (oid::regprocedure)::text = '${_togrant_object_only}${arguments}'",
455458
default => undef,
456459
}
457460

spec/spec_helper_acceptance_local.rb

-8
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,9 @@ def unindent
1616
RSpec.configure do |c|
1717
c.before :suite do
1818
install_dependencies
19-
turn_off_strict_error
2019
end
2120
end
2221

23-
def turn_off_strict_error
24-
# this is only temporary fix until we finish adding support for puppet 8
25-
# strict=warning is defaulted on puppet versions below 8, whereas puppet 8 has strict=error by default
26-
# error is caused by 'onlyif_exists' in spec/acceptance/server/grant_spec.rb L78 (works when removed, but not what we want to test)
27-
LitmusHelper.instance.run_shell("echo 'strict=warning\nstrict_variables=false' >> /etc/puppetlabs/puppet/puppet.conf")
28-
end
29-
3022
def export_locales(locale)
3123
LitmusHelper.instance.run_shell('echo export PATH="/opt/puppetlabs/bin:$PATH" > ~/.bashrc')
3224
LitmusHelper.instance.run_shell('echo export LC_ALL="C" > /etc/profile.d/my-custom.lang.sh')

0 commit comments

Comments
 (0)