ev_job_gen 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/kubernetes/tmpl/oneshot_job_template.yml.erb +1 -0
- data/lib/ev_job_gen/manifest_gen.rb +1 -1
- data/lib/ev_job_gen/renderer/manifest_renderer.rb +18 -0
- data/lib/ev_job_gen/renderer/spec_renderer.rb +27 -0
- data/lib/ev_job_gen/renderer.rb +38 -0
- data/lib/ev_job_gen/version.rb +1 -1
- data/lib/ev_job_gen.rb +1 -1
- metadata +5 -3
- data/lib/ev_job_gen/yml_renderer.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 911c2e6a913212af70db4fc8c75426db37895ee916b8e1b0e82b1dd3c8ce6e2f
|
4
|
+
data.tar.gz: 29519dd22e5f9069d4c64644cb97bc14f74969fa83793d3cf23727942f812def
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 570463b577ccbc222de9409d4380fe550d8b5641e2d2c2da720fa0ea141e34fffad3665fd3f513b47b1357c2a0e7b0e66c6490bd9016f02699eac7b02b0da500
|
7
|
+
data.tar.gz: 81070a6e5e947949f222fca3492d4a58879edfcf92866399e0e662c9fec5055528f228b56f4f7eab7f770f50e99bf402e48cf772be3337fa8bed1a8d1635aac6
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -52,6 +52,7 @@ metadata:
|
|
52
52
|
app: ev-job
|
53
53
|
role: job
|
54
54
|
spec:
|
55
|
+
backoffLimit: 0
|
55
56
|
schedule: "5 17 * * *"
|
56
57
|
concurrencyPolicy: "Replace"
|
57
58
|
suspend: false
|
@@ -74,10 +75,11 @@ spec:
|
|
74
75
|
app: ev-job
|
75
76
|
role: job
|
76
77
|
spec:
|
78
|
+
|
77
79
|
restartPolicy: Never
|
78
80
|
containers:
|
79
81
|
- name: ev-job
|
80
|
-
image: some-docker-registory/
|
82
|
+
image: some-docker-registory/ml-project-1:latest
|
81
83
|
imagePullPolicy: Always
|
82
84
|
command:
|
83
85
|
- "/bin/bash"
|
@@ -89,6 +91,7 @@ spec:
|
|
89
91
|
export AWS_SECRET_ACCESS_KEY=xxx;
|
90
92
|
export AWS_REGION=xxx;
|
91
93
|
|
94
|
+
apt install -y wget;
|
92
95
|
wget https://github.com/wantedly/ev-cli/releases/download/v1.2.3/ev-v1.2.3-linux-amd64.tar.gz;
|
93
96
|
tar xvzf ev-v1.2.3-linux-amd64.tar.gz;
|
94
97
|
cp linux-amd64/ev ev;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module EvJobGen
|
4
|
+
class Renderer
|
5
|
+
class ManifestRenderer
|
6
|
+
def initialize(template:, job:, spec:)
|
7
|
+
@renderer = ERB.new(File.read(template))
|
8
|
+
@job = job
|
9
|
+
@spec = spec
|
10
|
+
end
|
11
|
+
attr_reader :job, :spec
|
12
|
+
|
13
|
+
def render
|
14
|
+
@renderer.result(binding) # Only use `job` and `spec`
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module EvJobGen
|
4
|
+
class Renderer
|
5
|
+
class SpecRenderer
|
6
|
+
class << self
|
7
|
+
def spec_template_path
|
8
|
+
File.expand_path(
|
9
|
+
File.join('kubernetes', 'tmpl', 'spec_template.yml.erb'),
|
10
|
+
EvJobGen.root,
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(job:, config:)
|
16
|
+
@job = job
|
17
|
+
@config = config
|
18
|
+
@renderer = ERB.new(File.read(SpecRenderer.spec_template_path))
|
19
|
+
end
|
20
|
+
attr_reader :job, :config
|
21
|
+
|
22
|
+
def render
|
23
|
+
@renderer.result(binding) # Only use `job` and `config`
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'ev_job_gen/renderer/manifest_renderer'
|
2
|
+
require 'ev_job_gen/renderer/spec_renderer'
|
3
|
+
|
4
|
+
module EvJobGen
|
5
|
+
class Renderer
|
6
|
+
def initialize(template:, specoffset:, jobfile:, configfile:)
|
7
|
+
@template = template
|
8
|
+
@specoffset = specoffset
|
9
|
+
@job = EvJobGen::Job.new(jobfile)
|
10
|
+
@config = EvJobGen::Config.new(configfile)
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
spec = SpecRenderer.new(
|
15
|
+
job: @job,
|
16
|
+
config: @config,
|
17
|
+
).render
|
18
|
+
|
19
|
+
r = ManifestRenderer.new(
|
20
|
+
template: @template,
|
21
|
+
job: @job,
|
22
|
+
spec: offset(spec, off: @specoffset + 2)
|
23
|
+
).render
|
24
|
+
|
25
|
+
normalize(r)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def normalize(text)
|
31
|
+
text.split("\n").map { |l| l.rstrip }.map { |l| "#{l}\n" }.join
|
32
|
+
end
|
33
|
+
|
34
|
+
def offset(text, off:)
|
35
|
+
"\n" + text.split("\n").map { |l| "#{' ' * off}#{l}\n" }.join
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/ev_job_gen/version.rb
CHANGED
data/lib/ev_job_gen.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ev_job_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nao Minami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -125,8 +125,10 @@ files:
|
|
125
125
|
- lib/ev_job_gen/config.rb
|
126
126
|
- lib/ev_job_gen/job.rb
|
127
127
|
- lib/ev_job_gen/manifest_gen.rb
|
128
|
+
- lib/ev_job_gen/renderer.rb
|
129
|
+
- lib/ev_job_gen/renderer/manifest_renderer.rb
|
130
|
+
- lib/ev_job_gen/renderer/spec_renderer.rb
|
128
131
|
- lib/ev_job_gen/version.rb
|
129
|
-
- lib/ev_job_gen/yml_renderer.rb
|
130
132
|
homepage: https://github.com/wantedly/ev-job-gen
|
131
133
|
licenses:
|
132
134
|
- MIT
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
module EvJobGen
|
5
|
-
class YmlRenderer
|
6
|
-
class << self
|
7
|
-
def spec_template_path
|
8
|
-
File.expand_path(
|
9
|
-
File.join('kubernetes', 'tmpl', 'spec_template.yml.erb'),
|
10
|
-
EvJobGen.root,
|
11
|
-
)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(template:, specoffset:, jobfile:, configfile:)
|
16
|
-
@spec_renderer = ERB.new(File.read(YmlRenderer.spec_template_path))
|
17
|
-
@specoffset = specoffset
|
18
|
-
@renderer = ERB.new(File.read(template))
|
19
|
-
@job = EvJobGen::Job.new(jobfile)
|
20
|
-
@config = EvJobGen::Config.new(configfile)
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_reader :job, :config
|
24
|
-
|
25
|
-
def render
|
26
|
-
spec = render_spec
|
27
|
-
@renderer.result(binding)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def render_spec
|
33
|
-
r = @spec_renderer.result(binding)
|
34
|
-
offset = @specoffset + 2
|
35
|
-
"\n" + r.split("\n").map { |l| "#{' ' * offset}#{l}\n" }.join
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|