opsicle 0.0.1 → 0.0.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.
data/Gemfile.lock CHANGED
@@ -1,14 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opsicle (0.0.1)
5
- aws-sdk
4
+ opsicle (0.0.2)
5
+ aws-sdk (~> 1.30)
6
6
  commander
7
+ terminal-table
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- aws-sdk (1.30.0)
12
+ aws-sdk (1.30.1)
12
13
  json (~> 1.4)
13
14
  nokogiri (>= 1.4.4)
14
15
  uuidtools (~> 2.1)
@@ -57,6 +58,7 @@ GEM
57
58
  diff-lcs (>= 1.1.3, < 2.0)
58
59
  rspec-mocks (2.14.4)
59
60
  slop (3.4.7)
61
+ terminal-table (1.4.5)
60
62
  thor (0.18.1)
61
63
  timers (1.1.0)
62
64
  uuidtools (2.1.4)
data/bin/opsicle CHANGED
@@ -17,3 +17,13 @@ command :deploy do |c|
17
17
  Opsicle::Deploy.new(args.first).execute
18
18
  end
19
19
  end
20
+
21
+ command :list do |c|
22
+ c.syntax = "opsicle list <environment>"
23
+ c.description = "List all apps the given environment"
24
+ c.action do |args, options|
25
+ raise ArgumentError, "Environment is required" unless args.first
26
+ Opsicle::List.new(args.first).execute
27
+ end
28
+
29
+ end
data/lib/opsicle.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require "opsicle/version"
2
2
  require "opsicle/deploy"
3
+ require "opsicle/list"
3
4
 
@@ -15,6 +15,10 @@ module Opsicle
15
15
  aws_client.create_deployment(command_options(command, options))
16
16
  end
17
17
 
18
+ def api_call(command, options={})
19
+ aws_client.send(command, options)
20
+ end
21
+
18
22
  def command_options(command, options={})
19
23
  config.opsworks_config.merge(options).merge({ command: { name: command } })
20
24
  end
@@ -0,0 +1,40 @@
1
+ require 'aws-sdk'
2
+ require 'terminal-table'
3
+ require_relative 'client'
4
+
5
+ module Opsicle
6
+ class List
7
+ attr_reader :client
8
+
9
+ def initialize(environment)
10
+ @client = Client.new(environment)
11
+ end
12
+
13
+ def execute
14
+ stack_ids = get_stacks
15
+ apps = get_apps(stack_ids)
16
+ print(apps)
17
+ end
18
+
19
+ def get_stacks
20
+ client.api_call('describe_stacks')[:stacks].map{|s| s[:stack_id] }
21
+ end
22
+
23
+ def get_apps(stack_ids)
24
+ stack_ids.map{ |stack_id| apps_for_stack(stack_id) }.flatten
25
+ end
26
+
27
+ def apps_for_stack(stack_id)
28
+ client.api_call('describe_apps', stack_id: stack_id)[:apps]
29
+ end
30
+
31
+ def print(apps)
32
+ puts Terminal::Table.new headings: ['Name', 'Stack Id', 'App Id'], rows: app_data(apps)
33
+ end
34
+
35
+ def app_data(apps)
36
+ apps.map{|app| [app[:name], app[:stack_id], app[:app_id]] }
37
+ end
38
+
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module Opsicle
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/opsicle.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["andrew.fleener@sportngin.com"]
11
11
  spec.description = %q{CLI for the opsworks platform}
12
12
  spec.summary = %q{An opsworks specific abstraction on top of the aws sdk}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/sportngin/opsicle"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "aws-sdk"
21
+ spec.add_dependency "aws-sdk", "~> 1.30"
22
22
  spec.add_dependency "commander"
23
+ spec.add_dependency "terminal-table"
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 1.3"
25
26
  spec.add_development_dependency "rake"
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+ require "opsicle/list"
3
+
4
+ module Opsicle
5
+ describe List do
6
+ subject { List.new('derp') }
7
+
8
+ context "#execute" do
9
+ let(:client) { double }
10
+ let(:stack_ids) { [1,2,3] }
11
+ let(:apps) { [{ name: 'test', stack_id: 1, app_id: 1}, { name: 'test2', stack_id: 2, app_id: 2}, { name: 'test3', stack_id: 3, app_id: 3 }] }
12
+ before do
13
+ Client.stub(:new).with('derp').and_return(client)
14
+ end
15
+
16
+ it "creates a new deployment" do
17
+ subject.should_receive(:get_stacks).and_return(stack_ids)
18
+ subject.should_receive(:get_apps).with(stack_ids).and_return(apps)
19
+ subject.execute
20
+ end
21
+ end
22
+
23
+ context "#client" do
24
+ it "generates a new aws client from the given configs" do
25
+ Client.should_receive(:new).with('derp')
26
+ subject.client
27
+ end
28
+ end
29
+
30
+ end
31
+ 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.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,26 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-18 00:00:00.000000000 Z
12
+ date: 2013-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.30'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.30'
30
+ - !ruby/object:Gem::Dependency
31
+ name: commander
16
32
  requirement: !ruby/object:Gem::Requirement
17
33
  none: false
18
34
  requirements:
@@ -28,7 +44,7 @@ dependencies:
28
44
  - !ruby/object:Gem::Version
29
45
  version: '0'
30
46
  - !ruby/object:Gem::Dependency
31
- name: commander
47
+ name: terminal-table
32
48
  requirement: !ruby/object:Gem::Requirement
33
49
  none: false
34
50
  requirements:
@@ -146,13 +162,15 @@ files:
146
162
  - lib/opsicle/client.rb
147
163
  - lib/opsicle/config.rb
148
164
  - lib/opsicle/deploy.rb
165
+ - lib/opsicle/list.rb
149
166
  - lib/opsicle/version.rb
150
167
  - opsicle.gemspec
151
168
  - spec/opsicle/client_spec.rb
152
169
  - spec/opsicle/config_spec.rb
153
170
  - spec/opsicle/deploy_spec.rb
171
+ - spec/opsicle/list_spec.rb
154
172
  - spec/spec_helper.rb
155
- homepage: ''
173
+ homepage: https://github.com/sportngin/opsicle
156
174
  licenses:
157
175
  - MIT
158
176
  post_install_message:
@@ -167,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
185
  version: '0'
168
186
  segments:
169
187
  - 0
170
- hash: 3974705077046022330
188
+ hash: -2075520144687037526
171
189
  required_rubygems_version: !ruby/object:Gem::Requirement
172
190
  none: false
173
191
  requirements:
@@ -176,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
194
  version: '0'
177
195
  segments:
178
196
  - 0
179
- hash: 3974705077046022330
197
+ hash: -2075520144687037526
180
198
  requirements: []
181
199
  rubyforge_project:
182
200
  rubygems_version: 1.8.25
@@ -187,4 +205,5 @@ test_files:
187
205
  - spec/opsicle/client_spec.rb
188
206
  - spec/opsicle/config_spec.rb
189
207
  - spec/opsicle/deploy_spec.rb
208
+ - spec/opsicle/list_spec.rb
190
209
  - spec/spec_helper.rb