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 downloading puppet URL’s #270

Merged
merged 8 commits into from
Jun 28, 2017
Merged

Add support for downloading puppet URL’s #270

merged 8 commits into from
Jun 28, 2017

Conversation

hajee
Copy link
Contributor

@hajee hajee commented Mar 25, 2017

This PR allows archive to support puppet urls for the source parameter.

@bastelfreak
Copy link
Member

Hi @hajee, thanks for the great PR!

do you think you can also add some tests?

@@ -117,28 +117,16 @@ archive { '/tmp/test100k.db':

### Puppet URL

Below is an example of how to deploy a tar.gz to a local directory when it is
served via the ```puppet:///``` style url which is not currently supported.
Since march 2017, the Archive type also supports puppet url's. Here is an example
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing that ruby is the only provider that will support this feature? It's not the default provider on Linux. Does the example need a provider => ruby?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was expecting the default provider to be ruby, but I was wrong. I will update the readme

Copy link
Member

Choose a reason for hiding this comment

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

@hajee Actually, you might be ok. Ruby isn't the default provider, but it is still the parent provider for curl and wget providers which override the parent's download method. Could you double-check? For example, looks like things might still go wonky if a user tries to specify a checksum_url.

Copy link
Contributor

Choose a reason for hiding this comment

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

So not sure what happens if the puppet:/// url points to a directory v.s. a file. Maybe we should clarify it in documentation about expectations if it doesn't handle directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nanliu : If you mean a puppet url pointing to a directory when using puppet apply, it does handle that.

validate do |value|
unless value =~ URI.regexp(%w(http https ftp file s3)) || Puppet::Util.absolute_path?(value)
unless value =~ URI.regexp(%w(puppet http https ftp file s3)) || Puppet::Util.absolute_path?(value)
raise ArgumentError, "invalid source url: #{value}"
end
Copy link
Member

Choose a reason for hiding this comment

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

@hajee Perhaps you could declare a provider feature? Something like...

feature :puppet_urls, 'The ability to download from Puppet URLs' if value == 'puppet'

and then in the ruby provider

has_feature :puppet_urls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. Just wondering: is it possible to do a different validate for the provider too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need this for now since everything inherits from the ruby provider. feature :puppet_urls is only necessary if we start to differentiate features per provider.

Copy link
Contributor

Choose a reason for hiding this comment

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

Follow up with chat with @alexjfisher, it might be worthwhile to mention in README, puppet:/// source will use ruby provider regardless of provider setting for now. But not a blocker for merging.

Copy link
Contributor

@nanliu nanliu left a comment

Choose a reason for hiding this comment

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

Nice feature!

validate do |value|
unless value =~ URI.regexp(%w(http https ftp file s3)) || Puppet::Util.absolute_path?(value)
unless value =~ URI.regexp(%w(puppet http https ftp file s3)) || Puppet::Util.absolute_path?(value)
raise ArgumentError, "invalid source url: #{value}"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need this for now since everything inherits from the ruby provider. feature :puppet_urls is only necessary if we start to differentiate features per provider.

@@ -117,28 +117,16 @@ archive { '/tmp/test100k.db':

### Puppet URL

Below is an example of how to deploy a tar.gz to a local directory when it is
served via the ```puppet:///``` style url which is not currently supported.
Since march 2017, the Archive type also supports puppet url's. Here is an example
Copy link
Contributor

Choose a reason for hiding this comment

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

So not sure what happens if the puppet:/// url points to a directory v.s. a file. Maybe we should clarify it in documentation about expectations if it doesn't handle directory.

@nanliu
Copy link
Contributor

nanliu commented Mar 29, 2017

Last note, if we want to be smart about conditional downloads, we need to implement checksum retrieval as well via http://www.rubydoc.info/gems/puppet/Puppet/FileServing/Metadata checksum and checksum_type. There isn't a clean way to do this because I'm not aware of way to change default provider based on a parameter. If we could change default provider on the fly based on source url, it will make the implementation much cleaner, instead we need to settle with cramming everything into the ruby provider (instead of ruby/s3/puppet providers).

@hajee
Copy link
Contributor Author

hajee commented Apr 9, 2017

Hi guys. Thanks for all the feedback. What are the things that still need attention before this PR can be merged?

@alexjfisher
Copy link
Member

@hajee Just a note in the README explaining that the ruby provider will be used regardless of provider. I think we were then good to go.

@alexjfisher
Copy link
Member

@hajee Could you rebase?

@bastelfreak Are you happy to remove the 'needs-tests' label now?

@hajee
Copy link
Contributor Author

hajee commented Jun 16, 2017

@alexjfisher rebase executed

@hajee
Copy link
Contributor Author

hajee commented Jun 28, 2017

@alexjfisher @bastelfreak Is there an ATA on the merge. I'd hate to do a rebase again :-)

@bastelfreak
Copy link
Member

Thanks for the PR @hajee!

@bastelfreak bastelfreak merged commit 1abd212 into voxpupuli:master Jun 28, 2017
@hajee
Copy link
Contributor Author

hajee commented Jun 29, 2017

Thanks for all the reviews and suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants