-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`time` was both an old API ruby function, and not needed since Puppet 4. In this commit, the `parser` function is removed and replaced by a non-namespaced APIv4 function. This is done to preserve compatibility before the function is removed completely in a later release. The ruby function calls a Puppet language function which implements the existing behaviour using core Puppet functionality. The original function did something weird with an optional `timezone` parameter. Nobody really remembers why. It appears that very early versions of Ruby may have been buggy and needed this as a workaround. To be clear, seconds since the epoch are the same _everywhere_. Timezone is not relevant.
- Loading branch information
1 parent
7e7ded4
commit fea0881
Showing
5 changed files
with
56 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# @summary This function is deprecated. It implements the functionality of the original non-namespaced stdlib `time` function. | ||
# | ||
# It is provided for compatability, but users should use the native time related functions directly. | ||
# | ||
# @param _timezone | ||
# This parameter doesn't do anything, but exists for compatability reasons | ||
function stdlib::time(Optional[String] $_timezone = undef) >> Integer { | ||
# Note the `timezone` parameter doesn't do anything and didn't in the ruby implementation for _years_ (pre 1.8.7 perhaps ???) | ||
deprecation('time', 'The stdlib `time` function is deprecated. Please direcly use native Puppet functionality instead. eg. `Integer(Timestamp().strftime(\'%s\'))`', false) | ||
Integer(Timestamp().strftime('%s')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
# @summary DEPRECATED. Use the native Puppet fuctionality instead of this function. eg `Integer(Timestamp().strftime('%s'))` | ||
Puppet::Functions.create_function(:time) do | ||
dispatch :call_puppet_function do | ||
repeated_param 'Any', :args | ||
end | ||
def call_puppet_function(*args) | ||
# Note, `stdlib::time` calls `deprecation`, so we don't also do that here. | ||
call_function('stdlib::time', *args) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters