capistrano-nomad 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +26 -0
- data/capistrano-nomad.gemspec +2 -2
- data/lib/capistrano/nomad/helpers/base.rb +4 -0
- data/lib/capistrano/nomad/helpers/docker.rb +7 -5
- data/lib/capistrano/nomad/helpers/git.rb +1 -1
- data/lib/capistrano/nomad/helpers/nomad.rb +16 -11
- metadata +2 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d44671f9ed79b03419c3de79d4b938652eb3f35f3553450f4e5118fadeb596
|
4
|
+
data.tar.gz: 3a6afdc265f7f434774f960e1aa2a9c5950cd8da00c02dbf21407c752ec2bb22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 511bf835646bbfb0f5ec7bc0fe5dd575cd34b4a72573d73457ce07830284ad01260521bbdb2cc8a829e1ad535d78cbece3d041ed32f546efbd274090934523db
|
7
|
+
data.tar.gz: d576b13a85867cc3916dd32a7a26ece7aecdda4b1b14bc20a451f24a7bbeb48f3aef1144d3952e9e5ad831f06c33cb609fd41390bb40d2a29e0754254c48f098
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capistrano-nomad (0.
|
5
|
-
activesupport (
|
4
|
+
capistrano-nomad (0.3.0)
|
5
|
+
activesupport (<= 7.0.8)
|
6
6
|
byebug
|
7
7
|
capistrano (~> 3.0)
|
8
8
|
git
|
@@ -56,4 +56,4 @@ DEPENDENCIES
|
|
56
56
|
capistrano-nomad!
|
57
57
|
|
58
58
|
BUNDLED WITH
|
59
|
-
2.
|
59
|
+
2.4.20
|
data/README.md
CHANGED
@@ -24,6 +24,32 @@ gem install capistrano-nomad
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
+
Add to `Capfile`
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require "capistrano/nomad"
|
31
|
+
install_plugin Capistrano::Nomad
|
32
|
+
```
|
33
|
+
|
34
|
+
Define Nomad jobs within `deploy.rb`
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
nomad_job :app
|
38
|
+
nomad_job :redis
|
39
|
+
|
40
|
+
nomad_namespace :analytics do
|
41
|
+
nomad_job :grafana
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
Utilize tasks
|
46
|
+
|
47
|
+
```shell
|
48
|
+
cap production nomad:app:deploy
|
49
|
+
cap production nomad:redis:purge
|
50
|
+
cap production nomad:analytics:grafana:deploy
|
51
|
+
```
|
52
|
+
|
27
53
|
## Development
|
28
54
|
|
29
55
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/capistrano-nomad.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "capistrano-nomad"
|
5
|
-
spec.version = "0.
|
5
|
+
spec.version = "0.3.0"
|
6
6
|
spec.authors = ["James Hu"]
|
7
7
|
|
8
8
|
spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
# Uncomment to register a new dependency of your gem
|
30
|
-
spec.add_dependency "activesupport", "
|
30
|
+
spec.add_dependency "activesupport", "<= 7.0.8"
|
31
31
|
spec.add_dependency "byebug"
|
32
32
|
spec.add_dependency "capistrano", "~> 3.0"
|
33
33
|
spec.add_dependency "git"
|
@@ -61,16 +61,18 @@ def capistrano_nomad_build_docker_image(image_type, path, *args)
|
|
61
61
|
capistrano_nomad_build_docker_image_alias(image_type, git_commit_id),
|
62
62
|
capistrano_nomad_build_docker_image_alias(image_type, "latest"),
|
63
63
|
"trunk/#{fetch(:stage)}/#{image_type}:latest",
|
64
|
-
]
|
65
|
-
|
66
|
-
|
64
|
+
]
|
65
|
+
.compact
|
66
|
+
.each do |tag|
|
67
|
+
args << "--tag #{tag}"
|
68
|
+
end
|
67
69
|
|
68
70
|
# If any of these files exist then we're in the middle of rebase so we should interrupt
|
69
|
-
if ["rebase-merge", "rebase-apply"].any? { |f| File.exist?("#{
|
71
|
+
if ["rebase-merge", "rebase-apply"].any? { |f| File.exist?("#{capistrano_nomad_git.dir.path}/.git/#{f}") }
|
70
72
|
raise StandardError, "still in the middle of git rebase, interrupting docker image build"
|
71
73
|
end
|
72
74
|
|
73
|
-
system "docker build #{args.join(' ')}
|
75
|
+
system "docker build #{args.join(' ')} .#{capistrano_nomad_root.join(path)}"
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
@@ -36,9 +36,6 @@ class NomadErbNamespace
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def capistrano_nomad_build_file_path(parent_path, basename, namespace: nil)
|
39
|
-
# Remove initial slash if it exists
|
40
|
-
parent_path = parent_path[1..] if parent_path[0] == "/"
|
41
|
-
|
42
39
|
segments = [parent_path]
|
43
40
|
segments << namespace if namespace
|
44
41
|
segments << "#{basename}.hcl"
|
@@ -54,19 +51,27 @@ def capistrano_nomad_build_base_var_file_path(*args)
|
|
54
51
|
capistrano_nomad_build_file_path(fetch(:nomad_var_files_path), *args)
|
55
52
|
end
|
56
53
|
|
57
|
-
def
|
58
|
-
local_path =
|
54
|
+
def capistrano_nomad_build_local_path(path, *args)
|
55
|
+
local_path = ".#{capistrano_nomad_root.join(path)}"
|
59
56
|
|
60
57
|
# Determine if it has .erb appended or not
|
61
58
|
[local_path, "#{local_path}.erb"].find { |path| File.exist?(path) }
|
62
59
|
end
|
63
60
|
|
61
|
+
def capistrano_nomad_build_local_job_path(name, *args)
|
62
|
+
capistrano_nomad_build_local_path(capistrano_nomad_build_base_job_path(name, *args))
|
63
|
+
end
|
64
|
+
|
65
|
+
def capistrano_nomad_build_local_var_file_path(name, *args)
|
66
|
+
capistrano_nomad_build_local_path(capistrano_nomad_build_base_var_file_path(name, *args))
|
67
|
+
end
|
68
|
+
|
64
69
|
def capistrano_nomad_build_release_job_path(*args)
|
65
|
-
"#{release_path}
|
70
|
+
"#{release_path}#{capistrano_nomad_build_base_job_path(*args)}"
|
66
71
|
end
|
67
72
|
|
68
73
|
def capistrano_nomad_build_release_var_file_path(*args)
|
69
|
-
"#{release_path}
|
74
|
+
"#{release_path}#{capistrano_nomad_build_base_var_file_path(*args)}"
|
70
75
|
end
|
71
76
|
|
72
77
|
def capistrano_nomad_execute_nomad_command(*args)
|
@@ -158,7 +163,7 @@ def capistrano_nomad_build_jobs_docker_images(names, *args)
|
|
158
163
|
|
159
164
|
return false if image_types.empty?
|
160
165
|
|
161
|
-
image_types.each { |i| capistrano_nomad_build_docker_image_for_type(i
|
166
|
+
image_types.each { |i| capistrano_nomad_build_docker_image_for_type(i) }
|
162
167
|
end
|
163
168
|
|
164
169
|
def capistrano_nomad_push_jobs_docker_images(names, *args)
|
@@ -166,7 +171,7 @@ def capistrano_nomad_push_jobs_docker_images(names, *args)
|
|
166
171
|
|
167
172
|
return false if image_types.empty?
|
168
173
|
|
169
|
-
image_types.each { |i| capistrano_nomad_push_docker_image_for_type(i
|
174
|
+
image_types.each { |i| capistrano_nomad_push_docker_image_for_type(i) }
|
170
175
|
end
|
171
176
|
|
172
177
|
def capistrano_nomad_assemble_jobs_docker_images(names, *args)
|
@@ -180,7 +185,7 @@ def capistrano_nomad_upload_jobs(names, *args)
|
|
180
185
|
|
181
186
|
uniq_var_files.each do |var_file|
|
182
187
|
capistrano_nomad_upload_file(
|
183
|
-
local_path:
|
188
|
+
local_path: capistrano_nomad_build_local_var_file_path(var_file, *args),
|
184
189
|
remote_path: capistrano_nomad_build_release_var_file_path(var_file, *args),
|
185
190
|
)
|
186
191
|
end
|
@@ -196,7 +201,7 @@ def capistrano_nomad_upload_jobs(names, *args)
|
|
196
201
|
file_basename = nomad_job_options[:template] || name
|
197
202
|
|
198
203
|
capistrano_nomad_upload_file(
|
199
|
-
local_path:
|
204
|
+
local_path: capistrano_nomad_build_local_job_path(file_basename, *args),
|
200
205
|
remote_path: capistrano_nomad_build_release_job_path(name, *args),
|
201
206
|
erb_vars: erb_vars,
|
202
207
|
)
|
metadata
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-nomad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Hu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '7.0'
|
20
17
|
- - "<="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 7.0.8
|
@@ -24,9 +21,6 @@ dependencies:
|
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '7.0'
|
30
24
|
- - "<="
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: 7.0.8
|