Skip to content

Commit

Permalink
Inform user when latest remote platform image is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
sax committed Nov 8, 2014
1 parent 32afff4 commit 68b0700
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/vagrant/smartos/zones/cap/platform_image/latest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Cap
module PlatformImage
class Latest
def self.platform_image_latest(env)
platform_image = Zones::Util::PlatformImages.new(env).show_latest
platform_image = Zones::Util::PlatformImages.new(env).latest
env.ui.info 'Unable to find platform image' unless platform_image
env.ui.info platform_image
end
Expand Down
19 changes: 8 additions & 11 deletions lib/vagrant/smartos/zones/util/platform_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ def list
ui.info(images.join("\n"), prefix: false)
end

def show_latest
latest_platform_image
def latest
latest_html = Downloader.new(platform_image_latest_url).read
latest = latest_html.match(/(\d{8}T\d{6}Z)/)
return unless latest
latest[1]
end

private
Expand Down Expand Up @@ -69,16 +72,10 @@ def checksums_dir
home_path.join('smartos', 'checksums')
end

def latest_platform_image
latest_html = Downloader.new(platform_image_latest_url).read
latest = latest_html.match(/(\d{8}T\d{6}Z)/)
return unless latest
latest[1]
end

def latest_remote_or_current_image
latest_platform_image ||
images.last
return latest if latest
ui.info 'Unable to read remote latest platform image, using local'
images.last
end

def setup_smartos_directories
Expand Down

0 comments on commit 68b0700

Please sign in to comment.