stackit 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 673173d2d83ca9d388ff1af7e43455592113b240
4
- data.tar.gz: 38a108b6b1cb3778bc68bcd2a08d2a40f7a84655
3
+ metadata.gz: fbde49a4efbd662200baecfed8b4b7c40f9c340c
4
+ data.tar.gz: e565d4fb07afca1d2410afa98734ae455bf350f5
5
5
  SHA512:
6
- metadata.gz: f54ad693aaae722e5397964deff8397bafddccf19bd2a6b2e862477fbd0c51285aa5b251ec0a7cb8b98a2233ab677b194d58ed4833e664ae2694c25cd59ae747
7
- data.tar.gz: c89bb8c36bd6e2ef2c4fe5311949bd2709847af18dcc6e1afd1c656f229daf4ce0f0b17f02efda3273ff785f6726cc6ea3e0b449d33462d3ecf21aec7516ebe9
6
+ metadata.gz: 02c76bfdafbd85d0c7e186013fee0fac15540d71b93de8694b5f92577120e87decd6ea0b18f34171dcb67671fc79d684e9d5c71bc7577f116bd3661f9e48dabc
7
+ data.tar.gz: 83bb2a02c71e87d3ab04861797170a219c442cee989c19b46a0380d90190ab03e4b1839b8f7a07d407b4debbd2bfcec0825921b74fb5f31daa199de6b63b0d76
data/bin/stackit CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  $:.push File.expand_path('../../lib', __FILE__)
3
- require 'stackit/cli'
4
- Stackit::Cli.start
3
+ require 'stackit/cli/base_cli'
4
+ require 'stackit/cli/stack_cli'
5
+ require 'stackit/cli/stackit_cli'
6
+ Stackit::StackitCli.start
@@ -0,0 +1,81 @@
1
+ require 'stackit'
2
+ require 'thor'
3
+
4
+ module Stackit
5
+ class BaseCli < Thor
6
+
7
+ class_option :environment, :aliases => '-e', :desc => "Your stack environment (dev, staging, prod, etc)", :default => 'default'
8
+ class_option :profile, desc: 'AWS profile'
9
+ class_option :region, desc: 'AWS region', default: 'us-east-1'
10
+ class_option :debug, type: :boolean, default: false
11
+ class_option :verbose, type: :boolean, default: false
12
+ class_option :assume_role, type: :hash, :desc => 'IAM role name and optional duration to keep the STS token valid'
13
+
14
+ def initialize(*args)
15
+ super(*args)
16
+ init_cli
17
+ end
18
+
19
+ def self.banner(task, namespace = true, subcommand = false)
20
+ "#{basename} #{task.usage}"
21
+ end
22
+
23
+ def self.subcommand_prefix
24
+ self.name.gsub(%r{.*::}, '').gsub(%r{^[A-Z]}) { |match| match[0].downcase }.gsub(%r{[A-Z]}) { |match| "-#{match[0].downcase}" }
25
+ end
26
+
27
+ def self.exit_on_failure?
28
+ true
29
+ end
30
+
31
+ desc 'version', 'Displays StackIT version'
32
+ def version
33
+ puts <<-LOGO
34
+ _____ _ _ _______ _______
35
+ (_____) (_)_ (_) _ (_______)(__ _ __)
36
+ (_)___ (___) ____ ___ (_)(_) (_) (_)
37
+ (___)_ (_) (____) _(___)(___) (_) (_)
38
+ ____(_)(_)_( )_( )(_)___ (_)(_) __(_)__ (_)
39
+ (_____) (__)(__)_) (____)(_) (_)(_______) (_) v#{Stackit::VERSION}
40
+
41
+ Simple, elegant CloudFormation dependency management.
42
+
43
+ LOGO
44
+ end
45
+
46
+ no_commands do
47
+
48
+ def init_cli
49
+
50
+ Stackit.aws.region = options[:region] if options[:region]
51
+ Stackit.environment = options[:environment].to_sym if options[:environment]
52
+ Stackit.debug = !!options[:debug]
53
+ if Stackit.debug
54
+ Stackit.logger.level = Logger::DEBUG
55
+ Stackit.logger.debug "Initializing CLI in debug mode."
56
+ begin
57
+ require 'pry-byebug'
58
+ rescue LoadError; end
59
+ elsif options[:verbose]
60
+ Stackit.logger.level = Logger::INFO
61
+ else
62
+ Stackit.logger.level = Logger::ERROR
63
+ end
64
+ if options[:profile]
65
+ Stackit.aws.profile = options[:profile]
66
+ elsif options[:environment]
67
+ Stackit.aws.credentials = Stackit.aws.load_credentials(
68
+ options[:environment]
69
+ )
70
+ end
71
+ if options[:assume_role] && options[:assume_role].has_key?('name')
72
+ name = options[:assume_role]['name']
73
+ duration = options[:assume_role].has_key?('duration') ? options[:assume_role]['duration'] : 3600
74
+ Stackit.aws.assume_role!(name, duration)
75
+ end
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+ end
@@ -1,28 +1,12 @@
1
1
  require 'stackit'
2
+ require 'stackit/cli/base_cli'
2
3
  require 'thor'
3
4
 
4
5
  module Stackit
5
- class Cli < Thor
6
-
7
- class_option :environment, :aliases => '-e', :desc => "Your stack environment (dev, staging, prod, etc)", :default => 'default'
8
- class_option :profile, desc: 'AWS profile'
9
- class_option :region, desc: 'AWS region', default: 'us-east-1'
10
- class_option :debug, type: :boolean, default: false
11
- class_option :verbose, type: :boolean, default: false
12
- class_option :assume_role, type: :hash, :desc => 'IAM role name and optional duration to keep the STS token valid'
6
+ class StackCli < BaseCli
13
7
 
