-
Notifications
You must be signed in to change notification settings - Fork 42
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
(PDK-988) restrain mungify from non-puppet resource
workflows
#80
Conversation
It turns out that a new type instance with a Hash as argument is only used by the RAL's `find` method, if there is no matching instance returned from `instances`. While this is the method used by the `puppet resource` CLI, it is not indicative of being called from it (when the instance exists, this code path is not hit). This commit changes the name of the variable to better represent what it actually signifies.
6173f6e
to
61ce774
Compare
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.
A minor spelling mistake in commit message of 61ce774:
Such an implementation could provider more specific...
lib/puppet/resource_api.rb
Outdated
@@ -517,13 +517,30 @@ def self.try_mungify(type, value, error_msg_prefix) | |||
# fall through to default handling | |||
end | |||
|
|||
# a match! | |||
return [value, nil] if type.instance?(value) | |||
is_valid, error_msg = try_validate(type, value, error_msg_prefix) |
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.
Possibly, have try_validate return value, error_msg? If it fails, return nil, error_msg.
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.
Doing it like this would obscure the fact that try_validate
doesn't change the value. But I'll change it to only return error_msg
or nil
, which is enough information, and lines up better with try_mungify
.
lib/puppet/resource_api.rb
Outdated
def self.validate(type, value, error_msg_prefix) | ||
is_valid, error_msg = try_validate(type, value, error_msg_prefix) | ||
|
||
raise Puppet::ResourceError, error_msg unless is_valid |
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.
if previous suggestion is followed unless is_valid
would change here.
The mungify introduced in puppetlabs#59 would also affect strings passed in as parameters through manifests (e.g. using `puppet apply` or the agent), masking input type errors. This change fixes the behaviour so that munging is only happening when the runtime environment is actually puppet resource. Of course, long-term it would be better to have the CLI itself mungify inputs from the CLI. Such an implementation could provide more specific error messages, and reduce code complexity here. For now, this solution works across all puppet versions, and provides the same functionality. versions.
61ce774
to
b6faf26
Compare
No description provided.