engineyard-metadata 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +39 -39
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/ey_ssh_aliases +1 -1
- data/engineyard-metadata.gemspec +5 -2
- data/lib/engineyard-metadata.rb +3 -0
- data/lib/engineyard-metadata/amazon_ec2_api.rb +4 -4
- data/lib/engineyard-metadata/chef_dna.rb +25 -38
- data/lib/engineyard-metadata/engine_yard_cloud_api.rb +87 -47
- data/lib/engineyard-metadata/insider.rb +14 -8
- data/lib/engineyard-metadata/metadata.rb +24 -7
- data/lib/engineyard-metadata/outsider.rb +33 -49
- data/lib/engineyard-metadata/ssh_alias_helper.rb +1 -1
- data/spec/metadata_spec.rb +57 -53
- data/spec/spec_helper.rb +6 -7
- data/spec/support/dna.json +184 -119
- data/spec/support/dot.git.config +1 -1
- data/spec/support/engine_yard_cloud_api_response.json +33 -39
- metadata +23 -9
@@ -1,5 +1,5 @@
|
|
1
1
|
module EY
|
2
|
-
|
2
|
+
class Metadata
|
3
3
|
# This gets pulled in when you're running directly on a cloud instance.
|
4
4
|
module Insider
|
5
5
|
DELEGATED_TO_AMAZON_EC2_API = %w{
|
@@ -7,7 +7,7 @@ module EY
|
|
7
7
|
present_security_group
|
8
8
|
}
|
9
9
|
|
10
|
-
DELEGATED_TO_CHEF_DNA =
|
10
|
+
DELEGATED_TO_CHEF_DNA = METHODS - DELEGATED_TO_AMAZON_EC2_API
|
11
11
|
|
12
12
|
DELEGATED_TO_AMAZON_EC2_API.each do |name|
|
13
13
|
define_method name do
|
@@ -20,12 +20,7 @@ module EY
|
|
20
20
|
chef_dna.send name
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
|
-
def clear
|
25
|
-
@chef_dna = nil
|
26
|
-
@amazon_ec2_api = nil
|
27
|
-
end
|
28
|
-
|
23
|
+
|
29
24
|
# You can't get the list of environment names while you're on the instances themselves.
|
30
25
|
def environment_names
|
31
26
|
raise CannotGetFromHere
|
@@ -40,6 +35,17 @@ module EY
|
|
40
35
|
def amazon_ec2_api
|
41
36
|
@amazon_ec2_api ||= AmazonEc2Api.new
|
42
37
|
end
|
38
|
+
|
39
|
+
def app_name
|
40
|
+
return @app_name if @app_name.is_a? String
|
41
|
+
if ENV['EY_APP_NAME']
|
42
|
+
@app_name = ENV['EY_APP_NAME']
|
43
|
+
elsif Dir.pwd =~ %r{/data/([^/]+)/current} or Dir.pwd =~ %r{/data/([^/]+)/releases}
|
44
|
+
@app_name = $1
|
45
|
+
end
|
46
|
+
raise RuntimeError, "[engineyard-metadata gem] Please set EY.metadata.app_name= or set ENV['EY_APP_NAME']" unless @app_name.to_s.strip.length > 0
|
47
|
+
@app_name
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
@@ -1,11 +1,17 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
1
3
|
module EY
|
2
4
|
# All methods are defined on this module. For example, you're supposed to say
|
3
5
|
#
|
4
6
|
# EY::Metadata.database_username
|
5
7
|
#
|
6
8
|
# instead of trying to call it from a particular adapter.
|
7
|
-
|
8
|
-
|
9
|
+
class Metadata
|
10
|
+
include Singleton
|
11
|
+
|
12
|
+
attr_writer :app_name
|
13
|
+
|
14
|
+
METHODS = %w{
|
9
15
|
app_master
|
10
16
|
app_name
|
11
17
|
app_servers
|
@@ -34,7 +40,17 @@ module EY
|
|
34
40
|
ssh_username
|
35
41
|
stack_name
|
36
42
|
utilities
|
37
|
-
} unless defined?(
|
43
|
+
} unless defined?(METHODS)
|
44
|
+
|
45
|
+
# The path to the current deploy on app servers.
|
46
|
+
def current_path
|
47
|
+
"/data/#{app_name}/current"
|
48
|
+
end
|
49
|
+
|
50
|
+
# The path to the shared directory on app servers.
|
51
|
+
def shared_path
|
52
|
+
"/data/#{app_name}/shared"
|
53
|
+
end
|
38
54
|
|
39
55
|
# This gets raised when you can't get a particular piece of metadata from the execution environment you're in.
|
40
56
|
class CannotGetFromHere < RuntimeError
|
@@ -48,13 +64,14 @@ module EY
|
|
48
64
|
autoload :AmazonEc2Api, 'engineyard-metadata/amazon_ec2_api'
|
49
65
|
autoload :EngineYardCloudApi, 'engineyard-metadata/engine_yard_cloud_api'
|
50
66
|
|
51
|
-
def
|
67
|
+
def reload
|
52
68
|
if File.directory? '/var/log/engineyard'
|
53
|
-
|
69
|
+
Metadata.send :include, Insider
|
54
70
|
else
|
55
|
-
|
71
|
+
Metadata.send :include, Outsider
|
56
72
|
end
|
57
73
|
end
|
58
|
-
reload
|
59
74
|
end
|
60
75
|
end
|
76
|
+
|
77
|
+
EY.metadata.reload
|
@@ -2,13 +2,12 @@ require 'etc'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
module EY
|
5
|
-
|
5
|
+
class Metadata
|
6
6
|
# This gets pulled in when you're running from your developer machine (i.e., not on a cloud instance).
|
7
7
|
module Outsider
|
8
|
-
|
9
|
-
UNGETTABLE = KEYS.grep(/present/) + KEYS.grep(/password/) + KEYS.grep(/mysql/)
|
8
|
+
UNGETTABLE = METHODS.grep(/present/) + METHODS.grep(/password/) + METHODS.grep(/mysql/)
|
10
9
|
|
11
|
-
GETTABLE =
|
10
|
+
GETTABLE = METHODS - UNGETTABLE - %w{ environment_name }
|
12
11
|
|
13
12
|
UNGETTABLE.each do |name|
|
14
13
|
define_method name do
|
@@ -26,79 +25,64 @@ module EY
|
|
26
25
|
File.join File.expand_path("~#{Etc.getpwuid.name}"), '.eyrc'
|
27
26
|
end
|
28
27
|
|
29
|
-
def
|
30
|
-
|
28
|
+
def preset_app_name?
|
29
|
+
@app_name.is_a?(String) or ENV['EY_APP_NAME']
|
31
30
|
end
|
32
31
|
|
33
|
-
def
|
34
|
-
@
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
def app_name
|
33
|
+
return @app_name if @app_name.is_a?(String)
|
34
|
+
if ENV['EY_APP_NAME']
|
35
|
+
@app_name = ENV['EY_APP_NAME']
|
36
|
+
elsif engine_yard_cloud_api.possible_to_detect_app_from_environment_name?
|
37
|
+
@app_name = engine_yard_cloud_api.app_name
|
38
|
+
elsif engine_yard_cloud_api.possible_to_detect_app_from_git_config?
|
39
|
+
@app_name = engine_yard_cloud_api.app_name
|
40
|
+
end
|
41
|
+
@app_name
|
38
42
|
end
|
39
43
|
|
44
|
+
def preset_environment_name?
|
45
|
+
@environment_name.is_a?(String) or ENV['EY_ENVIRONMENT_NAME']
|
46
|
+
end
|
47
|
+
|
48
|
+
# Sets the environment you want, in case it can't be detected from ENV['EY_ENVIRONMENT_NAME'] or .git/config
|
40
49
|
def environment_name=(str)
|
41
|
-
# clear this out in case it was inferred
|
42
|
-
@repository_uri = nil
|
43
|
-
# clear this out in case we're looking up a new environment
|
44
|
-
@engine_yard_cloud_api = nil
|
45
50
|
@environment_name = str
|
46
51
|
end
|
47
52
|
|
48
53
|
# The name of the EngineYard AppCloud environment.
|
49
54
|
def environment_name
|
50
55
|
return @environment_name if @environment_name.is_a? String
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
ENV['EY_ENVIRONMENT_NAME']
|
56
|
+
if ENV['EY_ENVIRONMENT_NAME']
|
57
|
+
@environment_name = ENV['EY_ENVIRONMENT_NAME']
|
58
|
+
elsif engine_yard_cloud_api.possible_to_detect_environment_from_git_config?
|
59
|
+
@environment_name = engine_yard_cloud_api.environment_name
|
56
60
|
end
|
57
|
-
raise RuntimeError, "[engineyard-metadata gem] You need to run this from the application repo, set EY
|
61
|
+
raise RuntimeError, "[engineyard-metadata gem] You need to run this from the application repo, set EY.metadata.environment_name= or set ENV['EY_ENVIRONMENT_NAME']" unless @environment_name.to_s.strip.length > 0
|
58
62
|
@environment_name
|
59
63
|
end
|
60
64
|
|
65
|
+
# Sets the (secret) cloud token, in case it's not in ENV['EY_CLOUD_TOKEN'] or ~/.eyrc
|
61
66
|
def ey_cloud_token=(str)
|
62
|
-
|
63
|
-
@repository_uri = nil
|
64
|
-
# clear this out in case we're looking up a new environment
|
65
|
-
@engine_yard_cloud_api = nil
|
67
|
+
@engine_yard_cloud_api = nil # because it depends on cloud token
|
66
68
|
@ey_cloud_token = str
|
67
69
|
end
|
68
|
-
|
70
|
+
|
69
71
|
# The secret API token to access https://cloud.engineyard.com
|
70
72
|
def ey_cloud_token
|
71
73
|
return @ey_cloud_token if @ey_cloud_token.is_a? String
|
72
|
-
|
73
|
-
ENV['EY_CLOUD_TOKEN']
|
74
|
+
if ENV['EY_CLOUD_TOKEN']
|
75
|
+
@ey_cloud_token = ENV['EY_CLOUD_TOKEN']
|
74
76
|
elsif File.exist? eyrc_path
|
75
|
-
YAML.load(File.read(eyrc_path))['api_token']
|
77
|
+
@ey_cloud_token = YAML.load(File.read(eyrc_path))['api_token']
|
76
78
|
end
|
77
|
-
raise RuntimeError, "[engineyard-metadata gem] You need to have #{eyrc_path}, set EY
|
79
|
+
raise RuntimeError, "[engineyard-metadata gem] You need to have #{eyrc_path}, set EY.metadata.ey_cloud_token= or set ENV['EY_CLOUD_TOKEN']" unless @ey_cloud_token.to_s.strip.length > 0
|
78
80
|
@ey_cloud_token
|
79
81
|
end
|
80
|
-
|
81
|
-
# The URL that EngineYard has on file for your application.
|
82
|
-
#
|
83
|
-
# There's no setter for this because you should really use EY::Metadata.environment_name= or ENV['EY_ENVIRONMENT_NAME']
|
84
|
-
def repository_uri
|
85
|
-
return @repository_uri if @repository_uri.is_a? String
|
86
|
-
@repository_uri = if engine_yard_cloud_api.data_loaded?
|
87
|
-
engine_yard_cloud_api.repository_uri
|
88
|
-
elsif ENV['EY_REPOSITORY_URI']
|
89
|
-
ENV['EY_REPOSITORY_URI']
|
90
|
-
elsif File.exist? git_config_path
|
91
|
-
git_config = File.read git_config_path
|
92
|
-
git_config =~ /^\[remote.*?\burl = (.*?)\n/m
|
93
|
-
$1
|
94
|
-
end
|
95
|
-
raise RuntimeError, "[engineyard-metadata gem] Please set EY::Metadata.environment_name= or set ENV['EY_ENVIRONMENT_NAME']" unless @repository_uri.to_s.strip.length > 0
|
96
|
-
@repository_uri
|
97
|
-
end
|
98
82
|
|
99
83
|
# An adapter that reads from the public EngineYard Cloud API (https://cloud.engineyard.com)
|
100
84
|
def engine_yard_cloud_api
|
101
|
-
@engine_yard_cloud_api ||= EngineYardCloudApi.new
|
85
|
+
@engine_yard_cloud_api ||= EngineYardCloudApi.new ey_cloud_token
|
102
86
|
end
|
103
87
|
end
|
104
88
|
end
|
data/spec/metadata_spec.rb
CHANGED
@@ -2,181 +2,177 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
shared_examples_for "it does in all execution environments" do
|
4
4
|
it 'get the database username' do
|
5
|
-
EY
|
5
|
+
EY.metadata.database_username.should == 'deploy'
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'get the database name' do
|
9
|
-
EY
|
9
|
+
EY.metadata.database_name.should == 'cm1_certified_blue'
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'get the database host' do
|
13
|
-
EY
|
13
|
+
EY.metadata.database_host.should == 'ec2-67-202-19-255.compute-1.amazonaws.com'
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'get the ssh username' do
|
17
|
-
EY
|
17
|
+
EY.metadata.ssh_username.should == 'deploy'
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'get the app server hostnames' do
|
21
|
-
EY
|
21
|
+
EY.metadata.app_servers.should == ["ec2-174-129-212-130.compute-1.amazonaws.com"]
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'get the db server hostnames' do
|
25
|
-
EY
|
25
|
+
EY.metadata.db_servers.should == ["ec2-67-202-19-255.compute-1.amazonaws.com"]
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'get the utilities hostnames' do
|
29
|
-
EY
|
29
|
+
EY.metadata.utilities.should == []
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'get the app master hostname' do
|
33
|
-
EY
|
33
|
+
EY.metadata.app_master.should == 'ec2-174-129-212-130.compute-1.amazonaws.com'
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'get the db master hostname' do
|
37
|
-
EY
|
37
|
+
EY.metadata.db_master.should == 'ec2-67-202-19-255.compute-1.amazonaws.com'
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'get the db slave hostnames' do
|
41
|
-
EY
|
41
|
+
EY.metadata.db_slaves.should == []
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'get the app slave hostnames' do
|
45
|
-
EY
|
45
|
+
EY.metadata.app_slaves.should == []
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'get the solo hostname' do
|
49
|
-
EY
|
49
|
+
EY.metadata.solo.should == nil
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'get the environment name' do
|
53
|
-
EY
|
53
|
+
EY.metadata.environment_name.should == 'cm1_production_blue'
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'get the stack name' do
|
57
|
-
EY
|
57
|
+
EY.metadata.stack_name.should == 'nginx_unicorn'
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'get the repository URI' do
|
61
|
-
EY
|
61
|
+
EY.metadata.repository_uri.should == 'git@github.com:brighterplanet/cm1.git'
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'gets the app name' do
|
65
|
-
EY
|
65
|
+
EY.metadata.app_name.should == 'cm1_certified_blue'
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'gets the current path' do
|
69
|
-
EY
|
69
|
+
EY.metadata.current_path.should == '/data/cm1_certified_blue/current'
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'gets the shared path' do
|
73
|
-
EY
|
73
|
+
EY.metadata.shared_path.should == '/data/cm1_certified_blue/shared'
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'gets helpful ssh aliases' do
|
77
|
-
EY
|
77
|
+
EY.metadata.ssh_aliases.should =~ /Host cm1_production_blue-app_master\n Hostname ec2-174-129-212-130.compute-1.amazonaws.com/
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
shared_examples_for "it's executing outside the cloud" do
|
82
82
|
it 'gets the list of all environment names' do
|
83
|
-
EY
|
83
|
+
EY.metadata.environment_names.should == ["app1_production", "wlpf1_production", "data1_production", "cm1_production_red", "cm1_production_blue"]
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'not get the present instance ID' do
|
87
87
|
lambda {
|
88
|
-
EY
|
88
|
+
EY.metadata.present_instance_id
|
89
89
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'not get the present instance role (as a string)' do
|
93
93
|
lambda {
|
94
|
-
EY
|
94
|
+
EY.metadata.present_instance_role
|
95
95
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'not get the present public hostname' do
|
99
99
|
lambda {
|
100
|
-
EY
|
100
|
+
EY.metadata.present_public_hostname
|
101
101
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
102
102
|
end
|
103
103
|
|
104
104
|
it 'not get the present security group' do
|
105
105
|
lambda {
|
106
|
-
EY
|
106
|
+
EY.metadata.present_security_group
|
107
107
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'not get the database password' do
|
111
111
|
lambda {
|
112
|
-
EY
|
112
|
+
EY.metadata.database_password
|
113
113
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'not get the ssh password' do
|
117
117
|
lambda {
|
118
|
-
EY
|
118
|
+
EY.metadata.ssh_password
|
119
119
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'not get the mysql command' do
|
123
123
|
lambda {
|
124
|
-
EY
|
124
|
+
EY.metadata.mysql_command
|
125
125
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'not get the mysqldump command' do
|
129
129
|
lambda {
|
130
|
-
EY
|
130
|
+
EY.metadata.mysqldump_command
|
131
131
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
132
132
|
end
|
133
|
-
|
134
|
-
it 'get the raw EngineYard Cloud API data' do
|
135
|
-
EY::Metadata.engine_yard_cloud_api.data.should be_a(Hash)
|
136
|
-
end
|
137
133
|
end
|
138
134
|
|
139
135
|
shared_examples_for "it's executing inside the cloud" do
|
140
136
|
it 'not get the list of all environment names' do
|
141
137
|
lambda {
|
142
|
-
EY
|
138
|
+
EY.metadata.environment_names
|
143
139
|
}.should raise_error(EY::Metadata::CannotGetFromHere)
|
144
140
|
end
|
145
141
|
|
146
142
|
it 'get the present instance ID' do
|
147
|
-
EY
|
143
|
+
EY.metadata.present_instance_id.should == FAKE_INSTANCE_ID
|
148
144
|
end
|
149
145
|
|
150
146
|
it 'get the present instance role (as a string)' do
|
151
|
-
EY
|
147
|
+
EY.metadata.present_instance_role.should == 'app_master'
|
152
148
|
end
|
153
149
|
|
154
150
|
it 'get the present public hostname' do
|
155
|
-
EY
|
151
|
+
EY.metadata.present_public_hostname.should == 'ec2-174-129-212-130.compute-1.amazonaws.com'
|
156
152
|
end
|
157
153
|
|
158
154
|
it 'get the present security group' do
|
159
|
-
EY
|
155
|
+
EY.metadata.present_security_group.should == FAKE_SECURITY_GROUP
|
160
156
|
end
|
161
157
|
|
162
158
|
it 'get the database password' do
|
163
|
-
EY
|
159
|
+
EY.metadata.database_password.should == 'USERS-0-PASSWORD'
|
164
160
|
end
|
165
161
|
|
166
162
|
it 'get the ssh password' do
|
167
|
-
EY
|
163
|
+
EY.metadata.ssh_password.should == 'USERS-0-PASSWORD'
|
168
164
|
end
|
169
165
|
|
170
166
|
it 'get the mysql command' do
|
171
|
-
EY
|
167
|
+
EY.metadata.mysql_command.should =~ %r{mysql -h ec2-67-202-19-255.compute-1.amazonaws.com -u deploy -pUSERS-0-PASSWORD cm1_certified_blue}
|
172
168
|
end
|
173
169
|
|
174
170
|
it 'get the mysqldump command' do
|
175
|
-
EY
|
171
|
+
EY.metadata.mysqldump_command.should =~ %r{mysqldump -h ec2-67-202-19-255.compute-1.amazonaws.com -u deploy -pUSERS-0-PASSWORD cm1_certified_blue}
|
176
172
|
end
|
177
173
|
end
|
178
174
|
|
179
|
-
describe 'EY
|
175
|
+
describe 'EY.metadata' do
|
180
176
|
after do
|
181
177
|
stop_pretending
|
182
178
|
end
|
@@ -184,7 +180,8 @@ describe 'EY::Metadata' do
|
|
184
180
|
describe "being executed on an EngineYard AppCloud (i.e. Amazon EC2) instance" do
|
185
181
|
before do
|
186
182
|
pretend_we_are_on_an_engineyard_appcloud_ec2_instance
|
187
|
-
EY
|
183
|
+
EY.metadata.reload
|
184
|
+
EY.metadata.app_name = 'cm1_certified_blue'
|
188
185
|
end
|
189
186
|
it_should_behave_like "it does in all execution environments"
|
190
187
|
it_should_behave_like "it's executing inside the cloud"
|
@@ -193,34 +190,41 @@ describe 'EY::Metadata' do
|
|
193
190
|
describe "being executed from a developer/administrator's local machine" do
|
194
191
|
before do
|
195
192
|
pretend_we_are_on_a_developer_machine
|
196
|
-
EY
|
197
|
-
EY
|
193
|
+
EY.metadata.reload
|
194
|
+
EY.metadata.instance_variables.each do |ivar_name|
|
195
|
+
EY.metadata.instance_variable_set ivar_name, nil
|
196
|
+
end
|
198
197
|
ENV.delete 'EY_CLOUD_TOKEN'
|
199
198
|
ENV.delete 'EY_ENVIRONMENT_NAME'
|
199
|
+
ENV.delete 'EY_APP_NAME'
|
200
|
+
EY.metadata.app_name = 'cm1_certified_blue'
|
200
201
|
end
|
201
202
|
describe "controlled with environment variables" do
|
202
203
|
before do
|
204
|
+
EY.metadata.instance_variables.each do |ivar_name|
|
205
|
+
EY.metadata.instance_variable_set ivar_name, nil
|
206
|
+
end
|
203
207
|
ENV['EY_CLOUD_TOKEN'] = FAKE_CLOUD_TOKEN + 'aaa'
|
204
|
-
ENV['
|
205
|
-
EY
|
208
|
+
ENV['EY_APP_NAME'] = 'cm1_certified_blue'
|
209
|
+
EY.metadata.ey_cloud_token.should == FAKE_CLOUD_TOKEN + 'aaa' # sanity check
|
206
210
|
end
|
207
211
|
it_should_behave_like "it does in all execution environments"
|
208
212
|
it_should_behave_like "it's executing outside the cloud"
|
209
213
|
end
|
210
214
|
describe "controlled with attr writers" do
|
211
215
|
before do
|
212
|
-
EY
|
213
|
-
EY
|
214
|
-
EY
|
216
|
+
EY.metadata.ey_cloud_token = FAKE_CLOUD_TOKEN + 'bbb'
|
217
|
+
EY.metadata.app_name = 'cm1_certified_blue'
|
218
|
+
EY.metadata.ey_cloud_token.should == FAKE_CLOUD_TOKEN + 'bbb' # sanity check
|
215
219
|
end
|
216
220
|
it_should_behave_like "it does in all execution environments"
|
217
221
|
it_should_behave_like "it's executing outside the cloud"
|
218
222
|
end
|
219
223
|
describe "depending on .eyrc" do
|
220
224
|
before do
|
221
|
-
File.open(EY
|
222
|
-
EY
|
223
|
-
EY
|
225
|
+
File.open(EY.metadata.eyrc_path, 'w') { |f| f.write({'api_token' => FAKE_CLOUD_TOKEN + 'ccc'}.to_yaml) }
|
226
|
+
EY.metadata.environment_name = 'cm1_production_blue'
|
227
|
+
EY.metadata.ey_cloud_token.should == FAKE_CLOUD_TOKEN + 'ccc' # sanity check
|
224
228
|
end
|
225
229
|
it_should_behave_like "it does in all execution environments"
|
226
230
|
it_should_behave_like "it's executing outside the cloud"
|