14
8
  def initialize(*args)
15
9
  super(*args)
16
- init_cli
17
- end
18
-
19
- def self.banner(task, namespace = true, subcommand = false)
20
- #"#{basename} #{subcommand_prefix} #{task.usage}"
21
- "#{basename} #{task.usage}"
22
- end
23
-
24
- def self.subcommand_prefix
25
- self.name.gsub(%r{.*::}, '').gsub(%r{^[A-Z]}) { |match| match[0].downcase }.gsub(%r{[A-Z]}) { |match| "-#{match[0].downcase}" }
26
10
  end
27
11
 
28
12
  desc 'create-stack', 'Creates a new CloudFormation stack'
@@ -95,74 +79,5 @@ module Stackit
95
79
  }).delete!
96
80
  end
97
81
 
98
- desc 'create-keypair', 'Creates a new EC2 keypair and returns it\'s corresponding private key'
99
- method_option :name, desc: 'The name of the keypair', :required => true
100
- def create_keypair
101
- puts Stackit.aws.ec2.create_key_pair({
102
- key_name: options['name']
103
- })['key_material']
104
- end
105
-
106
- desc 'delete-keypair', 'Deletes an existing EC2 keypair'
107
- method_option :name, desc: 'The name of the keypair', :required => true
108
- def delete_keypair
109
- Stackit.aws.ec2.delete_key_pair({
110
- key_name: options['name']
111
- })
112
- end
113
-
114
- desc 'version', 'Displays StackIT version'
115
- def version
116
- puts <<-LOGO
117
- _____ _ _ _______ _______
118
- (_____) (_)_ (_) _ (_______)(__ _ __)
119
- (_)___ (___) ____ ___ (_)(_) (_) (_)
120
- (___)_ (_) (____) _(___)(___) (_) (_)
121
- ____(_)(_)_( )_( )(_)___ (_)(_) __(_)__ (_)
122
- (_____) (__)(__)_) (____)(_) (_)(_______) (_) v#{Stackit::VERSION}
123
-
124
- Simple, elegant CloudFormation dependency management.
125
-
126
- LOGO
127
- end
128
-
129
- def self.exit_on_failure?
130
- true
131
- end
132
-
133
- no_commands do
134
-
135
- def init_cli
136
-
137
- Stackit.aws.region = options[:region] if options[:region]
138
- Stackit.environment = options[:environment].to_sym if options[:environment]
139
- Stackit.debug = !!options[:debug]
140
- if Stackit.debug
141
- Stackit.logger.level = Logger::DEBUG
142
- Stackit.logger.debug "Initializing CLI in debug mode."
143
- begin
144
- require 'pry-byebug'
145
- rescue LoadError; end
146
- elsif options[:verbose]
147
- Stackit.logger.level = Logger::INFO
148
- else
149
- Stackit.logger.level = Logger::ERROR
150
- end
151
- if options[:profile]
152
- Stackit.aws.profile = options[:profile]
153
- elsif options[:environment]
154
- Stackit.aws.credentials = Stackit.aws.load_credentials(
155
- options[:environment]
156
- )
157
- end
158
- if options[:assume_role] && options[:assume_role].has_key?('name')
159
- name = options[:assume_role]['name']
160
- duration = options[:assume_role].has_key?('duration') ? options[:assume_role]['duration'] : 3600
161
- Stackit.aws.assume_role!(name, duration)
162
- end
163
- end
164
-
165
- end
166
-
167
82
  end
168
83
  end
@@ -0,0 +1,43 @@
1
+ require 'stackit'
2
+ require 'thor'
3
+
4
+ module Stackit
5
+ class StackitCli < StackCli
6
+
7
+ def initialize(*args)
8
+ super(*args)
9
+ end
10
+
11
+ desc 'create-keypair', 'Creates a new EC2 keypair and returns it\'s corresponding private key'
12
+ method_option :name, desc: 'The name of the keypair', :required => true
13
+ def create_keypair
14
+ puts Stackit.aws.ec2.create_key_pair({
15
+ key_name: options['name']
16
+ })['key_material']
17
+ end
18
+
19
+ desc 'delete-keypair', 'Deletes an existing EC2 keypair'
20
+ method_option :name, desc: 'The name of the keypair', :required => true
21
+ def delete_keypair
22
+ Stackit.aws.ec2.delete_key_pair({
23
+ key_name: options['name']
24
+ })
25
+ end
26
+
27
+ desc 'version', 'Displays StackIT version'
28
+ def version
29
+ puts <<-LOGO
30
+ _____ _ _ _______ _______
31
+ (_____) (_)_ (_) _ (_______)(__ _ __)
32
+ (_)___ (___) ____ ___ (_)(_) (_) (_)
33
+ (___)_ (_) (____) _(___)(___) (_) (_)
34
+ ____(_)(_)_( )_( )(_)___ (_)(_) __(_)__ (_)
35
+ (_____) (__)(__)_) (____)(_) (_)(_______) (_) v#{Stackit::VERSION}
36
+
37
+ Simple, elegant CloudFormation dependency management.
38
+
39
+ LOGO
40
+ end
41
+
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module Stackit
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Hahn
@@ -142,7 +142,9 @@ files:
142
142
  - bin/stackit
143
143
  - lib/stackit.rb
144
144
  - lib/stackit/aws.rb
145
- - lib/stackit/cli.rb
145
+ - lib/stackit/cli/base_cli.rb
146
+ - lib/stackit/cli/stack_cli.rb
147
+ - lib/stackit/cli/stackit_cli.rb
146
148
  - lib/stackit/stack.rb
147
149
  - lib/stackit/stack/default_notifier.rb
148
150
  - lib/stackit/stack/managed_stack.rb