cuber 1.3.0 → 1.5.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
  SHA256:
3
- metadata.gz: 0add7f37510059cb9a362057cdd2ea0ebb65129d3c1c815752115d5a8ebb02c9
4
- data.tar.gz: 6b1ac7715d12bc056a6cafc0bee58aa4562a7799961e41c9fdcb06b6e8c429bb
3
+ metadata.gz: 9539bae5c1054e978457c6d1bd927e5e88a28729f96b6f38b0c53a2cfe4764e1
4
+ data.tar.gz: e1409bdb27a9bb7c9712e7aac2f60602ab5d2476f337de970132aff3992be20a
5
5
  SHA512:
6
- metadata.gz: a90bcaaf29ef7712335afcb9cc85f1dc4f46def0d8bd8e8d271faeb62b76bf12de2fee9b03a74c057f128617fad3c55d3009ef3a4bebd78732fc290e9305e882
7
- data.tar.gz: af8612ca5c3728b37b999148daa69986ea29b683968aa724e480ce11fd3181dd8847c107a58275984a7f697bf8314d7a1bfc4b7ccd558d39c5b4ef33991dbbe6
6
+ metadata.gz: 6ad54e6e94ed208f42970099a2ed021e38627c9464b62307964d2edc07f4220679cbad49774e2574005ca91ef4f4c1752e9bf2b91fa8f9572ce4d94f678bc302
7
+ data.tar.gz: c92c28ceb31dc4b2ead37b2cd1634ece46219ff6b83f1b8e2366bf8f02bb456283c250983d29d349920d39705928cfdbcad57d2e1b86ec83d72f2c63afb760b6
@@ -109,8 +109,8 @@ module Cuber::Commands
109
109
  name = pod['metadata']['name']
110
110
  created_at = pod['metadata']['creationTimestamp']
111
111
  pod_status = pod['status']['phase']
112
- container_ready = pod['status']['containerStatuses'][0]['ready']
113
- container_status = pod['status']['containerStatuses'][0]['state'].values.first['reason']
112
+ container_ready = pod.dig('status', 'containerStatuses', 0, 'ready')
113
+ container_status = pod.dig('status', 'containerStatuses', 0, 'state')&.values&.first&.[]('reason')
114
114
  if pod_status == 'Succeeded' || (pod_status == 'Running' && container_ready)
115
115
  puts "#{name}: \e[32m#{container_status || pod_status}\e[0m (#{time_ago_in_words created_at})"
116
116
  else
@@ -64,8 +64,8 @@ module Cuber
64
64
  @migrate = { cmd: cmd, check: check }
65
65
  end
66
66
 
67
- def proc name, cmd, scale: 1, env: {}
68
- @procs[name] = { cmd: cmd, scale: scale, env: env }
67
+ def proc name, cmd, scale: 1, cpu: nil, ram: nil, term: 60, env: {}
68
+ @procs[name] = { cmd: cmd, scale: scale, cpu: cpu, ram: ram, term: term, env: env }
69
69
  end
70
70
 
71
71
  def cron name, schedule, cmd
@@ -81,6 +81,9 @@ module Cuber
81
81
  @errors << "proc \"#{procname}\" name can only include lowercase letters" if procname !~ /\A[a-z]+\z/
82
82
  @errors << "proc \"#{procname}\" command must be present" if proc[:cmd].to_s.strip.empty?
83
83
  @errors << "proc \"#{procname}\" scale must be a positive number" unless proc[:scale].is_a?(Integer) && proc[:scale] > 0
84
+ @errors << "proc \"#{procname}\" cpu must be a positive number" unless proc[:cpu].nil? || proc[:cpu].is_a?(Numeric) && proc[:cpu] > 0
85
+ @errors << "proc \"#{procname}\" ram must be a positive number" unless proc[:ram].nil? || proc[:ram].is_a?(Numeric) && proc[:ram] > 0
86
+ @errors << "proc \"#{procname}\" term must be a positive number" unless proc[:term].is_a?(Integer) && proc[:term] > 0
84
87
  proc[:env].each do |key, value|
85
88
  @errors << "proc \"#{procname}\" env name can only include uppercase letters, digits or underscores" if key !~ /\A[A-Z_]+[A-Z0-9_]*\z/
86
89
  end
@@ -137,6 +137,18 @@ spec:
137
137
  <%- else -%>
138
138
  command: <%= proc[:cmd].shellsplit %>
139
139
  <%- end -%>
140
+ resources:
141
+ requests:
142
+ <%- if proc[:cpu] -%>
143
+ cpu: <%= proc[:cpu] %>
144
+ <%- end -%>
145
+ <%- if proc[:ram] -%>
146
+ memory: <%= proc[:ram] %>Gi
147
+ <%- end -%>
148
+ limits:
149
+ <%- if proc[:ram] -%>
150
+ memory: <%= proc[:ram] %>Gi
151
+ <%- end -%>
140
152
  envFrom:
141
153
  - configMapRef:
142
154
  name: env
@@ -176,6 +188,7 @@ spec:
176
188
  <%- end -%>
177
189
  imagePullSecrets:
178
190
  - name: regcred
191
+ terminationGracePeriodSeconds: <%= proc[:term] %>
179
192
  <%- end -%>
180
193
 
181
194
  <%- @options[:cron].each do |jobname, cron| -%>
data/lib/cuber/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cuber
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuber
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cuber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-31 00:00:00.000000000 Z
11
+ date: 2022-10-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: