linecook-gem 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linecook-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Hamel
@@ -136,6 +136,62 @@ dependencies:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.8.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: encryptor
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 1.3.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.3.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: ejson
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 1.0.1
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 1.0.1
167
+ - !ruby/object:Gem::Dependency
168
+ name: aws-sdk
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 2.2.4
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 2.2.4
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubyzip
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 1.1.7
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 1.1.7
139
195
  - !ruby/object:Gem::Dependency
140
196
  name: rake
141
197
  requirement: !ruby/object:Gem::Requirement
@@ -202,17 +258,25 @@ extra_rdoc_files: []
202
258
  files:
203
259
  - bin/linecook
204
260
  - lib/linecook.rb
205
- - lib/linecook/bake.rb
206
- - lib/linecook/build.rb
207
- - lib/linecook/builder.rb
208
- - lib/linecook/chef.rb
261
+ - lib/linecook/builder/build.rb
262
+ - lib/linecook/builder/darwin_backend.rb
263
+ - lib/linecook/builder/linux_backend.rb
264
+ - lib/linecook/builder/lxc.rb
265
+ - lib/linecook/builder/manager.rb
209
266
  - lib/linecook/cli.rb
210
- - lib/linecook/config.rb
211
- - lib/linecook/darwin_backend.rb
212
- - lib/linecook/image.rb
213
- - lib/linecook/linux_backend.rb
214
- - lib/linecook/lxc.rb
215
- - lib/linecook/ssh.rb
267
+ - lib/linecook/image/crypt.rb
268
+ - lib/linecook/image/github.rb
269
+ - lib/linecook/image/manager.rb
270
+ - lib/linecook/image/s3.rb
271
+ - lib/linecook/packager/ebs.rb
272
+ - lib/linecook/packager/manager.rb
273
+ - lib/linecook/provisioner/chef-zero.rb
274
+ - lib/linecook/provisioner/manager.rb
275
+ - lib/linecook/provisioner/packer.rb
276
+ - lib/linecook/util/config.rb
277
+ - lib/linecook/util/downloader.rb
278
+ - lib/linecook/util/executor.rb
279
+ - lib/linecook/util/ssh.rb
216
280
  - lib/linecook/version.rb
217
281
  - man/LINECOOK.1
218
282
  homepage: http://rubygems.org/gems/linecook
@@ -240,3 +304,4 @@ signing_key:
240
304
  specification_version: 4
241
305
  summary: Build system images using chef zero, LXC, and packer
242
306
  test_files: []
