bora 1.2.0 → 1.3.0

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: 741e43489dd8279e5b9a2fa73068bd45bbfcc7de
4
- data.tar.gz: 708c036c31038bec8dc57a61541af3065f4bf2c9
3
+ metadata.gz: 1cd2cfc5042845d206c5fdd8916b6a0212fc943c
4
+ data.tar.gz: 3a0f73e893cb10e2d871bfe2e8e364fa9500aaf3
5
5
  SHA512:
6
- metadata.gz: 85b831a26bb9876db1a32a00238b1d489582a5f87adcb105d5103414d1274d175f53bc8123287a603a811e0f43ee2e336b0704e71107d85698507cbd84e176ac
7
- data.tar.gz: 957e597af2294f73976630840ef64dbcdb2f078ea2085b39e0aa9d4d2e9950168ac7c292b1aa67fc9d394ee52abcade685573070d7e7ff419c7a5fda6349eb11
6
+ metadata.gz: 90dd31bc2e7058cf9e65d9c17d30936c5891943c8d390528e721012b64aef849aa9917192589a316915026af429df1e9ecdec107cfbffdb45f7b364eee0cf4c2
7
+ data.tar.gz: 5669c210393f07cf5c337c911f6a885e29d8dd1d3bd139162e5d02d87eeeff40a6d7bf271cbcd9018ce056e020635fd70ec8625c5a9a80d2f714729bf4efb11c
data/README.md CHANGED
@@ -156,6 +156,7 @@ The following commands are available through the command line and rake tasks.
156
156
  * **events** - Outputs the latest events from the stack
157
157
  * **list** - Outputs a list of all stacks defined in the config file
158
158
  * **outputs** - Shows the outputs from the stack
159
+ * **parameters** - Shows the parameters from the stack
159
160
  * **recreate** - Recreates (deletes then creates) the stack
160
161
  * **show** - Shows the local template in JSON, generating it if necessary
161
162
  * **show_current** - Shows the currently applied template in AWS
@@ -0,0 +1,22 @@
1
+ class Bora
2
+ module Cfn
3
+ class Parameter
4
+ def initialize(parameter)
5
+ @parameter = parameter
6
+ end
7
+
8
+ def key
9
+ @parameter.parameter_key
10
+ end
11
+
12
+ def value
13
+ @parameter.parameter_value
14
+ end
15
+
16
+ def to_s
17
+ "#{key} - #{value}"
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -1,10 +1,10 @@
1
1
  require 'set'
2
2
  require 'open-uri'
3
3
  require 'aws-sdk'
4
- require 'diffy'
5
4
  require 'bora/cfn/stack_status'
6
5
  require 'bora/cfn/event'
7
6
  require 'bora/cfn/output'
7
+ require 'bora/cfn/parameter'
8
8
 
9
9
  class Bora
10
10
  module Cfn
@@ -50,6 +50,11 @@ class Bora
50
50
  underlying_stack.outputs.map { |output| Output.new(output) }
51
51
  end
52
52
 
53
+ def parameters
54
+ return if !exists?
55
+ underlying_stack.parameters.map { |parameter| Parameter.new(parameter) }
56
+ end
57
+
53
58
  def template(pretty = true)
54
59
  return if !exists?
55
60
  template = cloudformation.get_template({stack_name: @stack_name}).template_body
@@ -68,10 +73,6 @@ class Bora
68
73
  end
69
74
  end
70
75
 
71
- def diff(options)
72
- Diffy::Diff.new(template, new_template(options))
73
- end
74
-
75
76
  def validate(options)
76
77
  cloudformation.validate_template(resolve_options(options).select { |k| [:template_body, :template_url].include?(k) })
77
78
  end
@@ -17,7 +17,7 @@ class Bora
17
17
 
18
18
  class_option "cfn-stack-name",
19
19
  type: :string,
20
- aliases: :c,
20
+ aliases: :n,
21
21
  default: nil,
22
22
  desc: "The name to give the stack in CloudFormation. Overrides any CFN stack name setting in the Bora config file."
23
23
 
@@ -43,8 +43,9 @@ class Bora
43
43
 
44
44
  desc "diff STACK_NAME", "Diffs the new template with the stack's current template"
45
45
  option :params, type: :array, aliases: :p, desc: "Parameters to be passed to the template, eg: --params 'instance_type=t2.micro'"
46
+ option :context, type: :numeric, aliases: :c, default: 3, desc: "Number of lines of context to show around the differences"
46
47
  def diff(stack_name)
47
- stack(options.file, stack_name).diff(params)
48
+ stack(options.file, stack_name).diff(params, options.context)
48
49
  end
49
50
 
50
51
  desc "events STACK_NAME", "Outputs the latest events from the stack"
@@ -57,6 +58,11 @@ class Bora
57
58
  stack(options.file, stack_name).outputs
58
59
  end
59
60
 
61
+ desc "parameters STACK_NAME", "Shows the parameters from the stack"
62
+ def parameters(stack_name)
63
+ stack(options.file, stack_name).parameters
64
+ end
65
+
60
66
  desc "recreate STACK_NAME", "Recreates (deletes then creates) the stack"
61
67
  option :params, type: :array, aliases: :p, desc: "Parameters to be passed to the template, eg: --params 'instance_type=t2.micro'"
62
68
  def recreate(stack_name)
@@ -1,6 +1,7 @@
1
1
  require 'tempfile'
2
2
  require 'colorize'
3
3
  require 'cfndsl'
4
+ require 'diffy'
4
5
  require 'bora/cfn/stack'
5
6
  require 'bora/stack_tasks'
6
7
  require 'bora/parameter_resolver'
@@ -14,6 +15,7 @@ class Bora
14
15
  STACK_EVENTS_DO_NOT_EXIST_MESSAGE = "Stack '%s' has no events"
15
16
  STACK_EVENTS_MESSAGE = "Events for stack '%s'"
16
17
  STACK_OUTPUTS_DO_NOT_EXIST_MESSAGE = "Stack '%s' has no outputs"
18
+ STACK_PARAMETERS_DO_NOT_EXIST_MESSAGE = "Stack '%s' has no parameters"
17
19
  STACK_VALIDATE_SUCCESS_MESSAGE = "Template for stack '%s' is valid"
18
20
 
19
21
  def initialize(stack_name, template_file, stack_config)
@@ -53,9 +55,25 @@ class Bora
53
55
  invoke_action("delete")
54
56
  end
55
57
 
56
- def diff(override_params = {})
58
+ def diff(override_params = {}, context_lines = 3)
57
59
  generate(override_params)
58
- puts @cfn_stack.diff(@cfn_options).to_s(String.disable_colorization ? :text : :color)
60
+ diff = Diffy::Diff.new(@cfn_stack.template, @cfn_stack.new_template(@cfn_options),
61
+ context: context_lines,
62
+ include_diff_info: true)
63
+ diff = diff.reject { |line| line =~ /^(---|\+\+\+|\\\\)/ }
64
+ diff = diff.map do |line|
65
+ case line
66
+ when /^\+/
67
+ line.chomp.colorize(:green)
68
+ when /^-/
69
+ line.chomp.colorize(:red)
70
+ when /^@@/
71
+ line.chomp.colorize(:cyan)
72
+ else
73
+ line.chomp
74
+ end
75
+ end
76
+ puts diff.join("\n")
59
77
  end
60
78
 
61
79
  def events
@@ -88,6 +106,21 @@ class Bora
88
106
  outputs
89
107
  end
90
108
 
109
+ def parameters
110
+ parameters = @cfn_stack.parameters
111
+ if parameters
112
+ if parameters.length > 0
113
+ puts "Parameters for stack '#{@cfn_stack_name}'"
114
+ parameters.each { |parameter| puts parameter }
115
+ else
116
+ puts STACK_PARAMETERS_DO_NOT_EXIST_MESSAGE % @cfn_stack_name
117
+ end
118
+ else
119
+ puts STACK_DOES_NOT_EXIST_MESSAGE % @cfn_stack_name
120
+ end
121
+ parameters
122
+ end
123
+
91
124
  def recreate(override_params = {})
92
125
  generate(override_params)
93
126
  invoke_action("recreate", @cfn_options)
@@ -16,6 +16,7 @@ class Bora
16
16
  define_diff_task
17
17
  define_events_task
18
18
  define_outputs_task
19
+ define_parameters_task
19
20
  define_recreate_task
20
21
  define_show_task
21
22
  define_show_current_task
@@ -68,6 +69,15 @@ class Bora
68
69
  end
69
70
  end
70
71
 
72
+ def define_parameters_task
73
+ within_namespace do
74
+ desc "Shows the parameters from the '#{@stack.stack_name}' stack"
75
+ task :parameters do
76
+ @stack.parameters
77
+ end
78
+ end
79
+ end
80
+
71
81
  def define_recreate_task
72
82
  within_namespace do
73
83
  desc "Recreates (deletes then creates) the '#{@stack.stack_name}' stack"
@@ -1,3 +1,3 @@
1
1
  class Bora
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bora
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Blaxland
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-16 00:00:00.000000000 Z
11
+ date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -158,6 +158,7 @@ files:
158
158
  - lib/bora.rb
159
159
  - lib/bora/cfn/event.rb
160
160
  - lib/bora/cfn/output.rb
161
+ - lib/bora/cfn/parameter.rb
161
162
  - lib/bora/cfn/stack.rb
162
163
  - lib/bora/cfn/stack_status.rb
163
164
  - lib/bora/cfn/status.rb