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 support for prepared query templates #296

Merged
merged 2 commits into from
Dec 2, 2016

Conversation

adamcstephens
Copy link
Contributor

Expanding on #288 and the good work by @djtaylor, add support for prepared query templates to the custom type.

@@ -179,7 +181,12 @@ def flush
},
"DNS" => {
"TTL" => "#{ttl}s"
}})
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this should be part of this json should be included no matter what?

What about users of consul before 6.4? What if they don't want to make a template?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my testing consul creates the Template hash regardless when a query is created, so sending an empty hash shouldn't affect anything as its not actually a template until Type/Regexp are defined.

That said it will probably fail on < 0.6.4 since it doesn't have templating. I can add some logic into this if you prefer to maintain support for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please.


newparam(:template_regexp) do
desc 'regexp for template'
validate do |value|
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have to have to make this a required argument?

Can you default to nil so that users don't have to provide this all the time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, for sure. I'm somewhat new to ruby types so I'll read the docs a bit more and tweak this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Simply defaulting to "nil" or whatever and then not injecting template data will make this "automatically" backwards compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting a default value to nil causes a failure to compile. Set them to some sane string defaults.

@adamcstephens
Copy link
Contributor Author

I've updated this to add a template parameter, which allows 0.6.3 to work still since its defaulted to false.

@adamcstephens
Copy link
Contributor Author

Any more feedback on this?

@solarkennedy solarkennedy merged commit 154211a into voxpupuli:master Dec 2, 2016
@solarkennedy
Copy link
Contributor

Nope! ty.

spuder pushed a commit to spuder/puppet-consul that referenced this pull request Feb 25, 2020
add support for prepared query templates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants