ey-core 3.1.1 → 3.1.2
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/.ruby-gemset +1 -0
- data/.ruby-version +1 -1
- data/bin/ey-core +2 -2
- data/ey-core.gemspec +1 -0
- data/lib/ey-core/cli.rb +5 -21
- data/lib/ey-core/cli/helpers/server_sieve.rb +76 -0
- data/lib/ey-core/cli/login.rb +2 -2
- data/lib/ey-core/cli/main.rb +28 -0
- data/lib/ey-core/cli/recipes/apply.rb +35 -13
- data/lib/ey-core/cli/ssh.rb +12 -25
- data/lib/ey-core/version.rb +1 -1
- data/spec/ey-core/cli/helpers/server_sieve_spec.rb +226 -0
- data/spec/ey-core/cli/recipes/apply_spec.rb +91 -0
- data/spec/support/cli_helpers.rb +11 -0
- data/spec/support/fake_kernel.rb +21 -0
- metadata +28 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 919ebc8c77b103ddfd55db2ba29a66639dfddf34
|
4
|
+
data.tar.gz: 3ebcb90ae295acb131ef4412e4f44b91b87542b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 698694cdad540b7c271401dfb3917d93a7bdad374affd8bdd05da34690566de0331c13894fd8b57c4e438038664b6107385e4e6ae1ca2ca48b9f3567c478f3a5
|
7
|
+
data.tar.gz: 2b3c997104b8e9e8925ef60848bcbe88da61f21ebda4ed19dd6e27f950378d046ef7137f0dc276477bd4c76444a4f4026571467b10a9fc9d3d61c664a85479f1
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
core-client-rb-upstream
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3
|
1
|
+
2.3.0
|
data/bin/ey-core
CHANGED
data/ey-core.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |gem|
|
|
28
28
|
gem.add_dependency "faraday", "~> 0.9"
|
29
29
|
gem.add_dependency "faraday_middleware", "~> 0.9"
|
30
30
|
gem.add_dependency "faye"
|
31
|
+
gem.add_dependency "highline"
|
31
32
|
gem.add_dependency "mime-types", "~> 2.99" #maintain ruby 1.9 compatibility
|
32
33
|
gem.add_dependency "oj"
|
33
34
|
gem.add_dependency "oj_mimic_json"
|
data/lib/ey-core/cli.rb
CHANGED
@@ -1,24 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'ey-core'
|
4
|
-
require 'awesome_print'
|
5
|
-
require 'pry'
|
6
|
-
require 'belafonte'
|
7
|
-
require 'table_print'
|
8
|
-
require 'rubygems/package'
|
9
|
-
require 'escape'
|
1
|
+
module Ey
|
2
|
+
module Core
|
10
3
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
class Ey::Core::Cli < Belafonte::App
|
15
|
-
title "Engineyard CLI"
|
16
|
-
summary "Successor to the engineyard gem"
|
17
|
-
|
18
|
-
require_relative "cli/subcommand"
|
19
|
-
Dir[File.dirname(__FILE__) + '/cli/*.rb'].each {|file| load file }
|
20
|
-
|
21
|
-
Ey::Core::Cli::Subcommand.descendants.each do |d|
|
22
|
-
mount d
|
4
|
+
# The overall namespace for CLI-related code
|
5
|
+
module Cli
|
6
|
+
end
|
23
7
|
end
|
24
8
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Ey
|
2
|
+
module Core
|
3
|
+
module Cli
|
4
|
+
module Helpers
|
5
|
+
class ServerSieve
|
6
|
+
ROLES = [
|
7
|
+
:app_servers,
|
8
|
+
:db_servers,
|
9
|
+
:db_master,
|
10
|
+
:utilities
|
11
|
+
]
|
12
|
+
|
13
|
+
attr_reader :servers_api, :options
|
14
|
+
|
15
|
+
def self.filter(servers_api, options = {})
|
16
|
+
new(servers_api, options).filtered
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(servers_api, options = {})
|
20
|
+
@servers_api = servers_api
|
21
|
+
@options = options
|
22
|
+
end
|
23
|
+
|
24
|
+
def filtered
|
25
|
+
return all_servers if requested?(:all)
|
26
|
+
|
27
|
+
requested_roles.map {|role|
|
28
|
+
role == :utilities ? utils_named(option(:utilities)) : send(role)
|
29
|
+
}.flatten.uniq
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def requested_roles
|
34
|
+
#self.class::
|
35
|
+
ROLES.select {|role| requested?(role)}
|
36
|
+
end
|
37
|
+
|
38
|
+
def option(name)
|
39
|
+
options[name]
|
40
|
+
end
|
41
|
+
|
42
|
+
def requested?(name)
|
43
|
+
option(name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def all_servers
|
47
|
+
servers_api.all.to_a.uniq
|
48
|
+
end
|
49
|
+
|
50
|
+
def app_servers
|
51
|
+
['app_master', 'app', 'solo'].
|
52
|
+
map {|role| servers_api.all(role: role).to_a}.
|
53
|
+
flatten
|
54
|
+
end
|
55
|
+
|
56
|
+
def db_servers
|
57
|
+
db_master + servers_api.all(role: 'db_slave').to_a
|
58
|
+
end
|
59
|
+
|
60
|
+
def db_master
|
61
|
+
['db_master', 'solo'].
|
62
|
+
map {|role| servers_api.all(role: role).to_a}.
|
63
|
+
flatten
|
64
|
+
end
|
65
|
+
|
66
|
+
def utils_named(name)
|
67
|
+
filter = {role: 'util'}
|
68
|
+
filter[:name] = name unless name.downcase == 'all'
|
69
|
+
|
70
|
+
servers_api.all(filter).to_a
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/ey-core/cli/login.rb
CHANGED
@@ -3,8 +3,8 @@ class Ey::Core::Cli::Login < Ey::Core::Cli::Subcommand
|
|
3
3
|
summary "Retrieve API token from Engine Yard Cloud"
|
4
4
|
|
5
5
|
def handle
|
6
|
-
email = ENV["EMAIL"] || ask("Email:")
|
7
|
-
password = ENV["PASSWORD"] || ask("Password:"
|
6
|
+
email = ENV["EMAIL"] || ask("Email: ")
|
7
|
+
password = ENV["PASSWORD"] || ask("Password: ") { |q| q.echo = false }
|
8
8
|
|
9
9
|
token = unauthenticated_core_client.get_api_token(email, password).body["api_token"]
|
10
10
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'ey-core'
|
4
|
+
require 'ey-core/cli'
|
5
|
+
require 'awesome_print'
|
6
|
+
require 'pry'
|
7
|
+
require 'belafonte'
|
8
|
+
require 'table_print'
|
9
|
+
require 'rubygems/package'
|
10
|
+
require 'escape'
|
11
|
+
require 'highline/import'
|
12
|
+
|
13
|
+
Cistern.formatter = Cistern::Formatter::AwesomePrint
|
14
|
+
|
15
|
+
|
16
|
+
class Ey::Core::Cli::Main < Belafonte::App
|
17
|
+
title "Engineyard CLI"
|
18
|
+
summary "Successor to the engineyard gem"
|
19
|
+
|
20
|
+
require_relative "subcommand"
|
21
|
+
Dir[File.dirname(__FILE__) + '/*.rb'].
|
22
|
+
reject {|file| file =~ /.*\/main\.rb$/}.
|
23
|
+
each {|file| load file }
|
24
|
+
|
25
|
+
Ey::Core::Cli::Subcommand.descendants.each do |d|
|
26
|
+
mount d
|
27
|
+
end
|
28
|
+
end
|
@@ -5,30 +5,52 @@ class Ey::Core::Cli::Recipes::Apply < Ey::Core::Cli::Recipes
|
|
5
5
|
option :environment, short: "e", long: "environment", description: "Name or id of environment", argument: "environment"
|
6
6
|
|
7
7
|
switch :main, short: "m", long: "main", description: "Apply main recipes only"
|
8
|
-
switch :custom, long: "custom", description: "Apply custom recipes only"
|
8
|
+
switch :custom, short: "u", long: "custom", description: "Apply custom recipes only"
|
9
9
|
switch :quick, short: "q", long: "quick", description: "Quick chef run"
|
10
10
|
switch :full, short: "f", long: "full", description: "Run main and custom chef"
|
11
11
|
|
12
12
|
def handle
|
13
|
+
validate_run_type_flags
|
14
|
+
|
13
15
|
operator, environment = core_operator_and_environment_for(options)
|
14
16
|
raise "Unable to find matching environment" unless environment
|
15
17
|
|
16
|
-
run_type = if switch_active?(:main)
|
17
|
-
"main"
|
18
|
-
elsif switch_active?(:custom)
|
19
|
-
"custom"
|
20
|
-
elsif switch_active?(:quick)
|
21
|
-
"quick"
|
22
|
-
elsif switch_active?(:full)
|
23
|
-
"main"
|
24
|
-
else
|
25
|
-
"main"
|
26
|
-
end
|
27
|
-
|
28
18
|
run_chef(run_type, environment)
|
29
19
|
|
30
20
|
if switch_active?(:full)
|
31
21
|
run_chef("custom", environment)
|
32
22
|
end
|
33
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def validate_run_type_flags
|
27
|
+
if active_run_type_flags.length > 1
|
28
|
+
kernel.abort(
|
29
|
+
'Only one of --main, --custom, --quick, and --full may be specified.'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def run_type
|
35
|
+
secondary_run_types[active_run_type] || default_run_type
|
36
|
+
end
|
37
|
+
|
38
|
+
def active_run_type
|
39
|
+
active_run_type_flags.first
|
40
|
+
end
|
41
|
+
|
42
|
+
def active_run_type_flags
|
43
|
+
[:main, :custom, :quick, :full].select {|switch| switch_active?(switch)}
|
44
|
+
end
|
45
|
+
|
46
|
+
def secondary_run_types
|
47
|
+
{
|
48
|
+
custom: 'custom',
|
49
|
+
quick: 'quick'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def default_run_type
|
54
|
+
'main'
|
55
|
+
end
|
34
56
|
end
|
data/lib/ey-core/cli/ssh.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ey-core/cli/helpers/server_sieve'
|
2
|
+
|
1
3
|
class Ey::Core::Cli::Ssh < Ey::Core::Cli::Subcommand
|
2
4
|
title "ssh"
|
3
5
|
summary "Open an SSH session to the environment's application master"
|
@@ -27,8 +29,6 @@ class Ey::Core::Cli::Ssh < Ey::Core::Cli::Subcommand
|
|
27
29
|
user = environment.username
|
28
30
|
servers = []
|
29
31
|
|
30
|
-
|
31
|
-
|
32
32
|
if option(:command)
|
33
33
|
if shell = option(:shell)
|
34
34
|
cmd = Escape.shell_command([shell,'-lc',cmd])
|
@@ -40,29 +40,14 @@ class Ey::Core::Cli::Ssh < Ey::Core::Cli::Subcommand
|
|
40
40
|
puts "sudo commands often need a tty to run correctly. Use -t option to spawn a tty.".yellow
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
if switch_active?(:db_servers)
|
52
|
-
servers += (environment.servers.all(role: "db_master") + environment.servers.all(role: "db_slave") + environment.servers.all(role: "solo")).to_a
|
53
|
-
end
|
54
|
-
|
55
|
-
if switch_active?(:db_master)
|
56
|
-
servers += (environment.servers.all(role: "db_master") + environment.servers.all(role: "solo")).to_a
|
57
|
-
end
|
58
|
-
|
59
|
-
if utils = option(:utilities)
|
60
|
-
if utils == 'all'
|
61
|
-
servers += environment.servers.all(role: "util").to_a
|
62
|
-
else
|
63
|
-
servers += environment.servers.all(role: "util", name: utils).to_a
|
64
|
-
end
|
65
|
-
end
|
43
|
+
servers += Ey::Core::Cli::Helpers::ServerSieve.filter(
|
44
|
+
environment.servers,
|
45
|
+
all: switch_active?(:all),
|
46
|
+
app_servers: switch_active?(:app_servers),
|
47
|
+
db_servers: switch_active?(:db_servers),
|
48
|
+
db_master: switch_active?(:db_master),
|
49
|
+
utilities: option(:utilities)
|
50
|
+
)
|
66
51
|
else
|
67
52
|
if option(:bind_address)
|
68
53
|
ssh_opts += ["-L", option(:bind_address)]
|
@@ -79,6 +64,8 @@ class Ey::Core::Cli::Ssh < Ey::Core::Cli::Subcommand
|
|
79
64
|
abort "Unable to find any matching servers. Aborting.".red
|
80
65
|
end
|
81
66
|
|
67
|
+
servers.uniq!
|
68
|
+
|
82
69
|
servers.each do |server|
|
83
70
|
host = server.public_hostname
|
84
71
|
name = server.name ? "#{server.role} (#{server.name})" : server.role
|
data/lib/ey-core/version.rb
CHANGED
@@ -0,0 +1,226 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ey-core/cli/helpers/server_sieve'
|
3
|
+
|
4
|
+
module Ey
|
5
|
+
module Core
|
6
|
+
module Cli
|
7
|
+
module Helpers
|
8
|
+
describe ServerSieve do
|
9
|
+
# Set up individual servers
|
10
|
+
let(:app_master_server) {Object.new}
|
11
|
+
let(:app_slave_server) {Object.new}
|
12
|
+
let(:solo_server) {Object.new}
|
13
|
+
let(:db_master_server) {Object.new}
|
14
|
+
let(:db_slave_server) {Object.new}
|
15
|
+
let(:util_frank_server) {Object.new}
|
16
|
+
let(:util_johnny_server) {Object.new}
|
17
|
+
|
18
|
+
# Set up server groups
|
19
|
+
let(:all_apps) {[app_master_server, app_slave_server, solo_server]}
|
20
|
+
let(:all_db_master) {[db_master_server, solo_server]}
|
21
|
+
let(:all_dbs) {[db_master_server, db_slave_server, solo_server]}
|
22
|
+
let(:all_utils) {[util_frank_server, util_johnny_server]}
|
23
|
+
let(:all_servers) {all_apps + all_dbs + all_utils}
|
24
|
+
|
25
|
+
# Set up the upstream servers API
|
26
|
+
let(:servers_api) {Object.new}
|
27
|
+
before(:each) do
|
28
|
+
allow(servers_api).
|
29
|
+
to receive(:all).
|
30
|
+
with(no_args).
|
31
|
+
and_return(all_servers)
|
32
|
+
|
33
|
+
allow(servers_api).
|
34
|
+
to receive(:all).
|
35
|
+
with(role: 'app_master').
|
36
|
+
and_return([app_master_server])
|
37
|
+
|
38
|
+
allow(servers_api).
|
39
|
+
to receive(:all).
|
40
|
+
with(role: 'solo').
|
41
|
+
and_return([solo_server])
|
42
|
+
|
43
|
+
allow(servers_api).
|
44
|
+
to receive(:all).
|
45
|
+
with(role: 'app').
|
46
|
+
and_return([app_slave_server])
|
47
|
+
|
48
|
+
allow(servers_api).
|
49
|
+
to receive(:all).
|
50
|
+
with(role: 'db_master').
|
51
|
+
and_return([db_master_server])
|
52
|
+
|
53
|
+
allow(servers_api).
|
54
|
+
to receive(:all).
|
55
|
+
with(role: 'solo').
|
56
|
+
and_return([solo_server])
|
57
|
+
|
58
|
+
allow(servers_api).
|
59
|
+
to receive(:all).
|
60
|
+
with(role: 'db_slave').
|
61
|
+
and_return([db_slave_server])
|
62
|
+
|
63
|
+
allow(servers_api).
|
64
|
+
to receive(:all).
|
65
|
+
with(role: 'db_master').
|
66
|
+
and_return([db_master_server])
|
67
|
+
|
68
|
+
allow(servers_api).
|
69
|
+
to receive(:all).
|
70
|
+
with(role: 'solo').
|
71
|
+
and_return([solo_server])
|
72
|
+
|
73
|
+
allow(servers_api).
|
74
|
+
to receive(:all).
|
75
|
+
with(role: 'db_slave').
|
76
|
+
and_return([db_slave_server])
|
77
|
+
|
78
|
+
allow(servers_api).
|
79
|
+
to receive(:all).
|
80
|
+
with(role: 'util').
|
81
|
+
and_return(all_utils)
|
82
|
+
|
83
|
+
allow(servers_api).
|
84
|
+
to receive(:all).
|
85
|
+
with(role: 'util', name: 'frank').
|
86
|
+
and_return([util_frank_server])
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '.filter' do
|
91
|
+
let(:dummy) {Object.new}
|
92
|
+
let(:options) {{foo: 'bar'}}
|
93
|
+
let(:filtered) {['servers bruh']}
|
94
|
+
|
95
|
+
it 'is the same as creating a new sieve and filtering it' do
|
96
|
+
expect(described_class).
|
97
|
+
to receive(:new).
|
98
|
+
with(servers_api, options).
|
99
|
+
and_return(dummy)
|
100
|
+
|
101
|
+
expect(dummy).
|
102
|
+
to receive(:filtered).
|
103
|
+
and_return(filtered)
|
104
|
+
|
105
|
+
expect(described_class.filter(servers_api, options)).
|
106
|
+
to eql(filtered)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#filtered' do
|
111
|
+
let(:options) {{}}
|
112
|
+
let(:sieve) {described_class.new(servers_api, options)}
|
113
|
+
let(:filtered_servers) {sieve.filtered}
|
114
|
+
|
115
|
+
context 'when all servers are requested' do
|
116
|
+
let(:options) {{all: true}}
|
117
|
+
|
118
|
+
it 'is all of the servers known to the server api' do
|
119
|
+
all_servers.each do |server|
|
120
|
+
expect(filtered_servers).to include(server)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when app servers are requested' do
|
126
|
+
let(:options) {{app_servers: true}}
|
127
|
+
|
128
|
+
it 'includes app_master servers' do
|
129
|
+
expect(filtered_servers).to include(app_master_server)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'includes app (slave) servers' do
|
133
|
+
expect(filtered_servers).to include(app_slave_server)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'includes solo servers' do
|
137
|
+
expect(filtered_servers).to include(solo_server)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'when db servers are requested' do
|
142
|
+
let(:options) {{db_servers: true}}
|
143
|
+
|
144
|
+
it 'includes db_master servers' do
|
145
|
+
expect(filtered_servers).to include(db_master_server)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'includes db_slave servers' do
|
149
|
+
expect(filtered_servers).to include(db_slave_server)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'includes solo servers' do
|
153
|
+
expect(filtered_servers).to include(solo_server)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'when db master is requested' do
|
158
|
+
let(:options) {{db_master: true}}
|
159
|
+
|
160
|
+
it 'includes db_master servers' do
|
161
|
+
expect(filtered_servers).to include(db_master_server)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'includes solo servers' do
|
165
|
+
expect(filtered_servers).to include(solo_server)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'excludes db_slave servers' do
|
169
|
+
expect(filtered_servers).not_to include(db_slave_server)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'when all utils are requested' do
|
174
|
+
let(:options) {{utilities: 'all'}}
|
175
|
+
|
176
|
+
it 'includes all utility servers' do
|
177
|
+
all_utils.each do |server|
|
178
|
+
expect(filtered_servers).to include(server)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'when a specific util is requested' do
|
184
|
+
let(:options) {{utilities: 'frank'}}
|
185
|
+
|
186
|
+
it 'includes the requested util' do
|
187
|
+
expect(filtered_servers).to include(util_frank_server)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'excludes all other utils' do
|
191
|
+
expect(filtered_servers).not_to include(util_johnny_server)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context 'when multiple filters are active' do
|
196
|
+
|
197
|
+
# Release the Kraken!
|
198
|
+
let(:options) {
|
199
|
+
{
|
200
|
+
all: true,
|
201
|
+
app_servers: true,
|
202
|
+
db_servers: true,
|
203
|
+
db_master: true,
|
204
|
+
utilities: 'all'
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
it 'contains no duplicates' do
|
209
|
+
all_servers.each do |server|
|
210
|
+
count = filtered_servers.select {|item| item == server}.length
|
211
|
+
expect(count).to eql(1)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'when no filters are provided' do
|
217
|
+
it 'is empty' do
|
218
|
+
expect(filtered_servers).to be_empty
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
require 'belafonte'
|
4
|
+
require 'ey-core/cli'
|
5
|
+
require 'ey-core/cli/subcommand'
|
6
|
+
require 'ey-core/cli/recipes'
|
7
|
+
require 'ey-core/cli/recipes/apply'
|
8
|
+
|
9
|
+
describe Ey::Core::Cli::Recipes::Apply do
|
10
|
+
set_up_cli
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
allow_any_instance_of(described_class).
|
14
|
+
to receive(:core_operator_and_environment_for).
|
15
|
+
with(any_args).
|
16
|
+
and_return([operator, environment])
|
17
|
+
|
18
|
+
allow_any_instance_of(described_class).
|
19
|
+
to receive(:run_chef).
|
20
|
+
with(any_args).
|
21
|
+
and_return(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'ey-core recipes apply --main' do
|
25
|
+
let(:argv) {['--main']}
|
26
|
+
|
27
|
+
it 'performs a main chef run' do
|
28
|
+
expect(cli).to receive(:run_chef).with('main', environment)
|
29
|
+
|
30
|
+
execute
|
31
|
+
expect(kernel.exit_status).to eql(0)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'ey-core recipes apply --custom' do
|
36
|
+
let(:argv) {['--custom']}
|
37
|
+
|
38
|
+
it 'performs a custom chef run' do
|
39
|
+
expect(cli).to receive(:run_chef).with('custom', environment)
|
40
|
+
|
41
|
+
execute
|
42
|
+
expect(kernel.exit_status).to eql(0)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'ey-core recipes apply --quick' do
|
47
|
+
let(:argv) {['--quick']}
|
48
|
+
|
49
|
+
it 'performs a quick chef run' do
|
50
|
+
expect(cli).to receive(:run_chef).with('quick', environment)
|
51
|
+
|
52
|
+
execute
|
53
|
+
expect(kernel.exit_status).to eql(0)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'ey-core recipes apply --full' do
|
58
|
+
let(:argv) {['--full']}
|
59
|
+
|
60
|
+
it 'performs both a main and a custom chef run' do
|
61
|
+
expect(cli).to receive(:run_chef).with('main', environment)
|
62
|
+
expect(cli).to receive(:run_chef).with('custom', environment)
|
63
|
+
|
64
|
+
execute
|
65
|
+
expect(kernel.exit_status).to eql(0)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'attempting to use more than one run type flag' do
|
70
|
+
let(:run_type_flags) {['--main', '--custom', '--quick', '--full']}
|
71
|
+
let(:combinations) {run_type_flags.combination(2).to_a}
|
72
|
+
|
73
|
+
it 'aborts with advice regarding the run type flags' do
|
74
|
+
expect(kernel).
|
75
|
+
to receive(:abort).
|
76
|
+
with('Only one of --main, --custom, --quick, and --full may be specified.').
|
77
|
+
and_call_original.
|
78
|
+
exactly(combinations.length).
|
79
|
+
times
|
80
|
+
|
81
|
+
combinations.each do |combination|
|
82
|
+
attempt = described_class.new(combination, stdin, stdout, stderr, kernel)
|
83
|
+
|
84
|
+
expect(attempt.execute!).not_to eql(0)
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def set_up_cli
|
2
|
+
let(:argv) {[]}
|
3
|
+
let(:stdout) {StringIO.new}
|
4
|
+
let(:stderr) {StringIO.new}
|
5
|
+
let(:stdin) {StringIO.new}
|
6
|
+
let(:kernel) {FakeKernel.new}
|
7
|
+
let(:cli) {described_class.new(argv, stdin, stdout, stderr, kernel)}
|
8
|
+
let(:execute) {cli.execute!}
|
9
|
+
let(:operator) {Object.new}
|
10
|
+
let(:environment) {Object.new}
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class FakeKernel
|
2
|
+
attr_reader :exit_status
|
3
|
+
|
4
|
+
def system(*args)
|
5
|
+
system_commands.push(args.join(' '))
|
6
|
+
end
|
7
|
+
|
8
|
+
def system_commands
|
9
|
+
@system_commands ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def abort(msg)
|
13
|
+
self.exit(false)
|
14
|
+
#exit(false)
|
15
|
+
end
|
16
|
+
|
17
|
+
def exit(whatevs)
|
18
|
+
whatevs = -1 unless whatevs.is_a?(Integer)
|
19
|
+
@exit_status ||= whatevs
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: highline
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: mime-types
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -300,6 +314,7 @@ extensions: []
|
|
300
314
|
extra_rdoc_files: []
|
301
315
|
files:
|
302
316
|
- ".gitignore"
|
317
|
+
- ".ruby-gemset"
|
303
318
|
- ".ruby-version"
|
304
319
|
- ".travis.yml"
|
305
320
|
- CHANGELOG.md
|
@@ -320,10 +335,12 @@ files:
|
|
320
335
|
- lib/ey-core/cli/deploy.rb
|
321
336
|
- lib/ey-core/cli/environments.rb
|
322
337
|
- lib/ey-core/cli/errors.rb
|
338
|
+
- lib/ey-core/cli/helpers/server_sieve.rb
|
323
339
|
- lib/ey-core/cli/init.rb
|
324
340
|
- lib/ey-core/cli/login.rb
|
325
341
|
- lib/ey-core/cli/logout.rb
|
326
342
|
- lib/ey-core/cli/logs.rb
|
343
|
+
- lib/ey-core/cli/main.rb
|
327
344
|
- lib/ey-core/cli/recipes.rb
|
328
345
|
- lib/ey-core/cli/recipes/apply.rb
|
329
346
|
- lib/ey-core/cli/recipes/download.rb
|
@@ -685,6 +702,8 @@ files:
|
|
685
702
|
- spec/deployments_spec.rb
|
686
703
|
- spec/environment_plan_usage_spec.rb
|
687
704
|
- spec/environments_spec.rb
|
705
|
+
- spec/ey-core/cli/helpers/server_sieve_spec.rb
|
706
|
+
- spec/ey-core/cli/recipes/apply_spec.rb
|
688
707
|
- spec/features_spec.rb
|
689
708
|
- spec/firewalls_spec.rb
|
690
709
|
- spec/gems_spec.rb
|
@@ -713,9 +732,11 @@ files:
|
|
713
732
|
- spec/storages_spec.rb
|
714
733
|
- spec/support/account_helper.rb
|
715
734
|
- spec/support/alert_helper.rb
|
735
|
+
- spec/support/cli_helpers.rb
|
716
736
|
- spec/support/client_helper.rb
|
717
737
|
- spec/support/core.rb
|
718
738
|
- spec/support/coverage.rb
|
739
|
+
- spec/support/fake_kernel.rb
|
719
740
|
- spec/support/resource_helper.rb
|
720
741
|
- spec/support/timecop.rb
|
721
742
|
- spec/support_trial_spec.rb
|
@@ -742,7 +763,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
742
763
|
version: '0'
|
743
764
|
requirements: []
|
744
765
|
rubyforge_project:
|
745
|
-
rubygems_version: 2.
|
766
|
+
rubygems_version: 2.5.1
|
746
767
|
signing_key:
|
747
768
|
specification_version: 4
|
748
769
|
summary: Client library providing real and mock functionality for accessing Engine
|
@@ -769,6 +790,8 @@ test_files:
|
|
769
790
|
- spec/deployments_spec.rb
|
770
791
|
- spec/environment_plan_usage_spec.rb
|
771
792
|
- spec/environments_spec.rb
|
793
|
+
- spec/ey-core/cli/helpers/server_sieve_spec.rb
|
794
|
+
- spec/ey-core/cli/recipes/apply_spec.rb
|
772
795
|
- spec/features_spec.rb
|
773
796
|
- spec/firewalls_spec.rb
|
774
797
|
- spec/gems_spec.rb
|
@@ -797,9 +820,11 @@ test_files:
|
|
797
820
|
- spec/storages_spec.rb
|
798
821
|
- spec/support/account_helper.rb
|
799
822
|
- spec/support/alert_helper.rb
|
823
|
+
- spec/support/cli_helpers.rb
|
800
824
|
- spec/support/client_helper.rb
|
801
825
|
- spec/support/core.rb
|
802
826
|
- spec/support/coverage.rb
|
827
|
+
- spec/support/fake_kernel.rb
|
803
828
|
- spec/support/resource_helper.rb
|
804
829
|
- spec/support/timecop.rb
|
805
830
|
- spec/support_trial_spec.rb
|