diff options
| author | Micah Anderson <micah@leap.se> | 2015-06-11 12:10:09 -0400 | 
|---|---|---|
| committer | Micah Anderson <micah@leap.se> | 2015-06-11 12:10:09 -0400 | 
| commit | b429b30bda4dafc78cb02f6ece5d82f08e35de1f (patch) | |
| tree | 37efc30a4fcb642dec583c3accea76f7a7de9c39 /puppet/modules/site_couchdb/lib | |
| parent | 67b2bea2dfcfb06191bf5ed562309f264c6aed8c (diff) | |
| parent | d9146415db0e6b7dd0c945039c0a4ed4fd054a7d (diff) | |
Merge tag '0.7.0'
Releasing 0.7.0
Diffstat (limited to 'puppet/modules/site_couchdb/lib')
| -rw-r--r-- | puppet/modules/site_couchdb/lib/puppet/parser/functions/rotated_db_name.rb | 24 | 
1 files changed, 24 insertions, 0 deletions
| diff --git a/puppet/modules/site_couchdb/lib/puppet/parser/functions/rotated_db_name.rb b/puppet/modules/site_couchdb/lib/puppet/parser/functions/rotated_db_name.rb new file mode 100644 index 00000000..6458ae81 --- /dev/null +++ b/puppet/modules/site_couchdb/lib/puppet/parser/functions/rotated_db_name.rb @@ -0,0 +1,24 @@ +module Puppet::Parser::Functions +  newfunction(:rotated_db_name, :type => :rvalue, :doc => <<-EOS +This function takes a database name string and returns a database name with the current rotation stamp appended. +The first argument is the base name of the database. Subsequent arguments may contain these options: +  * 'next'    -- return the db name for the next rotation, not the current one. +  * 'monthly' -- rotate monthly (default) +  * 'weekly'  -- rotate weekly +*Examples:* +    rotated_db_name('tokens') => 'tokens_551' +    EOS +  ) do |arguments| +    if arguments.include?('weekly') +      rotation_period = 604800 # 1 week +    else +      rotation_period = 2592000 # 1 month +    end +    suffix = Time.now.utc.to_i / rotation_period +    if arguments.include?('next') +      suffix += 1 +    end +    "#{arguments.first}_#{suffix}" +  end +end + | 
