opsicle 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/opsicle +10 -0
- data/lib/opsicle/commands.rb +1 -0
- data/lib/opsicle/commands/ssh.rb +4 -1
- data/lib/opsicle/commands/user_profile_info.rb +21 -0
- data/lib/opsicle/user_profile.rb +30 -0
- data/lib/opsicle/version.rb +1 -1
- data/spec/opsicle/commands/ssh_spec.rb +3 -2
- data/spec/opsicle/commands/user_profile_info_spec.rb +33 -0
- data/spec/opsicle/user_profile_spec.rb +50 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93b0ea1f860c25fc05de3ba8bb1b88ea62e3a96f
|
4
|
+
data.tar.gz: 2c8d8ad2a5aa2c9433b11e456612c6128505f5dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5febed7681d8adb153cf3c09242526a0f070ca5e577d12499d4bb52503eb61ba618511db499bf254502c7c8766bf88031a85c6ab34360b70d780ca86c6dcda64
|
7
|
+
data.tar.gz: 13e4c19365c7200c822124ef5958e4ba5973f2d14877614e07e0cab523b23534093c024223945e9c2709365272dd8da475ec69e150028a9885247cdff5fbe445
|
data/bin/opsicle
CHANGED
@@ -208,4 +208,14 @@ command 'update' do |c|
|
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
|
+
desc "Display IAM user profile information as JSON."
|
212
|
+
arg_name '<environment>'
|
213
|
+
command 'user-profile-info' do |c|
|
214
|
+
c.action do |global_options, options, args|
|
215
|
+
$color = false
|
216
|
+
raise ArgumentError, "Environment is required" unless (environment = args.first)
|
217
|
+
Opsicle::UserProfileInfo.new(environment).execute
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
211
221
|
exit run(ARGV)
|
data/lib/opsicle/commands.rb
CHANGED
data/lib/opsicle/commands/ssh.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "opsicle/user_profile"
|
2
|
+
|
1
3
|
module Opsicle
|
2
4
|
class SSH
|
3
5
|
attr_reader :client
|
@@ -5,6 +7,7 @@ module Opsicle
|
|
5
7
|
def initialize(environment)
|
6
8
|
@client = Client.new(environment)
|
7
9
|
@stack = Opsicle::Stack.new(@client)
|
10
|
+
@user_profile = Opsicle::UserProfile.new(@client)
|
8
11
|
end
|
9
12
|
|
10
13
|
def execute(options={})
|
@@ -37,7 +40,7 @@ module Opsicle
|
|
37
40
|
end
|
38
41
|
|
39
42
|
def ssh_username
|
40
|
-
|
43
|
+
@user_profile.ssh_username
|
41
44
|
end
|
42
45
|
|
43
46
|
def ssh_command(instance, options={})
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "json"
|
2
|
+
require "opsicle/user_profile"
|
3
|
+
|
4
|
+
module Opsicle
|
5
|
+
class UserProfileInfo
|
6
|
+
attr_reader :client
|
7
|
+
|
8
|
+
def initialize(environment)
|
9
|
+
@client = Client.new(environment)
|
10
|
+
@user_profile = UserProfile.new(@client)
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(options={})
|
14
|
+
Output.say output.to_json
|
15
|
+
end
|
16
|
+
|
17
|
+
def output
|
18
|
+
@user_profile.attributes
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Opsicle
|
2
|
+
class UserProfile
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def ssh_username
|
10
|
+
attributes.fetch(:ssh_username)
|
11
|
+
end
|
12
|
+
|
13
|
+
def iam_username
|
14
|
+
attributes.fetch(:name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def public_key
|
18
|
+
attributes.fetch(:ssh_public_key)
|
19
|
+
end
|
20
|
+
|
21
|
+
def arn
|
22
|
+
attributes.fetch(:iam_user_arn)
|
23
|
+
end
|
24
|
+
|
25
|
+
def attributes
|
26
|
+
@attributes ||= client.api_call(:describe_my_user_profile)[:user_profile]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/opsicle/version.rb
CHANGED
@@ -6,10 +6,12 @@ module Opsicle
|
|
6
6
|
subject { SSH.new('derp') }
|
7
7
|
let(:client) { double(config: double(opsworks_config: {stack_id: "1234"})) }
|
8
8
|
let(:stack) { double(client: client) }
|
9
|
+
let(:user_profile) { double }
|
9
10
|
let(:api_call) { double }
|
10
11
|
before do
|
11
12
|
allow(Client).to receive(:new).with('derp').and_return(client)
|
12
13
|
allow(Stack).to receive(:new).with(client).and_return(stack)
|
14
|
+
allow(UserProfile).to receive(:new).with(client).and_return(user_profile)
|
13
15
|
end
|
14
16
|
|
15
17
|
context "#execute" do
|
@@ -104,8 +106,7 @@ module Opsicle
|
|
104
106
|
|
105
107
|
context "#ssh_username" do
|
106
108
|
it "makes a describe_my_user_profile API call" do
|
107
|
-
allow(
|
108
|
-
.and_return({user_profile: {:ssh_username => "captkirk01"}})
|
109
|
+
allow(user_profile).to receive(:ssh_username).and_return("captkirk01")
|
109
110
|
expect(subject.ssh_username).to eq("captkirk01")
|
110
111
|
end
|
111
112
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "opsicle"
|
3
|
+
|
4
|
+
module Opsicle
|
5
|
+
describe UserProfileInfo do
|
6
|
+
subject { UserProfileInfo.new(env) }
|
7
|
+
|
8
|
+
let(:env) { "example" }
|
9
|
+
let(:client) { double("Client") }
|
10
|
+
let(:user_profile) { double("UserProfile", attributes: {foo: "bar"}) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(Client).to receive(:new).with(env).and_return(client)
|
14
|
+
allow(UserProfile).to receive(:new).with(client).and_return(user_profile)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "#execute" do
|
18
|
+
it "renders its output as JSON" do
|
19
|
+
allow(subject).to receive(:output).and_return(user_profile.attributes)
|
20
|
+
|
21
|
+
expect(Output).to receive(:say).with(user_profile.attributes.to_json)
|
22
|
+
|
23
|
+
subject.execute
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "#output" do
|
28
|
+
it "returns the profile's attributes" do
|
29
|
+
expect(subject.output).to eq(user_profile.attributes)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "opsicle/user_profile"
|
3
|
+
|
4
|
+
module Opsicle
|
5
|
+
describe UserProfile do
|
6
|
+
subject { UserProfile.new client }
|
7
|
+
|
8
|
+
let(:client) { double("Opsicle::Client") }
|
9
|
+
|
10
|
+
let(:ssh_username) { double }
|
11
|
+
let(:iam_username) { double }
|
12
|
+
let(:public_key) { double }
|
13
|
+
let(:arn) { double }
|
14
|
+
|
15
|
+
before do
|
16
|
+
allow(client).to receive(:api_call).with(:describe_my_user_profile).and_return({
|
17
|
+
user_profile: {
|
18
|
+
iam_user_arn: arn,
|
19
|
+
name: iam_username,
|
20
|
+
ssh_username: ssh_username,
|
21
|
+
ssh_public_key: public_key,
|
22
|
+
}
|
23
|
+
})
|
24
|
+
end
|
25
|
+
|
26
|
+
context "#ssh_username" do
|
27
|
+
it "returns the IAM profile's SSH username" do
|
28
|
+
expect(subject.ssh_username).to eq(ssh_username)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "#iam_username" do
|
33
|
+
it "returns the IAM profile's AWS username" do
|
34
|
+
expect(subject.iam_username).to eq(iam_username)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "#public_key" do
|
39
|
+
it "returns the IAM profile's SSH public key" do
|
40
|
+
expect(subject.public_key).to eq(public_key)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "#arn" do
|
45
|
+
it "returns the IAM profile's ARN ID" do
|
46
|
+
expect(subject.arn).to eq(arn)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opsicle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Fleener
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/opsicle/commands/ssh_clean_keys.rb
|
202
202
|
- lib/opsicle/commands/ssh_key.rb
|
203
203
|
- lib/opsicle/commands/update.rb
|
204
|
+
- lib/opsicle/commands/user_profile_info.rb
|
204
205
|
- lib/opsicle/config.rb
|
205
206
|
- lib/opsicle/deploy_helper.rb
|
206
207
|
- lib/opsicle/deployment.rb
|
@@ -224,6 +225,7 @@ files:
|
|
224
225
|
- lib/opsicle/output.rb
|
225
226
|
- lib/opsicle/s3_bucket.rb
|
226
227
|
- lib/opsicle/stack.rb
|
228
|
+
- lib/opsicle/user_profile.rb
|
227
229
|
- lib/opsicle/version.rb
|
228
230
|
- spec/opsicle/client_spec.rb
|
229
231
|
- spec/opsicle/commands/chef_update_spec.rb
|
@@ -234,6 +236,7 @@ files:
|
|
234
236
|
- spec/opsicle/commands/ssh_key_spec.rb
|
235
237
|
- spec/opsicle/commands/ssh_spec.rb
|
236
238
|
- spec/opsicle/commands/update_spec.rb
|
239
|
+
- spec/opsicle/commands/user_profile_info_spec.rb
|
237
240
|
- spec/opsicle/config_spec.rb
|
238
241
|
- spec/opsicle/errors_spec.rb
|
239
242
|
- spec/opsicle/instances_spec.rb
|
@@ -245,6 +248,7 @@ files:
|
|
245
248
|
- spec/opsicle/monitor/subpanel_spec.rb
|
246
249
|
- spec/opsicle/output_spec.rb
|
247
250
|
- spec/opsicle/s3_bucket_spec.rb
|
251
|
+
- spec/opsicle/user_profile_spec.rb
|
248
252
|
- spec/spec_helper.rb
|
249
253
|
homepage: https://github.com/sportngin/opsicle
|
250
254
|
licenses:
|
@@ -266,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
270
|
version: '0'
|
267
271
|
requirements: []
|
268
272
|
rubyforge_project:
|
269
|
-
rubygems_version: 2.4.
|
273
|
+
rubygems_version: 2.4.2
|
270
274
|
signing_key:
|
271
275
|
specification_version: 4
|
272
276
|
summary: An opsworks specific abstraction on top of the aws sdk
|
@@ -280,6 +284,7 @@ test_files:
|
|
280
284
|
- spec/opsicle/commands/ssh_key_spec.rb
|
281
285
|
- spec/opsicle/commands/ssh_spec.rb
|
282
286
|
- spec/opsicle/commands/update_spec.rb
|
287
|
+
- spec/opsicle/commands/user_profile_info_spec.rb
|
283
288
|
- spec/opsicle/config_spec.rb
|
284
289
|
- spec/opsicle/errors_spec.rb
|
285
290
|
- spec/opsicle/instances_spec.rb
|
@@ -291,4 +296,5 @@ test_files:
|
|
291
296
|
- spec/opsicle/monitor/subpanel_spec.rb
|
292
297
|
- spec/opsicle/output_spec.rb
|
293
298
|
- spec/opsicle/s3_bucket_spec.rb
|
299
|
+
- spec/opsicle/user_profile_spec.rb
|
294
300
|
- spec/spec_helper.rb
|