pipely 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pipely/build/definition.rb +4 -0
- data/lib/pipely/build/template.rb +2 -0
- data/lib/pipely/deploy/client.rb +13 -6
- data/lib/pipely/tasks/deploy.rb +5 -4
- data/lib/pipely/version.rb +1 -1
- data/spec/lib/pipely/deploy/client_spec.rb +25 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 304e00b3319254cb54534703c1d0349fc1bee849
|
4
|
+
data.tar.gz: 9d33ed9a0eae6d2eab28329d041801cbc82d252a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3218c97c5efba3b81e86bff225655c9ac09a5223973e7c5514cb1956f5178d192879d53da96218ad87e2a0062ecbc70cb5163cb4de6e4df7c4c1a7b5ba5a65da
|
7
|
+
data.tar.gz: 3f3e63d34afd93f3216fd4827dfb222497c5d436923cd7214e9949984355ccd9540636c58d66e8b6fb7ec7c810f90deb4f81950dcaa313e8b7981caf5ab73b49
|
@@ -4,6 +4,10 @@ module Pipely
|
|
4
4
|
# Represent a pipeline definition, built from a Template and some config.
|
5
5
|
#
|
6
6
|
class Definition < Struct.new(:template, :env, :config)
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
def_delegators :template, :pipeline_id=, :pipeline_id
|
10
|
+
|
7
11
|
def pipeline_name
|
8
12
|
config[:name]
|
9
13
|
end
|
data/lib/pipely/deploy/client.rb
CHANGED
@@ -33,7 +33,7 @@ module Pipely
|
|
33
33
|
@aws = AWS::DataPipeline.new.client
|
34
34
|
end
|
35
35
|
|
36
|
-
def deploy_pipeline(pipeline_basename, definition)
|
36
|
+
def deploy_pipeline(pipeline_basename, definition=nil, &block)
|
37
37
|
pipeline_name = [
|
38
38
|
('P' if ENV['env'] == 'production'),
|
39
39
|
ENV['USER'],
|
@@ -47,9 +47,10 @@ module Pipely
|
|
47
47
|
@log.info("#{pipeline_ids.count} existing pipelines: #{pipeline_ids}")
|
48
48
|
|
49
49
|
# Create new pipeline
|
50
|
-
created_pipeline_id = create_pipeline(
|
51
|
-
|
52
|
-
|
50
|
+
created_pipeline_id = create_pipeline(
|
51
|
+
pipeline_name, definition, tags, &block
|
52
|
+
)
|
53
|
+
|
53
54
|
if created_pipeline_id
|
54
55
|
@log.info("Created pipeline id '#{created_pipeline_id}'")
|
55
56
|
|
@@ -96,6 +97,8 @@ module Pipely
|
|
96
97
|
tags: default_tags.merge(tags)
|
97
98
|
)
|
98
99
|
|
100
|
+
definition ||= yield(created_pipeline.id) if block_given?
|
101
|
+
|
99
102
|
# Use aws-sdk gem, instead of Fog, to put definition and activate
|
100
103
|
# pipeline, for improved reporting of validation errors.
|
101
104
|
#
|
@@ -104,13 +107,17 @@ module Pipely
|
|
104
107
|
pipeline_objects: JSONDefinition.parse(definition)
|
105
108
|
)
|
106
109
|
|
110
|
+
activate_pipeline(response, created_pipeline)
|
111
|
+
end
|
112
|
+
|
113
|
+
def activate_pipeline(response, pipeline)
|
107
114
|
if response[:errored]
|
108
115
|
@log.error("Failed to put pipeline definition.")
|
109
116
|
@log.error(response[:validation_errors].inspect)
|
110
117
|
false
|
111
118
|
else
|
112
|
-
@aws.activate_pipeline(pipeline_id:
|
113
|
-
|
119
|
+
@aws.activate_pipeline(pipeline_id: pipeline.id)
|
120
|
+
pipeline.id
|
114
121
|
end
|
115
122
|
end
|
116
123
|
|
data/lib/pipely/tasks/deploy.rb
CHANGED
@@ -54,10 +54,11 @@ module Pipely
|
|
54
54
|
def run_task(verbose)
|
55
55
|
Rake::Task["upload_steps"].invoke
|
56
56
|
|
57
|
-
Pipely::Deploy::Client.new
|
58
|
-
definition.pipeline_name
|
59
|
-
|
60
|
-
|
57
|
+
Pipely::Deploy::Client.new
|
58
|
+
.deploy_pipeline(definition.pipeline_name) do |pipeline_id|
|
59
|
+
definition.pipeline_id = pipeline_id
|
60
|
+
definition.to_json
|
61
|
+
end
|
61
62
|
end
|
62
63
|
|
63
64
|
end
|
data/lib/pipely/version.rb
CHANGED
@@ -15,7 +15,7 @@ describe Pipely::Deploy::Client do
|
|
15
15
|
|
16
16
|
subject.should_receive(:create_pipeline).
|
17
17
|
with("#{ENV['USER']}:#{pipeline_basename}",
|
18
|
-
|
18
|
+
nil,
|
19
19
|
hash_including( 'basename' => pipeline_basename )
|
20
20
|
).
|
21
21
|
and_return(new_pipeline_id)
|
@@ -24,7 +24,30 @@ describe Pipely::Deploy::Client do
|
|
24
24
|
subject.should_receive(:delete_pipeline).with(id)
|
25
25
|
end
|
26
26
|
|
27
|
-
subject.deploy_pipeline(pipeline_basename
|
27
|
+
subject.deploy_pipeline(pipeline_basename) { definition }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#create_pipeline' do
|
32
|
+
let(:pipeline_name) { 'NewPipeline' }
|
33
|
+
let(:pipeline_id) { 123 }
|
34
|
+
let(:created_pipeline) { double(:created_pipeline, id: pipeline_id) }
|
35
|
+
let(:definition) { "Pipeline ID: 123" }
|
36
|
+
|
37
|
+
let(:data_pipelines) { subject.instance_variable_get(:@data_pipelines) }
|
38
|
+
let(:aws) { subject.instance_variable_get(:@aws) }
|
39
|
+
|
40
|
+
it 'gets the definition from the block' do
|
41
|
+
data_pipelines.stub_chain(:pipelines, :create)
|
42
|
+
.and_return(created_pipeline)
|
43
|
+
|
44
|
+
Pipely::Deploy::JSONDefinition.should_receive(:parse).with(definition)
|
45
|
+
|
46
|
+
aws.should_receive(:put_pipeline_definition).and_return({})
|
47
|
+
aws.should_receive(:activate_pipeline)
|
48
|
+
subject.create_pipeline(pipeline_name, nil) do |pipeline_id|
|
49
|
+
"Pipeline ID: #{pipeline_id}"
|
50
|
+
end
|
28
51
|
end
|
29
52
|
end
|
30
53
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipely
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Gillooly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-graphviz
|