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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f9c4a0bcff7b3feb94912a01d1b05b766719478
4
- data.tar.gz: 0e425032da77535e9d1a3536f602fa21d6cd7902
3
+ metadata.gz: 304e00b3319254cb54534703c1d0349fc1bee849
4
+ data.tar.gz: 9d33ed9a0eae6d2eab28329d041801cbc82d252a
5
5
  SHA512:
6
- metadata.gz: 747f2bb935bb19e48bd750f20e5fbe6947ef933126e103700b2e200db9a45042c1279c6c017ecb74b17d256d63cad35e835c77d13a858d84dcf4a5551e26412a
7
- data.tar.gz: a2c072193e1ed2e98932f725f0ecf230efd2521f4f37be822964566fc4d8cc87c34e68bee4e4d78865f797ec0e1a5acc8b135dd7200523f39510cf42f917e3ee
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
@@ -12,6 +12,8 @@ module Pipely
12
12
  class Template
13
13
  include TemplateHelpers
14
14
 
15
+ attr_accessor :pipeline_id
16
+
15
17
  def initialize(source)
16
18
  @source = source
17
19
  @config = {}
@@ -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(pipeline_name,
51
- definition,
52
- tags)
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: created_pipeline.id)
113
- created_pipeline.id
119
+ @aws.activate_pipeline(pipeline_id: pipeline.id)
120
+ pipeline.id
114
121
  end
115
122
  end
116
123
 
@@ -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.deploy_pipeline(
58
- definition.pipeline_name,
59
- definition.to_json
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
@@ -1,3 +1,3 @@
1
1
  module Pipely
2
- VERSION = '0.11.0' unless defined?(::Pipely::VERSION)
2
+ VERSION = '0.12.0' unless defined?(::Pipely::VERSION)
3
3
  end
@@ -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
- anything(),
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, definition)
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.11.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: 2014-12-16 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-graphviz