Class: Litterbox::Habitat::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/litterbox/habitat/upload.rb

Overview

Habitat upload

Instance Method Summary collapse

Constructor Details

#initialize(pkg, auth) ⇒ Upload

Returns a new instance of Upload.



7
8
9
10
# File 'lib/litterbox/habitat/upload.rb', line 7

def initialize(pkg, auth)
  @pkg = pkg
  @auth = auth
end

Instance Method Details

#upload(pkg = @pkg, auth = @auth) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/litterbox/habitat/upload.rb', line 12

def upload(pkg = @pkg, auth = @auth)
  raise 'file artifact not found' unless File.exist?(pkg)
  raise 'must pass auth token' unless auth
  cmd = "hab pkg upload #{pkg} -z #{auth}"
  puts cmd
  Open3.popen3(cmd) do |_, out, _, thr|
    while (line = out.gets)
      puts(line)
    end
    return thr.value
  end
end