307
+ has_rdoc:
data/lib/linecook/bake.rb DELETED
@@ -1,21 +0,0 @@
1
- require 'securerandom'
2
-
3
- require 'linecook/build'
4
- require 'linecook/chef'
5
-
6
- module Linecook
7
- module Baker
8
- extend self
9
-
10
- def bake
11
- provisioner = 'chef' # FIXME HACK - read from config instead
12
- build = Linecook::Build.new('test', 'ubuntu-base.squashfs') # FIXME - HACK, read from config
13
- case provisioner
14
- when 'chef'
15
- Linecook::Chef.provision(build)
16
- else
17
- fail "Unsupported provisioner #{provisioner}"
18
- end
19
- end
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- require 'forwardable'
2
- require 'linecook/builder'
3
-
4
- module Linecook
5
- class Build
6
- extend Forwardable
7
-
8
- def_instance_delegators :@container, :stop, :start, :ip, :info
9
-
10
- def initialize(name, image)
11
- Linecook::Builder.start
12
- @name = name
13
- @image = image
14
- @container = Linecook::Lxc::Container.new(name: @name, image: @image, remote: Linecook::Builder.ssh)
15
- end
16
-
17
- def ssh
18
- @ssh ||= Linecook::SSH.new(@container.ip, username: 'ubuntu', password: 'ubuntu', proxy: Linecook::Builder.ssh, keyfile: Linecook::Builder.pemfile)
19
- end
20
- end
21
- end
@@ -1,93 +0,0 @@
1
- require 'forwardable'
2
- require 'sshkey'
3
-
4
- require 'linecook/lxc'
5
- require 'linecook/darwin_backend'
6
- require 'linecook/linux_backend'
7
- #
8
- # Linux builder:
9
- # - just checks for a bridge interface
10
- # - download live image, if not already
11
- # - sets up lxc container using local lxc config
12
- # - copies base image into builder container
13
-
14
- # OS X builder:
15
- # - download live ISO
16
- # - hdiutil
17
- # - create cache loopback image
18
- # - dd, based on config file.
19
- # - start xhyve using gem
20
- # - keep track of PID and IP
21
- # - copy base image into xhyve cache
22
-
23
- # One linecook instance per build, but many linecook instances can share a single builder
24
- # FIXME: How to deal with concurrent builds on different branches / revisions?
25
-
26
- module Linecook
27
- module Builder
28
- extend self
29
- extend Forwardable
30
- BUILD_HOME = '/u/lxc'
31
-
32
- attr_reader :pemfile
33
- def_instance_delegators :backend, :stop, :ip, :info, :running?
34
-
35
- def backend
36
- @backend ||= backend_for_platform
37
- end
38
-
39
- def start
40
- return if running?
41
- backend.start
42
- setup_ssh
43
- end
44
-
45
- def ssh
46
- config = Linecook::Config.load_config[:builder]
47
- @ssh ||= begin
48
- userkey = File.expand_path("~/.ssh/id_rsa")
49
- dedicated_key = File.join(Linecook::Config::LINECOOK_HOME, 'linecook_ssh.pem')
50
- unless File.exists?(dedicated_key)
51
- File.write(dedicated_key, SSHKey.generate.private_key)
52
- FileUtils.chmod(0600, dedicated_key)
53
- end
54
- @pemfile = File.exists?(userkey) ? userkey : dedicated_key
55
- puts @pemfile
56
- SSH.new(ip, username: config[:username], password: config[:password], keyfile: @pemfile)
57
- end
58
- end
59
-
60
- def builds
61
- ssh.test("[ -d #{BUILD_HOME} ]") ? ssh.capture("find #{BUILD_HOME} -maxdepth 1 -mindepth 1 -type d -printf \"%f\n\"").delete(';').lines : []
62
- end
63
-
64
- def build_info
65
- info = {}
66
- builds.each do |build|
67
- info[build] = Linecook::Build.new(build, nil).info
68
- end
69
- info
70
- end
71
-
72
- private
73
-
74
- def setup_ssh
75
- ssh
76
- pubkey = SSHKey.new(File.read(@pemfile)).ssh_public_key
77
- config = Linecook::Config.load_config[:builder]
78
- ssh.run("mkdir -p /home/#{config[:username]}/.ssh")
79
- ssh.upload(pubkey, "/home/#{config[:username]}/.ssh/authorized_keys")
80
- end
81
-
82
- def backend_for_platform
83
- case Config.platform
84
- when 'linux'
85
- LinuxBuilder.backend
86
- when 'darwin'
87
- OSXBuilder.backend
88
- else
89
- fail "Cannot find supported backend for #{Config.platform}"
90
- end
91
- end
92
- end
93
- end
@@ -1,51 +0,0 @@
1
- require 'open-uri'
2
- require 'fileutils'
3
- require 'digest'
4
-
5
- require 'octokit'
6
- require 'ruby-progressbar'
7
-
8
- module Linecook
9
- module ImageFetcher
10
- extend self
11
-
12
- def fetch(name, upgrade:false)
13
- dir = File.join(Config::LINECOOK_HOME, 'images')
14
- path = File.join(dir, name)
15
- download(image(name)[:browser_download_url], path) unless File.exist?(path) || upgrade
16
- path
17
- end
18
-
19
- private
20
-
21
- def client
22
- @client ||= Octokit::Client.new
23
- end
24
-
25
- def source
26
- @source ||= (Config.load_config['source_repo'] || 'dalehamel/lxb')
27
- end
28
-
29
- def latest
30
- client.releases(source).sort_by { |r| r[:published_at] }.last
31
- end
32
-
33
- def image(name)
34
- latest[:assets].find { |a| a[:name] =~ /#{name}/ }
35
- end
36
-
37
- def download(url, path)
38
- FileUtils.mkdir_p(File.dirname(path))
39
- File.open(path, 'w') do |f|
40
- pbar = ProgressBar.create(title: File.basename(path), total: nil)
41
- IO.copy_stream(open(url,
42
- content_length_proc: lambda do|t|
43
- pbar.total = t if t && 0 < t
44
- end,
45
- progress_proc: lambda do|s|
46
- pbar.progress = s
47
- end), f)
48
- end
49
- end
50
- end
51
- end