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

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

Issue 6221863587938304: Issue 212 - Update Discourse (Closed)
Patch Set: Removed post action types Created March 27, 2014, 11:09 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
OLDNEW
1 define discourse::sitesetting( 1 define discourse::sitesetting(
2 $setting = $title, 2 $setting = $title,
3 $value = undef, 3 $value = undef,
4 $type = 1, 4 $type = 1,
5 $ensure = 'present' 5 $ensure = 'present'
6 ) { 6 ) {
7 # Attempt some escaping 7 # Attempt some escaping
8 $escaped_value = regsubst($value, '[\'\\]', '\\\1', 'G') 8 $escaped_value = regsubst($value, '[\'\\]', '\\\1', 'G')
9 $escaped_setting = regsubst($setting, '[\'\\]', '\\\1', 'G') 9 $escaped_setting = regsubst($setting, '[\'\\]', '\\\1', 'G')
10 $escaped_type = regsubst($type, '\D', '', 'G') 10 $escaped_type = regsubst($type, '\D', '', 'G')
11 11
12 case $ensure { 12 case $ensure {
13 default: { 13 default: {
14 err("unknown ensure value ${ensure}") 14 err("unknown ensure value ${ensure}")
15 } 15 }
16 present: { 16 present: {
17 # This is apparently how you do a conditional INSERT in PostgreSQL - sorry 17 # This is apparently how you do a conditional INSERT in PostgreSQL - sorry
18 $update_sql = "UPDATE site_settings SET value = '$escaped_value', data_typ e = $escaped_type WHERE name = '$escaped_setting' RETURNING 1" 18 $update_sql = "UPDATE site_settings SET value = '$escaped_value', data_typ e = $escaped_type WHERE name = '$escaped_setting' RETURNING 1"
19 $columns = "name, data_type, value, created_at, updated_at" 19 $columns = "name, data_type, value, created_at, updated_at"
20 $values = "SELECT '$escaped_setting', $escaped_type, '$escaped_value', CUR RENT_TIMESTAMP, CURRENT_TIMESTAMP" 20 $values = "SELECT '$escaped_setting', $escaped_type, '$escaped_value', CUR RENT_TIMESTAMP, CURRENT_TIMESTAMP"
21 21
22 postgresql_psql {"WITH upd AS ($update_sql) INSERT INTO site_settings ($co lumns) $values WHERE NOT EXISTS (SELECT * FROM upd)": 22 postgresql_psql {"WITH upd AS ($update_sql) INSERT INTO site_settings ($co lumns) $values WHERE NOT EXISTS (SELECT * FROM upd)":
23 db => 'discourse', 23 db => 'discourse',
24 psql_user => 'discourse' 24 psql_user => 'discourse',
25 notify => Service['discourse']
25 } 26 }
26 } 27 }
27 absent: { 28 absent: {
28 postgresql_psql {"DELETE FROM site_settings WHERE name = '$escaped_setting '": 29 postgresql_psql {"DELETE FROM site_settings WHERE name = '$escaped_setting '":
29 db => 'discourse', 30 db => 'discourse',
30 psql_user => 'discourse' 31 psql_user => 'discourse',
32 notify => Service['discourse']
31 } 33 }
32 } 34 }
33 } 35 }
34 } 36 }
OLDNEW
« no previous file with comments | « modules/discourse/manifests/postactiontype.pp ('k') | modules/discourse/templates/database.yml.erb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld