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

Add title consistency checks for multi-namevar providers #240

Merged
merged 3 commits into from
Dec 5, 2019

Conversation

seanmil
Copy link
Contributor

@seanmil seanmil commented Oct 27, 2019

This ensures that title values, if returned from a multi-namevar
provider, meet the following consistency checks:

  • The title value must match one of the title patterns
  • The values parsed from the title pattern match must match the
    values returned from the provider for the respective namevars.

@seanmil seanmil requested a review from a team October 27, 2019 18:35
@seanmil
Copy link
Contributor Author

seanmil commented Oct 27, 2019

I took a stab at resolving #219. It doesn't verify titles returned from types with a single namevar, but perhaps it should make sure those match as well?

It also doesn't verify that composite namevar types return a title. That requirement is stated in the documentation, but the code seems to gracefully accommodate the lack of a title.

Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sean, thanks for working on this, and apologies for the delay in reviewing. I've been travelling last week and suffered from the conference lurgy afterwards 🤧 😞

The core of this change is 👍 , two minor change requests below.

lib/puppet/resource_api.rb Outdated Show resolved Hide resolved
@@ -5,6 +5,16 @@
docs: <<-EOS,
This type provides Puppet with the capabilities to manage ...
EOS
title_patterns: [
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a title_patterns test type instead of changing this one, to preserve multiple-namevars-no-title_patterns testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes in this file are no longer necessary after improving the title verification logic and I have removed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I take back that last comment. I think I need to add a title_patterns definition because that acceptance test deals with multiple namevars and has strict enabled, which means this patch has it trigger errors. Is your expectation that a type with multiple namevars and no title_patterns should emit no warnings or errors?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my expectation is that a type with multiple namevars and no title_patterns should emit no warnings or errors. Resources with multiple namevars can be specified by passing in values as properties rather than through the title. While a valid design choice in some rare edge-cases, I'm not overly fond of it. Let's keep this acceptance test as it is, but please add a unit test (and associated code) to make sure that title_patterns are not required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the relaxation of the check in a separate commit. If you're fine with it, we can get this merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, looks great! Thanks for doing that. It would have been at least a few days before I could have gotten to it.

lib/puppet/resource_api.rb Outdated Show resolved Hide resolved
@seanmil seanmil force-pushed the issue_219-title_consistency_check branch 3 times, most recently from ff4d14d to 4b078be Compare November 9, 2019 01:52
Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified my stance on namevar/title_pattern interaction.

Other than that issue, this looks good to me.

@@ -5,6 +5,16 @@
docs: <<-EOS,
This type provides Puppet with the capabilities to manage ...
EOS
title_patterns: [
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my expectation is that a type with multiple namevars and no title_patterns should emit no warnings or errors. Resources with multiple namevars can be specified by passing in values as properties rather than through the title. While a valid design choice in some rare edge-cases, I'm not overly fond of it. Let's keep this acceptance test as it is, but please add a unit test (and associated code) to make sure that title_patterns are not required.

@@ -5,6 +5,16 @@
docs: <<-EOS,
This type provides Puppet with the capabilities to manage ...
EOS
title_patterns: [
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the relaxation of the check in a separate commit. If you're fine with it, we can get this merged.

seanmil and others added 3 commits December 5, 2019 14:23
This ensures results returned from a multi-namevar provider
meet the following consistency checks:

* There must be a title attribute returned
* The title value must match one of the title patterns
* The values parsed from the title pattern match must match the
  values returned from the provider for the respective namevars.
Resources with multiple namevars can be specified by passing in values as
properties rather than through the title. A valid design choice in some
rare edge-cases. This commit allows it through the title-validation.
@DavidS DavidS force-pushed the issue_219-title_consistency_check branch from a3ca856 to 7f8e987 Compare December 5, 2019 14:23
@DavidS
Copy link
Contributor

DavidS commented Dec 5, 2019

Rebased on top of master. Will merge after CI confirms git didn't mess up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants