singel 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaa5865dd1830b229c430c5846b5ef4b28c586b0
4
- data.tar.gz: 54c9c871c502e99a8e9f9103868ae7355217e1bd
3
+ metadata.gz: 93309ed4bb6ca45ba817b03388085fb3f5fe8b9a
4
+ data.tar.gz: 8607257c32a674deac60097d3e88349fabe5d4fd
5
5
  SHA512:
6
- metadata.gz: d27fb80019dd99723ae69fd2e9c18a2be5316cea852457a8072851b9c84cd67b99157c0db4efb486f7cc5b58d5fbe6087c68a4d8dbb73e0c240a90d597a63483
7
- data.tar.gz: f61553aed236cdf546ce82fb544213d8ad51d6eb0215e6e02a79c565f87fc14a5b408a79a42f90adbbbbecd9132e578e7ee53beef1ef58bc573c0b0bfa54357f
6
+ metadata.gz: 8aa63e39b2eb98bcfcbe4af326a3e996c178bbc1e6e8ef48913c53afd60d4396c4f3bf7b37cf4f2cffb767a05d64032f6ca63d382d485a9db7bc2aab0cb53fa0
7
+ data.tar.gz: 1652fe4e7d25d9ac23e99cbdc18ed63844047ae3aa4518466a6d019768e28cd305be73beac370570662a4752927ab5c90c940bc324b8a9f4bbbacb23c975c0e6
@@ -1,8 +1,11 @@
1
1
  language: ruby
2
+ cache:
3
+ - bundler
4
+ install:
5
+ - bundle install
2
6
  rvm:
3
- - 1.9.3
4
- - 2.1.5
5
- - 2.2.0
7
+ - 2.1.6
8
+ - 2.2.2
6
9
  script:
7
10
  - bundle exec rake test
8
11
 
data/Gemfile CHANGED
@@ -1,8 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'aws-sdk-core'
4
-
5
- group :test do
6
- gem 'rubocop', '~> 0.28.0'
7
- gem 'rake', '~> 10.0'
8
- end
3
+ gemspec
data/bin/singel CHANGED
@@ -25,14 +25,9 @@ begin
25
25
  require 'aws-sdk-core'
26
26
  require 'json'
27
27
  require 'pty'
28
- require 'config.rb'
29
- require 'orchestrator.rb'
30
- require 'executor.rb'
31
- require 'uploader.rb'
32
- require 'template.rb'
33
- require 'string.rb'
28
+ require 'singel.rb'
34
29
  rescue LoadError => e
35
30
  raise "Missing gem or lib #{e}"
36
31
  end
37
32
 
38
- Singel::SingelOrchestrator.new.run
33
+ Singel.run
@@ -0,0 +1,108 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Author:: Tim Smith (<tim@cozy.co>)
4
+ # Copyright:: Copyright (c) 2014 Tim Smith
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ # main orchestrator of singel runs
20
+ module Singel
21
+ require 'singel/config.rb'
22
+ require 'singel/executor.rb'
23
+ require 'singel/uploader.rb'
24
+ require 'singel/template.rb'
25
+ require 'string.rb'
26
+
27
+ include Singel::Config
28
+
29
+ # main method used to kick off the run
30
+ def self::run
31
+ @options = Config.config
32
+ puts "\nsingel - unified image creation tool"
33
+ puts "-----------------------------------------\n\n"
34
+
35
+ check_dirs
36
+ check_executables
37
+ @templates = find_templates
38
+ check_aws_keys
39
+
40
+ execute_command(ARGV[0])
41
+ end
42
+
43
+ private
44
+
45
+ # check to make sure the packer dir exists
46
+ def self::check_dirs
47
+ unless Dir.exist?(@options[:packer_dir])
48
+ puts "#{@options[:packer_dir]} not present.".to_red
49
+ puts "See help for information on specifying an alternate dir.\n".to_red
50
+ exit!
51
+ end
52
+ end
53
+
54
+ # make a test connection using the AWS keys to determine if they're valid
55
+ def self::check_aws_keys
56
+ ec2 = Aws::EC2::Client.new(region: 'us-east-1')
57
+ ec2.describe_instance_status
58
+ rescue
59
+ puts 'Could not connect to EC2. Check your local AWS credentials before continuing.'.to_red
60
+ exit!
61
+ end
62
+
63
+ # check to make sure the prereq binaries present
64
+ def self::check_executables
65
+ { 'Virtualbox' => 'vboxwebsrv', 'Packer' => 'packer' }.each_pair do |name, binary|
66
+ `which #{binary} 2>&1`
67
+ unless $CHILD_STATUS.success?
68
+ puts "Could not find #{name} binary #{binary}. You must install #{name} before continuing.".to_red unless $CHILD_STATUS
69
+ exit!
70
+ end
71
+ end
72
+ end
73
+
74
+ # find the available packer templates on the host
75
+ def self::find_templates
76
+ # find packer templates on disk since none were passed via args
77
+ if @options[:templates].empty?
78
+ templates = []
79
+ Dir.foreach(@options[:packer_dir]) do |item|
80
+ templates << File.join(@options[:packer_dir], item) if File.extname(item).downcase == '.json'
81
+ end
82
+
83
+ # throw and error and exist if we still dont find any templates
84
+ if templates.empty?
85
+ puts "No packer templates found in the 'packer' dir. Cannot continue.".to_red
86
+ exit!
87
+ end
88
+ templates
89
+ else # parse the arg provided template list
90
+ @options[:templates].map { |x| File.join(@options[:packer_dir], x) }
91
+ end
92
+ end
93
+
94
+ # run the passed command per packer template
95
+ def self::execute_command(cmd)
96
+ @templates.each do |t|
97
+ template = PackerTemplate.new(t)
98
+ executor = PackerExecutor.new(template, @options[:builders])
99
+ puts "Packer template validation for #{template.path} failed.\n".to_red unless template.validates?
100
+ begin
101
+ executor.send(cmd)
102
+ rescue NoMethodError
103
+ puts "Action \"#{cmd}\" not found. Cannot continue".to_red
104
+ exit!
105
+ end
106
+ end
107
+ end
108
+ end
File without changes
@@ -54,7 +54,7 @@ module Singel
54
54
  PTY.spawn(command) do |r, _w, pid|
55
55
  begin
56
56
  r.each { |line| print line; }
57
- rescue Errno::EIO
57
+ rescue Errno::EIO # rubocop: disable Lint/HandleExceptions
58
58
  # this is an expected behavior when an app is done sending output
59
59
  ensure
60
60
  Process.wait(pid)
@@ -29,6 +29,9 @@ module Singel
29
29
 
30
30
  def json
31
31
  @parsed || @parsed = JSON.parse(@file)
32
+ rescue JSON::ParserError
33
+ puts "Invalid JSON in the Packer config #{@name}.\nValidate your JSON before running Singel again.".to_red
34
+ exit!
32
35
  end
33
36
 
34
37
  def builders
File without changes
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'singel'
3
- s.version = '0.2.2'
3
+ s.version = '0.2.3'
4
4
  s.date = Date.today.to_s
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.extra_rdoc_files = ['README.md', 'LICENSE']
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.required_ruby_version = '>= 1.9.3'
15
15
  s.add_dependency 'aws-sdk-core'
16
16
  s.add_development_dependency 'rake', '~> 10.0'
17
- s.add_development_dependency 'rubocop', '~> 0.28.0'
17
+ s.add_development_dependency 'rubocop', '~> 0.30.0'
18
18
 
19
19
  s.files = `git ls-files -z`.split("\x0")
20
20
  s.executables = s.name
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-23 00:00:00.000000000 Z
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 0.28.0
47
+ version: 0.30.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 0.28.0
54
+ version: 0.30.0
55
55
  description: Unified system image creation using Packer
56
56
  email: tim@cozy.co
57
57
  executables:
@@ -68,12 +68,12 @@ files:
68
68
  - README.md
69
69
  - Rakefile
70
70
  - bin/singel
71
- - lib/config.rb
72
- - lib/executor.rb
73
- - lib/orchestrator.rb
71
+ - lib/singel.rb
72
+ - lib/singel/config.rb
73
+ - lib/singel/executor.rb
74
+ - lib/singel/template.rb
75
+ - lib/singel/uploader.rb
74
76
  - lib/string.rb
75
- - lib/template.rb
76
- - lib/uploader.rb
77
77
  - singel.gemspec
78
78
  homepage: http://www.github.com/tas50/singel
79
79
  licenses:
@@ -1,106 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Author:: Tim Smith (<tim@cozy.co>)
4
- # Copyright:: Copyright (c) 2014 Tim Smith
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- module Singel
20
- # class to control validation of configs / prereqs and to
21
- # fire off the individual executor instances to build each template
22
- class SingelOrchestrator
23
- include Singel::Config
24
-
25
- def initialize
26
- @options = Singel::Config.config
27
- end
28
-
29
- # main method used to kick off the run
30
- def run
31
- puts "\nsingel - unified image creation tool"
32
- puts "-----------------------------------------\n\n"
33
-
34
- check_dirs
35
- check_executables
36
- @templates = find_templates
37
- check_aws_keys
38
-
39
- execute_command(ARGV[0])
40
- end
41
-
42
- # check to make sure the packer dir exists
43
- def check_dirs
44
- unless Dir.exist?(@options[:packer_dir])
45
- puts "#{@options[:packer_dir]} not present.".to_red
46
- puts "See help for information on specifying an alternate dir.\n".to_red
47
- exit!
48
- end
49
- end
50
-
51
- # make a test connection using the AWS keys to determine if they're valid
52
- def check_aws_keys
53
- ec2 = Aws::EC2::Client.new(region: 'us-east-1')
54
- ec2.describe_instance_status
55
- rescue
56
- puts 'Could not connect to EC2. Check your local AWS credentials before continuing.'.to_red
57
- exit!
58
- end
59
-
60
- # check to make sure the prereq binaries present
61
- def check_executables
62
- { 'Virtualbox' => 'vboxwebsrv', 'Packer' => 'packer' }.each_pair do |name, binary|
63
- `which #{binary} 2>&1`
64
- unless $CHILD_STATUS.success?
65
- puts "Could not find #{name} binary #{binary}. You must install #{name} before continuing.".to_red unless $CHILD_STATUS
66
- exit!
67
- end
68
- end
69
- end
70
-
71
- # find the available packer templates on the host
72
- def find_templates
73
- # find packer templates on disk since none were passed via args
74
- if @options[:templates].empty?
75
- templates = []
76
- Dir.foreach(@options[:packer_dir]) do |item|
77
- templates << File.join(@options[:packer_dir], item) if File.extname(item).downcase == '.json'
78
- end
79
-
80
- # throw and error and exist if we still dont find any templates
81
- if templates.empty?
82
- puts "No packer templates found in the 'packer' dir. Cannot continue.".to_red
83
- exit!
84
- end
85
- templates
86
- else # parse the arg provided template list
87
- @options[:templates].map { |x| File.join(@options[:packer_dir], x) }
88
- end
89
- end
90
-
91
- # run the passed command per packer template
92
- def execute_command(cmd)
93
- @templates.each do |t|
94
- template = PackerTemplate.new(t)
95
- executor = PackerExecutor.new(template, @options[:builders])
96
- puts "Packer template validation for #{template.path} failed.\n".to_red unless template.validates?
97
- begin
98
- executor.send(cmd)
99
- rescue NoMethodError
100
- puts "Action \"#{cmd}\" not found. Cannot continue".to_red
101
- exit!
102
- end
103
- end
104
- end
105
- end
106
- end