Module: BoxAddExtension

Included in:
Vagrant::Action::Builtin::BoxAdd
Defined in:
lib/vagrant-box-gcs/extensions/box_add.rb

Instance Method Summary collapse

Instance Method Details

#download(url, env, **opts) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-box-gcs/extensions/box_add.rb', line 14

def download(url, env, **opts)
  opts[:ui] = true if !opts.key?(:ui)
  uri = URI.parse(url)
  if uri.scheme == 'gs'
    if (opts[:ui])
      env[:ui].detail(I18n.t('vagrant.box_downloading', url: uri.to_s))
    end
    temp_path = env[:tmp_path].join('box' + Digest::SHA1.hexdigest(uri.to_s))
    VagrantPlugins::BoxGCS::Storage.download(uri, temp_path.to_s)
  else
    super(url, env, **opts)
  end
end

#metadata_url?(url, env) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'lib/vagrant-box-gcs/extensions/box_add.rb', line 5

def (url, env)
  uri = URI.parse(url)
  if uri.scheme == 'gs'
    VagrantPlugins::BoxGCS::Storage.(uri)
  else
    super(url, env)
  end
end