Skip to content

Commit

Permalink
Merge pull request #644 from chef/release-check
Browse files Browse the repository at this point in the history
Check to see if release has already taken place
  • Loading branch information
Seth Thomas committed Aug 3, 2016
2 parents 51893b9 + f5d037d commit 11c5e3a
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions bin/bento
Expand Up @@ -644,14 +644,26 @@ class ReleaseRunner
private

def release_version(boxname, version)
banner("Releasing version #{version} of box #{boxname}")
req = request('put', "#{atlas_api}/box/#{atlas_org}/#{boxname}/version/#{version}/release", { 'access_token' => atlas_token }, { 'Content-Type' => 'application/json' })
if req.code == '200'
banner("Version #{version} of box #{boxname} has been successfully released")
case status(boxname, version)
when 'unreleased'
banner("Releasing version #{version} of box #{boxname}")
req = request('put', "#{atlas_api}/box/#{atlas_org}/#{boxname}/version/#{version}/release", { 'access_token' => atlas_token }, { 'Content-Type' => 'application/json' })
if req.code == '200'
banner("Version #{version} of box #{boxname} has been successfully released")
else
warn("Something went wrong #{req.code}")
end
when 'active'
banner("Version #{version} of box #{boxname} has already been released - nothing to do")
else
warn("Something went wrong #{req.code}")
warn("Unexpected status retrieved from Atlas")
end
end

def status(boxname, version)
req = request('get', "#{atlas_api}/box/#{atlas_org}/#{boxname}/version/#{version}", { 'access_token' => atlas_token }, { 'Content-Type' => 'application/json' })
status = JSON.parse(req.body)['status']
end
end

class RevokeRunner
Expand Down

0 comments on commit 11c5e3a

Please sign in to comment.