bento-ya 0.1.4 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +19 -0
- data/CHANGELOG.md +20 -1
- data/Gemfile +11 -2
- data/README.md +1 -1
- data/Rakefile +22 -1
- data/bento-ya.gemspec +4 -5
- data/bin/bento +1 -1
- data/lib/bento.rb +2 -2
- data/lib/bento/build.rb +19 -13
- data/lib/bento/buildmetadata.rb +10 -10
- data/lib/bento/cli.rb +47 -64
- data/lib/bento/common.rb +55 -17
- data/lib/bento/delete.rb +6 -6
- data/lib/bento/normalize.rb +5 -6
- data/lib/bento/packerexec.rb +0 -1
- data/lib/bento/providermetadata.rb +26 -12
- data/lib/bento/release.rb +7 -7
- data/lib/bento/revoke.rb +7 -7
- data/lib/bento/test.rb +15 -11
- data/lib/bento/upload.rb +19 -10
- data/lib/bento/version.rb +1 -1
- data/templates/bootstrap.sh.erb +1 -0
- data/templates/kitchen.yml.erb +3 -3
- metadata +11 -26
- data/lib/bento/build_remote.rb +0 -116
- data/lib/bento/httpstuff.rb +0 -73
- data/lib/bento/vagrantcloud.rb +0 -138
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d80f43a61098c9b321b679f1518f54a033fcd3eb
|
4
|
+
data.tar.gz: fe4d410bb82744e2757d5717072019b222782daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db56b1404c177c23ca3229c08b3281b5d524a7e01c3f82a8c76a331798a21ea1d86058312637250881c5fbdd8aba141a9479846abc1dbd86bf4885ea00b6e9c1
|
7
|
+
data.tar.gz: 3d004b6eb6e7fcd13f1a36ed86d991bbb24d5c9f678fbe5024d323e73f34aa27e1cf9e7b8ddd4c6be5643571748ff68b6065a81d0e50b4f08ad185625ba7b4a2
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v1.0.0](https://github.com/cheeseplus/bento-ya/tree/v1.0.0) (2017-09-05)
|
4
|
+
[Full Changelog](https://github.com/cheeseplus/bento-ya/compare/v0.1.4...v1.0.0)
|
5
|
+
|
6
|
+
### IMPROVEMENTS
|
7
|
+
|
8
|
+
* Use `vagrant_cloud` gem
|
9
|
+
* Refactor all Vagrant Cloud related code
|
10
|
+
* cleanup deps, options, style
|
11
|
+
* drop remote build support
|
12
|
+
* add Chefstyle
|
13
|
+
* configure TravisCI
|
14
|
+
* moved more things out of bento and into bento-ya
|
15
|
+
* support for loading `builds.yml`
|
16
|
+
* support folder re-organzation in bento project
|
17
|
+
|
18
|
+
### BUG FIXES
|
19
|
+
|
20
|
+
* Fix provider being set incorrectly for VMware builds
|
21
|
+
|
3
22
|
## [v0.1.4](https://github.com/cheeseplus/bento-ya/tree/v0.1.4) (2017-07-05)
|
4
23
|
[Full Changelog](https://github.com/cheeseplus/bento-ya/compare/v0.1.3...v0.1.4)
|
5
24
|
|
@@ -76,4 +95,4 @@
|
|
76
95
|
|
77
96
|
|
78
97
|
|
79
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
98
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gemspec
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem "chefstyle"
|
7
|
+
gem "rake", ">= 10.1.0"
|
8
|
+
gem "rspec-core", "~> 3.0"
|
9
|
+
gem "rspec-expectations", "~> 3.0"
|
10
|
+
gem "rspec-mocks", "~> 3.0"
|
11
|
+
gem "rspec-collection_matchers", "~> 1.0"
|
12
|
+
end
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](http://badge.fury.io/rb/bento-ya)
|
1
|
+
[](http://badge.fury.io/rb/bento-ya) [](https://travis-ci.org/cheeseplus/bento-ya)
|
2
2
|
|
3
3
|
# bento-ya
|
4
4
|
A RubyGem for managing chef/bento builds
|
data/Rakefile
CHANGED
@@ -1 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new do |t|
|
7
|
+
t.pattern = "spec/**/*_spec.rb"
|
8
|
+
end
|
9
|
+
rescue LoadError
|
10
|
+
desc "rspec is not installed, this task is disabled"
|
11
|
+
task :spec do
|
12
|
+
abort "rspec is not installed. `(sudo) gem install rspec` to run unit tests"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => :spec
|
17
|
+
|
18
|
+
require "chefstyle"
|
19
|
+
require "rubocop/rake_task"
|
20
|
+
RuboCop::RakeTask.new(:style) do |task|
|
21
|
+
task.options += ["--display-cop-names", "--no-color"]
|
22
|
+
end
|
data/bento-ya.gemspec
CHANGED
@@ -14,14 +14,13 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.homepage = "https://github.com/cheeseplus/bento-ya"
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
|
-
gem.bindir
|
18
|
-
gem.executables = %w
|
17
|
+
gem.bindir = "bin"
|
18
|
+
gem.executables = %w{bento}
|
19
19
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
20
|
gem.require_paths = ["lib"]
|
21
21
|
|
22
22
|
gem.required_ruby_version = ">= 2.3.1"
|
23
23
|
|
24
|
-
gem.add_dependency
|
25
|
-
gem.add_dependency
|
26
|
-
gem.add_dependency 'buildkit', '~> 0.4'
|
24
|
+
gem.add_dependency "mixlib-shellout", ">= 2.3.2"
|
25
|
+
gem.add_dependency "vagrant_cloud", "~> 1.0"
|
27
26
|
end
|
data/bin/bento
CHANGED
data/lib/bento.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bento/common"
|
2
|
+
require "bento/version"
|
data/lib/bento/build.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "bento/common"
|
2
|
+
require "bento/buildmetadata"
|
3
|
+
require "bento/providermetadata"
|
4
|
+
require "bento/packerexec"
|
5
5
|
|
6
6
|
class BuildRunner
|
7
7
|
include Common
|
8
8
|
include PackerExec
|
9
9
|
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :template_files, :config, :dry_run, :debug, :only, :except, :mirror, :headed,
|
11
11
|
:override_version, :build_timestamp, :cpus, :mem
|
12
12
|
|
13
13
|
def initialize(opts)
|
14
|
-
@
|
14
|
+
@template_files = opts.template_files
|
15
|
+
@config = opts.config ||= false
|
15
16
|
@dry_run = opts.dry_run
|
16
17
|
@debug = opts.debug
|
17
|
-
@
|
18
|
+
@only = opts.only ||= "parallels-iso,virtualbox-iso,vmware-iso"
|
18
19
|
@except = opts.except
|
19
20
|
@mirror = opts.mirror
|
20
21
|
@headed = opts.headed ||= false
|
@@ -25,7 +26,9 @@ class BuildRunner
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def start
|
28
|
-
|
29
|
+
templates = config ? build_list : template_files
|
30
|
+
banner("Starting build for templates:")
|
31
|
+
templates.each { |t| puts "- #{t}" }
|
29
32
|
time = Benchmark.measure do
|
30
33
|
templates.each { |template| build(template) }
|
31
34
|
end
|
@@ -34,23 +37,26 @@ class BuildRunner
|
|
34
37
|
|
35
38
|
private
|
36
39
|
|
37
|
-
def build(
|
40
|
+
def build(file)
|
41
|
+
dir, template = file.split("/")[0], file.split("/")[1]
|
42
|
+
Dir.chdir dir
|
38
43
|
for_packer_run_with(template) do |md_file, var_file|
|
39
44
|
cmd = packer_build_cmd(template, md_file.path)
|
40
45
|
banner("[#{template}] Building: '#{cmd.join(' ')}'")
|
41
46
|
time = Benchmark.measure do
|
42
|
-
system(*cmd)
|
47
|
+
system(*cmd) || raise("[#{template}] Error building, exited #{$?}")
|
43
48
|
end
|
44
49
|
write_final_metadata(template, time.real.ceil)
|
45
50
|
banner("[#{template}] Finished building in #{duration(time.real)}.")
|
46
51
|
end
|
52
|
+
Dir.chdir("..")
|
47
53
|
end
|
48
54
|
|
49
55
|
def packer_build_cmd(template, var_file)
|
50
56
|
vars = "#{template}.variables.json"
|
51
|
-
cmd = %W
|
57
|
+
cmd = %W{packer build -var-file=#{var_file} #{template}.json}
|
52
58
|
cmd.insert(2, "-var-file=#{vars}") if File.exist?(vars)
|
53
|
-
cmd.insert(2, "-only=#{
|
59
|
+
cmd.insert(2, "-only=#{only}")
|
54
60
|
cmd.insert(2, "-except=#{except}") if except
|
55
61
|
# Build the command line in the correct order and without spaces as future input for the splat operator.
|
56
62
|
cmd.insert(2, "cpus=#{cpus}") if cpus
|
@@ -68,7 +74,7 @@ class BuildRunner
|
|
68
74
|
|
69
75
|
def write_final_metadata(template, buildtime)
|
70
76
|
md = BuildMetadata.new(template, build_timestamp, override_version).read
|
71
|
-
path = File.join("
|
77
|
+
path = File.join("../builds")
|
72
78
|
filename = File.join(path, "#{md[:box_basename]}.metadata.json")
|
73
79
|
md[:providers] = ProviderMetadata.new(path, md[:box_basename]).read
|
74
80
|
md[:providers].each do |p|
|
data/lib/bento/buildmetadata.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bento/common"
|
2
|
+
require "mixlib/shellout"
|
3
3
|
|
4
4
|
class BuildMetadata
|
5
5
|
include Common
|
@@ -35,11 +35,11 @@ class BuildMetadata
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def git_revision
|
38
|
-
sha =
|
38
|
+
sha = `git rev-parse HEAD`.strip
|
39
39
|
end
|
40
40
|
|
41
41
|
def git_clean?
|
42
|
-
|
42
|
+
`git status --porcelain`.strip.empty?
|
43
43
|
end
|
44
44
|
|
45
45
|
def merged_vars
|
@@ -62,10 +62,10 @@ class BuildMetadata
|
|
62
62
|
|
63
63
|
def version
|
64
64
|
if override_version
|
65
|
-
|
65
|
+
override_version
|
66
66
|
else
|
67
|
-
|
68
|
-
|
67
|
+
merged_vars.fetch("version", "#{UNKNOWN}.TIMESTAMP").
|
68
|
+
rpartition(".").first.concat(".#{build_timestamp}")
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -76,12 +76,12 @@ class BuildMetadata
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def vagrant_ver
|
79
|
-
if ENV[
|
80
|
-
|
79
|
+
if ENV["TRAVIS"]
|
80
|
+
"travis"
|
81
81
|
else
|
82
82
|
cmd = Mixlib::ShellOut.new("vagrant --version")
|
83
83
|
cmd.run_command
|
84
|
-
cmd.stdout.split(
|
84
|
+
cmd.stdout.split(" ")[1]
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
data/lib/bento/cli.rb
CHANGED
@@ -1,31 +1,27 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require 'bento/upload'
|
13
|
-
|
1
|
+
require "optparse"
|
2
|
+
require "ostruct"
|
3
|
+
|
4
|
+
require "bento/common"
|
5
|
+
require "bento/build"
|
6
|
+
require "bento/delete"
|
7
|
+
require "bento/normalize"
|
8
|
+
require "bento/release"
|
9
|
+
require "bento/revoke"
|
10
|
+
require "bento/test"
|
11
|
+
require "bento/upload"
|
14
12
|
|
15
13
|
class Options
|
16
|
-
|
17
14
|
NAME = File.basename($0).freeze
|
18
15
|
|
19
16
|
def self.parse(args)
|
20
17
|
options = OpenStruct.new
|
21
|
-
options.
|
18
|
+
options.template_files = calculate_templates("**/*.json")
|
22
19
|
|
23
20
|
global = OptionParser.new do |opts|
|
24
21
|
opts.banner = "Usage: #{NAME} [SUBCOMMAND [options]]"
|
25
22
|
opts.separator ""
|
26
23
|
opts.separator <<-COMMANDS.gsub(/^ {8}/, "")
|
27
24
|
build : build one or more templates
|
28
|
-
build_remote : build one or more templates via buildkite
|
29
25
|
help : prints this help message
|
30
26
|
list : list all templates in project
|
31
27
|
normalize : normalize one or more templates
|
@@ -38,13 +34,13 @@ class Options
|
|
38
34
|
end
|
39
35
|
|
40
36
|
platforms_argv_proc = proc { |options|
|
41
|
-
options.platforms = builds[
|
37
|
+
options.platforms = builds["public"] unless args.empty?
|
42
38
|
}
|
43
39
|
|
44
40
|
templates_argv_proc = proc { |options|
|
45
41
|
options.templates = calculate_templates(args) unless args.empty?
|
46
42
|
|
47
|
-
options.
|
43
|
+
options.template_files.each do |t|
|
48
44
|
if !File.exists?("#{t}.json")
|
49
45
|
$stderr.puts "File #{t}.json does not exist for template '#{t}'"
|
50
46
|
exit(1)
|
@@ -67,23 +63,27 @@ class Options
|
|
67
63
|
argv: proc { |options|
|
68
64
|
puts global
|
69
65
|
exit(0)
|
70
|
-
}
|
66
|
+
},
|
71
67
|
},
|
72
68
|
build: {
|
73
69
|
class: BuildRunner,
|
74
|
-
parser: OptionParser.new
|
70
|
+
parser: OptionParser.new do |opts|
|
75
71
|
opts.banner = "Usage: #{NAME} build [options] TEMPLATE[ TEMPLATE ...]"
|
76
72
|
|
77
73
|
opts.on("-n", "--dry-run", "Dry run (what would happen)") do |opt|
|
78
74
|
options.dry_run = opt
|
79
75
|
end
|
80
76
|
|
77
|
+
opts.on("-c BUILD_YML", "--config BUILD_YML", "Use a configuration file") do |opt|
|
78
|
+
options.config = opt
|
79
|
+
end
|
80
|
+
|
81
81
|
opts.on("-d", "--[no-]debug", "Run packer with debug output") do |opt|
|
82
82
|
options.debug = opt
|
83
83
|
end
|
84
84
|
|
85
85
|
opts.on("-o BUILDS", "--only BUILDS", "Only build some Packer builds") do |opt|
|
86
|
-
options.
|
86
|
+
options.only = opt
|
87
87
|
end
|
88
88
|
|
89
89
|
opts.on("-e BUILDS", "--except BUILDS", "Build all Packer builds except these") do |opt|
|
@@ -109,45 +109,30 @@ class Options
|
|
109
109
|
opts.on("-v VERSION", "--version VERSION", "Override the version set in the template") do |opt|
|
110
110
|
options.override_version = opt
|
111
111
|
end
|
112
|
-
|
113
|
-
argv: templates_argv_proc
|
114
|
-
},
|
115
|
-
build_remote: {
|
116
|
-
class: BuildRemoteRunner,
|
117
|
-
parser: OptionParser.new { |opts|
|
118
|
-
opts.banner = "Usage: #{NAME} build_remote [options] [PLATFORM ...]"
|
119
|
-
|
120
|
-
opts.on("-v VERSION", "--version VERSION", "Override the version set in the template") do |opt|
|
121
|
-
options.override_version = opt
|
122
|
-
end
|
123
|
-
|
124
|
-
opts.on("--dry-run", "Show me what you got") do |opt|
|
125
|
-
options.dry_run = opt
|
126
|
-
end
|
127
|
-
},
|
128
|
-
argv: platforms_argv_proc
|
112
|
+
end,
|
113
|
+
argv: templates_argv_proc,
|
129
114
|
},
|
130
115
|
list: {
|
131
116
|
class: ListRunner,
|
132
|
-
parser: OptionParser.new
|
117
|
+
parser: OptionParser.new do |opts|
|
133
118
|
opts.banner = "Usage: #{NAME} list [TEMPLATE ...]"
|
134
|
-
|
135
|
-
argv: templates_argv_proc
|
119
|
+
end,
|
120
|
+
argv: templates_argv_proc,
|
136
121
|
},
|
137
122
|
normalize: {
|
138
123
|
class: NormalizeRunner,
|
139
|
-
parser: OptionParser.new
|
124
|
+
parser: OptionParser.new do |opts|
|
140
125
|
opts.banner = "Usage: #{NAME} normalize TEMPLATE[ TEMPLATE ...]"
|
141
126
|
|
142
127
|
opts.on("-d", "--[no-]debug", "Run packer with debug output") do |opt|
|
143
128
|
options.debug = opt
|
144
129
|
end
|
145
|
-
|
146
|
-
argv: templates_argv_proc
|
130
|
+
end,
|
131
|
+
argv: templates_argv_proc,
|
147
132
|
},
|
148
133
|
test: {
|
149
134
|
class: TestRunner,
|
150
|
-
parser: OptionParser.new
|
135
|
+
parser: OptionParser.new do |opts|
|
151
136
|
opts.banner = "Usage: #{NAME} test [options]"
|
152
137
|
|
153
138
|
opts.on("--no-shared-folder", "Disable shared folder testing") do |opt|
|
@@ -157,37 +142,37 @@ class Options
|
|
157
142
|
opts.on("-p", "--provisioner PROVISIONER", "Use a specfic provisioner") do |opt|
|
158
143
|
options.provisioner = opt
|
159
144
|
end
|
160
|
-
|
161
|
-
argv: Proc.new {}
|
145
|
+
end,
|
146
|
+
argv: Proc.new {},
|
162
147
|
},
|
163
148
|
upload: {
|
164
149
|
class: UploadRunner,
|
165
|
-
parser: OptionParser.new
|
150
|
+
parser: OptionParser.new do |opts|
|
166
151
|
opts.banner = "Usage: #{NAME} upload"
|
167
|
-
|
168
|
-
argv: md_json_argv_proc
|
152
|
+
end,
|
153
|
+
argv: md_json_argv_proc,
|
169
154
|
},
|
170
155
|
release: {
|
171
156
|
class: ReleaseRunner,
|
172
|
-
parser: OptionParser.new
|
157
|
+
parser: OptionParser.new do |opts|
|
173
158
|
opts.banner = "Usage: #{NAME} release BOX VERSION"
|
174
|
-
|
175
|
-
argv: box_version_argv_proc
|
159
|
+
end,
|
160
|
+
argv: box_version_argv_proc,
|
176
161
|
},
|
177
162
|
revoke: {
|
178
163
|
class: RevokeRunner,
|
179
|
-
parser: OptionParser.new
|
164
|
+
parser: OptionParser.new do |opts|
|
180
165
|
opts.banner = "Usage: #{NAME} revoke BOX VERSION"
|
181
|
-
|
182
|
-
argv: box_version_argv_proc
|
166
|
+
end,
|
167
|
+
argv: box_version_argv_proc,
|
183
168
|
},
|
184
169
|
delete: {
|
185
170
|
class: DeleteRunner,
|
186
|
-
parser: OptionParser.new
|
171
|
+
parser: OptionParser.new do |opts|
|
187
172
|
opts.banner = "Usage: #{NAME} delete BOX VERSION"
|
188
|
-
|
189
|
-
argv: box_version_argv_proc
|
190
|
-
}
|
173
|
+
end,
|
174
|
+
argv: box_version_argv_proc,
|
175
|
+
},
|
191
176
|
}
|
192
177
|
|
193
178
|
global.order!
|
@@ -206,13 +191,12 @@ class Options
|
|
206
191
|
map { |glob| result = Dir.glob(glob); result.empty? ? glob : result }.
|
207
192
|
flatten.
|
208
193
|
sort.
|
209
|
-
delete_if { |file| file =~ /\.variables\./ }.
|
210
|
-
map { |template| template.sub(/\.json$/,
|
194
|
+
delete_if { |file| file =~ /\.(variables||metadata)\./ }.
|
195
|
+
map { |template| template.sub(/\.json$/, "") }
|
211
196
|
end
|
212
197
|
end
|
213
198
|
|
214
199
|
class ListRunner
|
215
|
-
|
216
200
|
include Common
|
217
201
|
|
218
202
|
attr_reader :templates
|
@@ -227,7 +211,6 @@ class ListRunner
|
|
227
211
|
end
|
228
212
|
|
229
213
|
class Runner
|
230
|
-
|
231
214
|
attr_reader :options
|
232
215
|
|
233
216
|
def initialize(options)
|