cfn-flow 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfn-flow/cli.rb +17 -9
- data/lib/cfn-flow/template.rb +7 -4
- data/spec/cfn-flow_cli_spec.rb +30 -0
- data/spec/cfn-flow_template_spec.rb +1 -1
- data/spec/helper.rb +38 -0
- metadata +8 -6
- data/spec/spec_helper.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc660f95c7b3db9463a85875e038d11df8529c2b
|
4
|
+
data.tar.gz: daf4c92f76fd32d889657202e9cff7fe06921e23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b64abbf2f0a958b7afacac581e3d10d0fe59b133700692024f33323f4de73010ea6608bab7fc5208ea6812cc7c1280ec97bd80f78cefb452c748a8a2d74a4bf
|
7
|
+
data.tar.gz: f6cf53f021602ef8906f20c82fd1dae26b8bfe0830c8e98821aae9675800f2ac2aedc039f8db046eba204b0217b951842a9fe023e64fec64991593eb993c134f
|
data/lib/cfn-flow/cli.rb
CHANGED
@@ -6,7 +6,7 @@ class CfnFlow::CLI < Thor
|
|
6
6
|
method_option :from, type: :string, desc: 'Local source directory for templates'
|
7
7
|
method_option 'dev-name', type: :string, desc: 'Personal development prefix'
|
8
8
|
method_option :region, type: :string, desc: 'AWS Region'
|
9
|
-
method_option :verbose,
|
9
|
+
method_option :verbose, type: :boolean, desc: 'Verbose output', default: false
|
10
10
|
end
|
11
11
|
|
12
12
|
no_commands do
|
@@ -31,7 +31,16 @@ class CfnFlow::CLI < Thor
|
|
31
31
|
# Ensure region env var is set for AWS client
|
32
32
|
ENV['AWS_REGION'] = options['region']
|
33
33
|
|
34
|
-
#
|
34
|
+
# validate required options are present
|
35
|
+
%w(region bucket to from).each do |arg|
|
36
|
+
unless options[arg]
|
37
|
+
raise Thor::RequiredArgumentMissingError.new("Missing required argument '#{arg}'")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
unless options['dev-name'] || options['release']
|
42
|
+
raise Thor::RequiredArgumentMissingError.new("Missing either 'dev-name' or 'release' argument")
|
43
|
+
end
|
35
44
|
end
|
36
45
|
|
37
46
|
shared_options
|
@@ -61,12 +70,11 @@ class CfnFlow::CLI < Thor
|
|
61
70
|
load_templates
|
62
71
|
@templates.each do |t|
|
63
72
|
begin
|
64
|
-
|
73
|
+
say "Validating #{t.from}... "
|
65
74
|
t.validate!
|
66
|
-
|
75
|
+
say "valid."
|
67
76
|
rescue Aws::CloudFormation::Errors::ValidationError
|
68
|
-
|
69
|
-
say $!.message
|
77
|
+
raise Thor::Error.new("Error validating #{t.from}. Message: #{$!.message}")
|
70
78
|
end
|
71
79
|
end
|
72
80
|
end
|
@@ -75,11 +83,11 @@ class CfnFlow::CLI < Thor
|
|
75
83
|
shared_options
|
76
84
|
method_option :release, type: :string, lazy_default: CfnFlow::Git.sha, desc: 'Upload release'
|
77
85
|
def upload
|
78
|
-
|
86
|
+
CfnFlow::Git.check_status if options['release']
|
79
87
|
|
80
88
|
validate
|
81
89
|
@templates.each do |t|
|
82
|
-
|
90
|
+
say "Uploading #{t.from} to #{t.url}"
|
83
91
|
t.upload!
|
84
92
|
end
|
85
93
|
|
@@ -94,7 +102,7 @@ class CfnFlow::CLI < Thor
|
|
94
102
|
def prefix
|
95
103
|
# Add the release or dev name to the prefix
|
96
104
|
parts = []
|
97
|
-
parts << options['prefix']
|
105
|
+
parts << options['prefix'] if options['prefix']
|
98
106
|
if options['release']
|
99
107
|
parts += [ 'release', options['release'] ]
|
100
108
|
else
|
data/lib/cfn-flow/template.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
class CfnFlow::Template
|
2
2
|
attr_reader :from, :prefix, :bucket
|
3
|
-
def initialize(
|
4
|
-
|
3
|
+
def initialize(opts={})
|
4
|
+
unless [:from, :prefix, :bucket].all? {|arg| opts.key?(arg) }
|
5
|
+
raise ArgumentError.new("Must pass :from, :prefix, and :bucket")
|
6
|
+
end
|
7
|
+
@from, @prefix, @bucket = opts[:from], opts[:prefix], opts[:bucket]
|
5
8
|
end
|
6
9
|
|
7
10
|
def yaml?
|
@@ -51,11 +54,11 @@ class CfnFlow::Template
|
|
51
54
|
|
52
55
|
private
|
53
56
|
def cfn
|
54
|
-
|
57
|
+
Thread.current[:aws_cfn_client] ||= Aws::CloudFormation::Client.new
|
55
58
|
end
|
56
59
|
|
57
60
|
def s3_object
|
58
|
-
|
61
|
+
Thread.current[:aws_s3_object] ||= Aws::S3::Object.new(bucket, key)
|
59
62
|
end
|
60
63
|
|
61
64
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
describe 'CfnFlow::CLI' do
|
4
|
+
let(:cli) { CfnFlow::CLI }
|
5
|
+
|
6
|
+
before do
|
7
|
+
ENV.update({
|
8
|
+
'CFN_FLOW_BUCKET' => 'test-bucket',
|
9
|
+
'CFN_FLOW_FROM' => 'spec/data',
|
10
|
+
'CFN_FLOW_TO' => 'test'
|
11
|
+
})
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#validate' do
|
15
|
+
it('succeeds') {
|
16
|
+
capture { cli.start %w[validate] }
|
17
|
+
}
|
18
|
+
|
19
|
+
it('can fail') {
|
20
|
+
(Thread.current[:aws_cfn_client] = Aws::CloudFormation::Client.new).
|
21
|
+
stub_responses(:validate_template, 'ValidationError')
|
22
|
+
|
23
|
+
out = capture(:stderr) { cli.start %w(validate) }
|
24
|
+
|
25
|
+
Thread.current[:aws_cfn_client] = nil
|
26
|
+
out.include?("Error validating").must_equal true
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "minitest/pride"
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'pry'
|
8
|
+
rescue LoadError
|
9
|
+
# NBD.
|
10
|
+
end
|
11
|
+
|
12
|
+
require "cfn-flow"
|
13
|
+
|
14
|
+
Aws.config[:stub_responses] = true
|
15
|
+
ENV['AWS_REGION'] = 'us-east-1'
|
16
|
+
ENV['AWS_ACCESS_KEY_ID'] = 'test-key'
|
17
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = 'test-secret'
|
18
|
+
ENV['CFN_FLOW_DEV_NAME'] = 'cfn-flow-specs'
|
19
|
+
|
20
|
+
class Minitest::Spec
|
21
|
+
# From http://git.io/bcfh
|
22
|
+
def capture(stream = :stdout)
|
23
|
+
begin
|
24
|
+
stream = stream.to_s
|
25
|
+
eval "$#{stream} = StringIO.new"
|
26
|
+
yield
|
27
|
+
result = eval("$#{stream}").string
|
28
|
+
ensure
|
29
|
+
eval("$#{stream} = #{stream.upcase}")
|
30
|
+
end
|
31
|
+
|
32
|
+
result
|
33
|
+
end
|
34
|
+
|
35
|
+
# Reset env between tests
|
36
|
+
before { @orig_env = ENV.to_hash }
|
37
|
+
after { ENV.clear; ENV.update(@orig_env) }
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn-flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Suggs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,11 +109,12 @@ files:
|
|
109
109
|
- lib/cfn-flow/cli.rb
|
110
110
|
- lib/cfn-flow/git.rb
|
111
111
|
- lib/cfn-flow/template.rb
|
112
|
+
- spec/cfn-flow_cli_spec.rb
|
112
113
|
- spec/cfn-flow_template_spec.rb
|
113
114
|
- spec/data/cfn-flow.yml
|
114
115
|
- spec/data/sqs.template
|
115
116
|
- spec/data/sqs.yml
|
116
|
-
- spec/
|
117
|
+
- spec/helper.rb
|
117
118
|
homepage: http://github.com/kickstarter/cfn-flow
|
118
119
|
licenses:
|
119
120
|
- MIT
|
@@ -140,8 +141,9 @@ signing_key:
|
|
140
141
|
specification_version: 4
|
141
142
|
summary: A CLI for CloudFormation templates
|
142
143
|
test_files:
|
144
|
+
- spec/cfn-flow_cli_spec.rb
|
143
145
|
- spec/cfn-flow_template_spec.rb
|
144
146
|
- spec/data/cfn-flow.yml
|
145
147
|
- spec/data/sqs.template
|
146
148
|
- spec/data/sqs.yml
|
147
|
-
- spec/
|
149
|
+
- spec/helper.rb
|
data/spec/spec_helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler/setup"
|
3
|
-
require "minitest/autorun"
|
4
|
-
require "minitest/pride"
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'pry'
|
8
|
-
rescue LoadError
|
9
|
-
# NBD.
|
10
|
-
end
|
11
|
-
|
12
|
-
require "cfn-flow"
|
13
|
-
|
14
|
-
Aws.config[:stub_responses] = true
|
15
|
-
ENV['AWS_REGION'] = 'us-east-1'
|
16
|
-
ENV['AWS_ACCESS_KEY_ID'] = 'test-key'
|
17
|
-
ENV['AWS_SECRET_ACCESS_KEY'] = 'test-secret'
|