Closed lusis closed 12 years ago
Forgot to include an example recipe:
class Portal < FPM::Cookery::Recipe
homepage 'http://mycompany.com'
source 'https://svn-server/portal/trunk?15716' # query string here is optional. HEAD is used if missing
handler :svn
name 'portal'
def build
safesystem('mvn', 'clean', 'package', '-U', '-DskipTests', '-Pprod')
end
def install
end
end
What about instead of a handler, you just implement it like:
source "http://...." # assumes 'handler' is the url scheme.
source :http, :location => "http://...." same as above
source :svn, :location => "https://...", :revision => 15716
source :git, :location => "git@somehost.com:foo/foo.git", :hash => "some silly hash"
Or something.
That way you could implement your own 'source' plugins and you wouldn't need to introduce any extra top level methods (like handler, etc) for configuring them. Bonus that you don't need now to use strange URL query strings to indicate parameters to pass to your source handler.
Thoughts? Could be better ways to improve this, too.
yeah that would work. I was trying to keep the complexity in dsl to strings only but that approach works. @bernd let me know what you think and I'll hack it on in.
Strings-only is a decent goal, but shoving everything in a URL isn't delicious either, hmm.. Now I am conflicted.
Oups, reopen.
The source keyword already takes an optional hash. (:as) And for git/svn it makes sense to have :tag/:branch/:sha/:rev. (like Homebrew does) So I like Jordan's proposal.
Got it. I'll go down that route then.
Addition: I think we can use simple strings most of the time. "git://", "svn+http://", "hg://" are unambiguous and we don't need to explicitly select a source handler.
source "git://github.com/bernd/fpm-cookery.git" # => git
source :git, "https://github.com/bernd/fpm-cookery" # => git
So one thing I do in the noah-agent, is have plugins set an attribute/constant that they register under:
e.g. https://github.com/lusis/noah-agent/blob/master/lib/noah-agent/handler/http.rb#L4 https://github.com/lusis/noah-agent/blob/master/lib/noah-agent/handler/dummy.rb#L4
So it's totally doable and easy enough to match on.
Nice, I like that!
Closing this. See Issue #7 for proper pull request.
I've got an MVP of an SVN handler here:
https://github.com/lusis/fpm-cookery/commit/28a8a54ac99c925fe32454698cbd77273bc4ed6f
https
, I decided to add a new attr to the block called:handler
. It defaults to:curl
.FPM::Cookery::SourceHandler::Template
should probably have some sort of inheritance hook and drop the whole conditional aspect.Template
to toggle the checksum process. I'm currently overriding it inSVN
in the fetch method. This would PROBABLY work better as a constant?I've tested it here with/without a revision query string and it works well. I've also validated that Curl-based fetches still work and checksum properly.
Before I go on and do a Git handler, I want to run this implementation up the flag pole and get opinions. It's not very testable in its current form so I'll have to refactor that as well. I think I also have some
puts
statements in there that I need to clean up.Thoughts?