Class: Stove::Artifactory
- Inherits:
-
Object
- Object
- Stove::Artifactory
- Includes:
- Mixin::Instanceable
- Defined in:
- lib/stove/artifactory.rb
Instance Method Summary collapse
-
#upload(cookbook, extended_metadata = false) ⇒ Object
Upload a cookbook to an Artifactory server.
Methods included from Mixin::Instanceable
Instance Method Details
#upload(cookbook, extended_metadata = false) ⇒ Object
Upload a cookbook to an Artifactory server.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stove/artifactory.rb', line 13 def upload(cookbook, = false) # Artifactory doesn't prevent uploading over an existing release in # some cases so let's check for that. Seriously never do this, go delete # and then re-upload if you have to. response = request(:get, "api/v1/cookbooks/#{cookbook.name}/versions/#{cookbook.version}") # Artifactory's version of the cookbook_version endpoint returns an # empty 200 on an unknown version. unless response.code == '404' || (response.code == '200' && response.body.to_s == '') raise Error::CookbookAlreadyExists.new(cookbook: cookbook) end # Run the upload. response = request(:post, "api/v1/cookbooks/#{cookbook.name}.tgz") do |req| req.body_stream = cookbook.tarball() req.content_length = req.body_stream.size req['Content-Type'] = 'application/x-binary' end response.error! unless response.code == '201' end |