Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/discourse/manifests/admin.pp

Issue 9453112: Update puppet-postgresql and remove unless (Closed)
Patch Set: Created Feb. 28, 2013, 5:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .hgsub ('k') | modules/discourse/manifests/postactiontype.pp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 define discourse::admin( 1 define discourse::admin(
2 $email = $title, 2 $email = $title,
3 $ensure = 'present' 3 $ensure = 'present'
4 ) { 4 ) {
5 # Attempt some escaping 5 # Attempt some escaping
6 $escaped_email = regsubst($email, '[\'\\]', '\\\1', 'G') 6 $escaped_email = regsubst($email, '[\'\\]', '\\\1', 'G')
7 7
8 case $ensure { 8 case $ensure {
9 default: { 9 default: {
10 err("unknown ensure value ${ensure}") 10 err("unknown ensure value ${ensure}")
11 } 11 }
12 present: { 12 present: {
13 # Only confirmed accounts should be made admins 13 # Only confirmed accounts should be made admins
14 postgresql_psql {"UPDATE users SET admin = true WHERE email = '$escaped_em ail' AND EXISTS (SELECT * FROM email_tokens WHERE email_tokens.user_id = users.i d AND email_tokens.email = users.email AND email_tokens.confirmed)": 14 postgresql_psql {"UPDATE users SET admin = true WHERE email = '$escaped_em ail' AND EXISTS (SELECT * FROM email_tokens WHERE email_tokens.user_id = users.i d AND email_tokens.email = users.email AND email_tokens.confirmed)":
15 db => 'discourse', 15 db => 'discourse',
16 psql_user => 'discourse', 16 psql_user => 'discourse'
17 unless => 'SELECT false'
18 } 17 }
19 } 18 }
20 absent: { 19 absent: {
21 postgresql_psql {"UPDATE users SET admin = false WHERE email = '$escaped_e mail'": 20 postgresql_psql {"UPDATE users SET admin = false WHERE email = '$escaped_e mail'":
22 db => 'discourse', 21 db => 'discourse',
23 psql_user => 'discourse', 22 psql_user => 'discourse'
24 unless => 'SELECT false'
25 } 23 }
26 } 24 }
27 } 25 }
28 } 26 }
OLDNEW
« no previous file with comments | « .hgsub ('k') | modules/discourse/manifests/postactiontype.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld