Skip to content
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

Merged
merged 4 commits into from
May 23, 2018

Conversation

DavidS
Copy link
Contributor

@DavidS DavidS commented May 22, 2018

No description provided.

@DavidS DavidS added the bug label May 22, 2018
@DavidS DavidS requested a review from da-ar May 22, 2018 12:58
DavidS added 2 commits May 22, 2018 14:09
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.
@DavidS DavidS force-pushed the pdk-988-restrain-mungify branch 2 times, most recently from 6173f6e to 61ce774 Compare May 22, 2018 13:37
Copy link

@da-ar da-ar left a 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...

@@ -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)
Copy link

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.

Copy link
Contributor Author

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.

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
Copy link

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.

DavidS added 2 commits May 22, 2018 16:19
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.
@DavidS DavidS force-pushed the pdk-988-restrain-mungify branch from 61ce774 to b6faf26 Compare May 22, 2018 15:20
@da-ar da-ar merged commit 4e34995 into puppetlabs:master May 23, 2018
@DavidS DavidS deleted the pdk-988-restrain-mungify branch May 24, 2018 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants