-
Notifications
You must be signed in to change notification settings - Fork 583
(MODULES-3529) add deprecation function #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3523142
to
ff30448
Compare
ff30448
to
294d7f8
Compare
@@ -289,6 +289,10 @@ Deletes all instances of a given value from a hash. For example, `delete_values( | |||
|
|||
Deletes all instances of the undef value from an array or hash. For example, `$hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})` returns {a => 'A', b => '', d => false}. *Type*: rvalue. | |||
|
|||
#### `deprecation` | |||
|
|||
Function to print deprecation warnings, it will display a provided message as well as the caller. The deprecation message will only be displayed once per caller. It is affected by the puppet setting 'strict', which can be set to :error, :off and :warning (default) *Type*: String. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't tell reader how strict
affects the function.
294d7f8
to
a73e6ff
Compare
module Stdlib | ||
class DeprecationState | ||
# This is so we display one message per caller | ||
@@deprecation_warning_said = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not good - no @@vars please - they hold on to the data forever.
There is yet another possibility - there is a migration support class that can be used to report issues during runtime in a more structured way. That API is then used by the catalog preview tool to collect and present issues. That makes it a lot easier to do migration of old code. In 3.8, that API has a fairly rich set of methods. They are mostly removed in 4.x. It is possible to introduce new methods akin to the 3.8.x -> 4.x migration checks. The result of using the migration checking issues makes it possible to offer a better user experience than just "stuff logged with messages". |
@hlindberg @DavidS I think that your last recommendation about using catalog_preview may be outside of our requirements. I have a question: if Puppet.settings[:strict] = :error, what logging / error method would you recommend i use. http://www.rubydoc.info/gems/puppet/4.4.1/Puppet/Util/Logging |
a73e6ff
to
290aa49
Compare
@hlindberg @DavidS i have made the suggested changes, what do you think of the README, i pulled in your comments @hlindberg . |
there is an :err (or is it :error - I mix them up all the time) log level. This level does not cause puppet to fail. The spirit of {{--strict=error}} is that you want the evaluation to actually stop as you would use that level to be pedantic and enforce that all deprecations have been dealt with. I suggest failing in that case rather than just logging an error. |
#### `deprecation` | ||
|
||
Function to print deprecation warnings, Logs a (non deprecation) warning once for a given key. A key, that can be used to denote this particular type of deprecation (for instance also adding it to disabled_warnings). The second is the uniqueness key - in the example, the deprecation can appear once per module name. The msg is the message text including any positional information that is formatted by the user/caller of the method It is affected by the puppet setting 'strict', which can be set to :error (outputs as an error message), :off (no message / error is displayed) and :warning (default, outputs a warning) *Type*: String, String, String. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding to disabled_warnings requires an update to puppet as it lists all keys that can be disabled - so that part will not work without a change to that setting in puppet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is very unfortunate, as we hoped to expose this functionality to the user. Specifically, allowing them(us) to specify finegrained deprecations, at least at the module level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually what I said is misleading, the first parameter kind
to warn once, is the key to disabled_warnings
. So, kind
can be set to 'deprecation'
which means it can be disabled. Here is an example from puppet source: Puppet.warn_once('deprecation', 'symbol_comparison', 'Comparing Symbols to non-Symbol values is deprecated')
. If a new kind is wanted and that it is also wanted to be able to disable that kind then puppet must be updated. (It would not be unreasonable to support any kind in the disable_warnings (with the only downside that typos will not be caught)).
290aa49
to
80a7374
Compare
Given the vague descriptions of the core infrastructure we're using here, a few integration tests exercising the whole stack would be great. Also, please put the ticket number in the Commit and PR title for automatic linking to JIRA. |
80a7374
to
d222e4c
Compare
@hlindberg @DavidS changes made. |
d222e4c
to
737b39f
Compare
@DavidS i didnt know you were pointing that comment at me. What you mean by full stack testing ? |
I was thinking about something like this: https://github.com/tphoney/puppetlabs-stdlib/compare/add_deprecate_function...DavidS:MODULES-3529-acceptance-tests?expand=1 |
737b39f
to
6cdd86c
Compare
@DavidS i changed the check for puppet4 in the acceptance test to
|
@tphoney please apply shellquoting and then fix the fialing tests:
|
6cdd86c
to
8d83b43
Compare
@DavidS boom ! |
retriggered jenkins to pickup the new beaker version |
8d83b43
to
72d2365
Compare
@DavidS tests are now passing |
Wohoo!! 🎉 |
No description provided.