pipe_fitter 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: 6ca34c72ead67585ab3933c20339c6024dba555d
4
- data.tar.gz: 434c953698fb018b6babfbdcde83e1f4d770ab2c
3
+ metadata.gz: a1625059a89f5ae2b482da2c099fde222833c824
4
+ data.tar.gz: 338ea0ab87e4ac6e98156d7591f2185ea3c21014
5
5
  SHA512:
6
- metadata.gz: a4ffd2b3e959cda33c02760755be11f05460c144a8700915f20a4f04fac44d74b825b29e25fbd03f4646fcb24333ca8afeb8b5e24640f09a3dac30af44b114c3
7
- data.tar.gz: 0fe0ec48c13e2bcc260d9dbe7cae396a265e8f7f555fedb669c112874f48f6f2ec1d50939aca8a7496473374eac4f500e16cd36cb54f5f4654a4aad974f5026e
6
+ metadata.gz: 2fd6a9e9b5c3c2fa96b7f732369c3b7ae70f8088f88de8897b88b9527c12daf35ba65562920fd71462ab826f324b9be60f33709b8e42574d59d97bf83c32c3ec
7
+ data.tar.gz: 062c50ae98dd45eba4ce2363f43b2ea0302fa2e26441cf48f9864de3c9d9c83e56adab1cf201f51e4a7eb9ba900ee1cf48846bd149ce2631a9d486fa9d601cf3
data/exe/pipe_fitter CHANGED
@@ -36,11 +36,11 @@ module PipeFitter
36
36
 
37
37
  desc "activate", "Activate pipeline"
38
38
  option :pipeline_id, type: :string, required: true, aliases: "i"
39
- option :parameter_values, type: :hash, required: false, aliases: "p"
39
+ option :parameter_file, type: :string, required: false, aliases: "p"
40
40
  option :start_timestamp, type: :string, required: false, aliases: "t"
41
41
  def activate
42
42
  t = options[:start_timestamp] ? Time.parse(options[:start_timestamp]) : nil
43
- puts client.activate(options[:pipeline_id], options[:parameter_values], t)
43
+ puts client.activate(options[:pipeline_id], options[:parameter_file], t)
44
44
  end
45
45
 
46
46
  private
@@ -39,9 +39,9 @@ module PipeFitter
39
39
  [res.pipeline_id, put_definition(res.pipeline_id, pipeline)]
40
40
  end
41
41
 
42
- def activate(pipeline_id, parameter_values, start_timestamp)
43
- p = Pipeline.new({}, { pipeline_id: pipeline_id })
44
- exec(:activate_pipeline, p.activate_opts(parameter_values, start_timestamp))
42
+ def activate(pipeline_id, parameter_file, start_timestamp)
43
+ p = parameter_file ? Pipeline.load_yaml(parameter_file) : Pipeline.new
44
+ exec(:activate_pipeline, p.activate_opts(pipeline_id, start_timestamp)).to_h
45
45
  end
46
46
 
47
47
  private
@@ -21,7 +21,8 @@ module PipeFitter
21
21
  PipelineDescription.new(yml["pipeline_description"]))
22
22
  end
23
23
 
24
- def initialize(pipeline_objects, parameter_objects, parameter_values, pipeline_description)
24
+ def initialize(pipeline_objects = nil, parameter_objects = nil,
25
+ parameter_values = nil, pipeline_description = nil)
25
26
  @pipeline_objects = pipeline_objects
26
27
  @parameter_objects = parameter_objects
27
28
  @parameter_values = parameter_values
@@ -41,6 +42,10 @@ module PipeFitter
41
42
  }.to_yaml
42
43
  end
43
44
 
45
+ def create_opts
46
+ @pipeline_description.to_api_opts
47
+ end
48
+
44
49
  def put_definition_opts(pipeline_id)
45
50
  {
46
51
  pipeline_id: pipeline_id,
@@ -58,6 +63,15 @@ module PipeFitter
58
63
  { pipeline_id: pipeline_id, tag_keys: @pipeline_description.tag_keys }
59
64
  end
60
65
 
66
+ def activate_opts(pipeline_id, start_timestamp)
67
+ opts = {
68
+ pipeline_id: pipeline_id,
69
+ start_timestamp: start_timestamp,
70
+ }
71
+ opts.merge!(parameter_values: @parameter_values.to_api_opts) if @parameter_values
72
+ opts
73
+ end
74
+
61
75
  def diff(other, format = nil)
62
76
  Diffy::Diff.new(self.to_yaml, other.to_yaml).to_s(format)
63
77
  end
@@ -103,7 +117,6 @@ module PipeFitter
103
117
  if base.key?(key)
104
118
  base[key] = [base[key]] unless base[key].is_a?(Array)
105
119
  base[key] << value
106
- base[key].sort!
107
120
  else
108
121
  base[key] = value
109
122
  end
@@ -193,9 +206,19 @@ module PipeFitter
193
206
  new(objs)
194
207
  end
195
208
 
209
+ DESCRIPTION_KEYS = %i(name description tags uniqueId).freeze
210
+
196
211
  def to_objs
197
- keys = %i(name description tags uniqueId)
198
- stringify_keys(@objs.select { |k, _| keys.include?(k) })
212
+ stringify_keys(@objs.select { |k, _| DESCRIPTION_KEYS.include?(k) })
213
+ end
214
+
215
+ def to_api_opts
216
+ @objs.select { |k, _| DESCRIPTION_KEYS.include?(k) }.tap do |obj|
217
+ obj[:unique_id] = obj.delete(:uniqueId)
218
+ obj[:tags] = obj[:tags].map do |tag|
219
+ tag.map { |k, v| { key: k, value: v } }
220
+ end.flatten
221
+ end
199
222
  end
200
223
 
201
224
  def tags
@@ -1,3 +1,3 @@
1
1
  module PipeFitter
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipe_fitter
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
  - masa21kik
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk