rubysdk 0.0.1.pre5 → 0.0.1

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
  SHA256:
3
- metadata.gz: 8a1f3ca13463948e53df0160b0564d0e94db8cdce16b49a9d0981f4c8f7b40b4
4
- data.tar.gz: bcd44d408657979cb8124d73b0d08abe5b13d7c684ff76f43676c43fc630262c
3
+ metadata.gz: 5e359c2b1c028748e828f91fb7e152f31045d796b55c7003381398fcc872b51c
4
+ data.tar.gz: df272ba0b3512d992c15c6131e2943a5e94a386d06f4d09b4b31383bd7326898
5
5
  SHA512:
6
- metadata.gz: d66e79ad9faadac21dcc94eee9955e24049bbb9cee038c0f926cbc7441533f6fa73778c24e1da6df16d476ab373030f52cc229e8d225a0bff227ba71f339aff6
7
- data.tar.gz: a6dc88a4a699520f455b2b10b3a5a3cb3781679d385ebe9ec0e38eb9f89bdef619d5a0fcbd240b11522ad808c6c8517c4c2663410b7450088123f56f5e6aaf42
6
+ metadata.gz: b9b1e46917ad9b81e97551dd950c58f4d889a7aaa1ab49ff8a6cea1ba9be5ce9b3953a68c451c73aa1b8c287cefd52b70bd55bba4a95227c7ce9991b83931781
7
+ data.tar.gz: aea4b478c9b968c94b7ce636558ed45c595c20e426653564e23a7c6762ac708334771af0efd98bae92bbcb74fab100ddcb18bef063eb32dba1f540ad18ed9c78
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Interface
4
+ # Constants
5
+ TextFieldInput = "textfield"
6
+ TextAreaInput = "textarea"
7
+ BoolInput = "boolean"
8
+ VaultInput = "vault"
9
+
4
10
  class Job
5
11
  attr_accessor :handler, :title, :desc, :dependson, :args, :interaction
6
12
 
@@ -3,6 +3,7 @@ proto_dir = File.join(this_dir, 'proto')
3
3
  interface_dir = File.join(this_dir, 'interface')
4
4
  $LOAD_PATH.unshift(proto_dir) unless $LOAD_PATH.include?(proto_dir)
5
5
  $LOAD_PATH.unshift(interface_dir) unless $LOAD_PATH.include?(interface_dir)
6
+ STDOUT.sync = true
6
7
 
7
8
  require 'grpc'
8
9
  require 'grpc/health/checker'
@@ -28,7 +29,7 @@ module RubySDK
28
29
  def execute_job(job, _call)
29
30
  cjob = nil
30
31
  @cached_jobs.each do |cached_job|
31
- cjob = cached_job unless cached_job.unique_id == job.unique_id
32
+ cjob = cached_job if cached_job.job.unique_id == job.unique_id
32
33
  end
33
34
  if cjob == nil
34
35
  Proto::JobResult.new(failed: true,
@@ -39,26 +40,35 @@ module RubySDK
39
40
 
40
41
  # Transform arguments
41
42
  args = []
42
- job.args.each do |arg|
43
- new_arg = Proto::Argument.new(key: arg.key,
43
+ if !job.args.empty?
44
+ job.args.each do |arg|
45
+ new_arg = Proto::Argument.new(key: arg.key,
44
46
  value: arg.value)
45
- args.push new_arg
47
+ args.push new_arg
48
+ end
46
49
  end
47
50
 
48
51
  # Execute job
49
- job_result = Proto::JobResult.new
52
+ job_failed = false
53
+ exit_pipeline = false
54
+ message = ""
55
+ unique_id = 0
50
56
  begin
51
- job.handler.call(args)
57
+ cjob.handler.call(args)
52
58
  rescue => e
53
59
  # Check if job wants to force exit pipeline.
54
60
  # We will exit the pipeline but not mark it as 'failed'.
55
- job_result.failed = true unless e == ErrorExitPipeline
61
+ job_failed = true if e == ErrorExitPipeline
56
62
 
57
63
  # Set log message and job id
58
- job_result.exit_pipeline = true
59
- job_result.message = e.message
60
- job_result.unique_id = job.job.unique_id
64
+ exit_pipeline = true
65
+ message = e.message
66
+ unique_id = job.job.unique_id
61
67
  end
68
+ Proto::JobResult.new(unique_id: unique_id,
69
+ failed: job_failed,
70
+ exit_pipeline: exit_pipeline,
71
+ message: message)
62
72
  end
63
73
  end
64
74
 
@@ -81,6 +91,11 @@ module RubySDK
81
91
  args = []
82
92
  if job.args != nil
83
93
  job.args.each do |arg|
94
+ # Description and Value are optional.
95
+ # Set default values for those.
96
+ arg.desc = "" if arg.desc == nil
97
+ arg.value = "" if arg.value == nil
98
+
84
99
  trans_arg = Proto::Argument.new(description: arg.desc,
85
100
  type: arg.type,
86
101
  key: arg.key,
@@ -104,7 +119,7 @@ module RubySDK
104
119
  dep_found = false
105
120
  jobs.each do |curr_job|
106
121
  if curr_job.title.casecmp(dep_job) == 0
107
- proto_job.dependson += FNV.new.fnv1a_32(curr_job.title)
122
+ proto_job.dependson.push FNV.new.fnv1a_32(curr_job.title)
108
123
  dep_found = true
109
124
  break
110
125
  end
@@ -159,7 +174,7 @@ module RubySDK
159
174
  )
160
175
 
161
176
  # Register gRPC server and handle.
162
- host = 'localhost'
177
+ host = '127.0.0.1'
163
178
  s = GRPC::RpcServer.new
164
179
  port = s.add_http2_port(host+':0', credentials)
165
180
  s.handle(GRPCServer.new(cached_jobs))
@@ -167,9 +182,7 @@ module RubySDK
167
182
 
168
183
  # Output the address and service name to stdout.
169
184
  # hashicorp go-plugin will use that to establish a connection.
170
- puts "1|2|tcp|#{host}:#{port}|grpc"
171
- GRPC.logger.info("1|2|tcp|#{host}:#{port}|grpc")
172
- STDOUT.sync = true
185
+ STDOUT.puts "1|2|tcp|#{host}:#{port}|grpc"
173
186
 
174
187
  s.run_till_terminated
175
188
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre5
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Vocks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-08 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -77,9 +77,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 1.3.1
82
+ version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
85
  rubygems_version: 2.7.6