From b4e1b675b2d4f33abf21d6f923c42cf4cb013931 Mon Sep 17 00:00:00 2001 From: Daniel Carabas Date: Mon, 9 Mar 2020 11:51:35 +0200 Subject: [PATCH 1/2] Remove strftime from stdlib --- lib/puppet/parser/functions/strftime.rb | 107 ------------------------ spec/functions/strftime_spec.rb | 26 ------ 2 files changed, 133 deletions(-) delete mode 100644 lib/puppet/parser/functions/strftime.rb delete mode 100644 spec/functions/strftime_spec.rb diff --git a/lib/puppet/parser/functions/strftime.rb b/lib/puppet/parser/functions/strftime.rb deleted file mode 100644 index 50ee4bc33..000000000 --- a/lib/puppet/parser/functions/strftime.rb +++ /dev/null @@ -1,107 +0,0 @@ -# -# strftime.rb -# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. -# -module Puppet::Parser::Functions - newfunction(:strftime, :type => :rvalue, :doc => <<-DOC - @summary - This function returns formatted time. - - @return - converted time according to the directives in the given format string - - > *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this - function. It also supports the Timestamp and Timespan data types in the Puppet language. - - @example **Usage** - - To return the time since epoch: strftime("%s") - To return the date: strftime("%Y-%m-%d") - - **Format meaning:** - - %a - The abbreviated weekday name (``Sun'') - %A - The full weekday name (``Sunday'') - %b - The abbreviated month name (``Jan'') - %B - The full month name (``January'') - %c - The preferred local date and time representation - %C - Century (20 in 2009) - %d - Day of the month (01..31) - %D - Date (%m/%d/%y) - %e - Day of the month, blank-padded ( 1..31) - %F - Equivalent to %Y-%m-%d (the ISO 8601 date format) - %h - Equivalent to %b - %H - Hour of the day, 24-hour clock (00..23) - %I - Hour of the day, 12-hour clock (01..12) - %j - Day of the year (001..366) - %k - hour, 24-hour clock, blank-padded ( 0..23) - %l - hour, 12-hour clock, blank-padded ( 0..12) - %L - Millisecond of the second (000..999) - %m - Month of the year (01..12) - %M - Minute of the hour (00..59) - %n - Newline (\n) - %N - Fractional seconds digits, default is 9 digits (nanosecond) - %3N millisecond (3 digits) - %6N microsecond (6 digits) - %9N nanosecond (9 digits) - %p - Meridian indicator (``AM'' or ``PM'') - %P - Meridian indicator (``am'' or ``pm'') - %r - time, 12-hour (same as %I:%M:%S %p) - %R - time, 24-hour (%H:%M) - %s - Number of seconds since 1970-01-01 00:00:00 UTC. - %S - Second of the minute (00..60) - %t - Tab character (\t) - %T - time, 24-hour (%H:%M:%S) - %u - Day of the week as a decimal, Monday being 1. (1..7) - %U - Week number of the current year, - starting with the first Sunday as the first - day of the first week (00..53) - %v - VMS date (%e-%b-%Y) - %V - Week number of year according to ISO 8601 (01..53) - %W - Week number of the current year, - starting with the first Monday as the first - day of the first week (00..53) - %w - Day of the week (Sunday is 0, 0..6) - %x - Preferred representation for the date alone, no time - %X - Preferred representation for the time alone, no date - %y - Year without a century (00..99) - %Y - Year with century - %z - Time zone as hour offset from UTC (e.g. +0900) - %Z - Time zone name - %% - Literal ``%'' character - DOC - ) do |arguments| - - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "strftime(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? - - format = arguments[0] - - raise(Puppet::ParseError, 'strftime(): You must provide format for evaluation') if format.empty? - - # The Time Zone argument is optional ... - time_zone = arguments[1] if arguments[1] - - time = Time.new - - # There is probably a better way to handle Time Zone ... - if time_zone && !time_zone.empty? - original_zone = ENV['TZ'] - - local_time = time.clone - local_time = local_time.utc - - ENV['TZ'] = time_zone - - time = local_time.localtime - - ENV['TZ'] = original_zone - end - - result = time.strftime(format) - - return result - end -end - -# vim: set ts=2 sw=2 et : diff --git a/spec/functions/strftime_spec.rb b/spec/functions/strftime_spec.rb deleted file mode 100644 index 92a6893ba..000000000 --- a/spec/functions/strftime_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'strftime' do - it 'exists' do - expect(Puppet::Parser::Functions.function('strftime')).to eq('function_strftime') - end - - it 'raises a ParseError if there is less than 1 arguments' do - expect { scope.function_strftime([]) }.to(raise_error(Puppet::ParseError)) - end - - it 'using %s should be higher then when I wrote this test' do - result = scope.function_strftime(['%s']) - expect(result.to_i).to(be > 1_311_953_157) - end - - it 'using %s should be greater than 1.5 trillion' do - result = scope.function_strftime(['%s']) - expect(result.to_i).to(be > 1_500_000_000) - end - - it 'returns a date when given %Y-%m-%d' do - result = scope.function_strftime(['%Y-%m-%d']) - expect(result).to match(%r{^\d{4}-\d{2}-\d{2}$}) - end -end From c1f8dd769778893b8849bb3599fbc47bd4036c3d Mon Sep 17 00:00:00 2001 From: Daniel Carabas Date: Mon, 9 Mar 2020 15:53:49 +0200 Subject: [PATCH 2/2] Update acceptance test images to litmusimage --- provision.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/provision.yaml b/provision.yaml index b0ba908ff..c9d0b7e3c 100644 --- a/provision.yaml +++ b/provision.yaml @@ -1,22 +1,22 @@ --- default: provisioner: docker - images: ['waffleimage/centos7'] + images: ['litmusimage/centos:7'] vagrant: provisioner: vagrant images: ['centos/7', 'generic/ubuntu1804', 'gusztavvargadr/windows-server'] travis_deb: provisioner: docker - images: ['waffleimage/debian8', 'waffleimage/debian9', 'waffleimage/debian10'] + images: ['litmusimage/debian:8', 'litmusimage/debian:9', 'litmusimage/debian:10'] travis_ub: provisioner: docker - images: ['waffleimage/ubuntu14.04', 'waffleimage/ubuntu16.04', 'waffleimage/ubuntu18.04'] + images: ['litmusimage/ubuntu:14.04', 'litmusimage/ubuntu:16.04', 'litmusimage/ubuntu:18.04'] travis_el6: provisioner: docker - images: ['waffleimage/centos6', 'waffleimage/scientificlinux6'] + images: ['litmusimage/centos:6', 'litmusimage/scientificlinux:6'] travis_el7: provisioner: docker - images: ['waffleimage/centos7', 'waffleimage/oraclelinux7', 'waffleimage/scientificlinux7'] + images: ['litmusimage/centos:7', 'litmusimage/oraclelinux:7', 'litmusimage/scientificlinux:7'] release_checks: provisioner: vmpooler images: ['redhat-5-x86_64', 'redhat-6-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'centos-5-x86_64', 'centos-6-x86_64', 'centos-7-x86_64', 'centos-8-x86_64', 'oracle-5-x86_64', 'oracle-6-x86_64', 'oracle-7-x86_64', 'scientific-6-x86_64', 'scientific-7-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'sles-11-x86_64', 'sles-12-x86_64', 'ubuntu-1404-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64', 'win-2008-x86_64', 'win-2008r2-x86_64', 'win-2012-x86_64', 'win-2012r2-x86_64', 'win-2016-x86_64', 'win-2019-x86_64', 'win-7-x86_64', 'win-81-x86_64', 'win-10-pro-x86_64']