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

Unified Diff: modules/discourse/manifests/postactiontype.pp

Issue 6221863587938304: Issue 212 - Update Discourse (Closed)
Patch Set: Disabled mini profiler Created March 28, 2014, 11:51 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « modules/discourse/manifests/init.pp ('k') | modules/discourse/manifests/sitesetting.pp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/discourse/manifests/postactiontype.pp
===================================================================
deleted file mode 100644
--- a/modules/discourse/manifests/postactiontype.pp
+++ /dev/null
@@ -1,49 +0,0 @@
-define discourse::postactiontype(
- $id,
- $key = $title,
- $is_flag = false,
- $icon = undef,
- $position = 0,
- $ensure = 'present'
-) {
- # Attempt some escaping
- $escaped_id = regsubst($id, '\D', '', 'G')
- $escaped_key = regsubst($key, '[\'\\]', '\\\1', 'G')
- if $is_flag {
- $escaped_flag = 'true'
- }
- else {
- $escaped_flag = 'false'
- }
- if $icon {
- $dummy = regsubst($icon, '[\'\\]', '\\\1', 'G')
- $escaped_icon = "'${dummy}'"
- }
- else {
- $escaped_icon = "null"
- }
- $escaped_position = regsubst($position, '\D', '', 'G')
-
- case $ensure {
- default: {
- err("unknown ensure value ${ensure}")
- }
- present: {
- # This is apparently how you do a conditional INSERT in PostgreSQL - sorry
- $update_sql = "UPDATE post_action_types SET name_key = '$escaped_key', is_flag = $escaped_flag, icon = $escaped_icon, position = $escaped_position WHERE id = $escaped_id RETURNING 1"
- $columns = "id, name_key, is_flag, icon, position, created_at, updated_at"
- $values = "SELECT $escaped_id, '$escaped_key', $escaped_flag, $escaped_icon, $escaped_position, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP"
-
- postgresql_psql {"WITH upd AS ($update_sql) INSERT INTO post_action_types ($columns) $values WHERE NOT EXISTS (SELECT * FROM upd)":
- db => 'discourse',
- psql_user => 'discourse'
- }
- }
- absent: {
- postgresql_psql {"DELETE FROM post_action_types WHERE id = $escaped_id":
- db => 'discourse',
- psql_user => 'discourse'
- }
- }
- }
-}
« no previous file with comments | « modules/discourse/manifests/init.pp ('k') | modules/discourse/manifests/sitesetting.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld