capistrano-nomad 0.10.0 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/capistrano-nomad.gemspec +1 -1
- data/lib/capistrano/nomad/helpers/dsl.rb +6 -2
- data/lib/capistrano/nomad/helpers/nomad.rb +12 -12
- data/lib/capistrano/nomad/tasks/nomad.rake +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e53ea71739d8bf0e6a35acc8fc6cf53b38793e2cb84406eabcbcae39eb3c95a
|
4
|
+
data.tar.gz: 9acd6a38e395394f5b6fd2c29b7f79ff57ab4b5f03580b507131f4f14fa0e73c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b40e9dc02e6e447f20ba8f22c8c2916512b6d16204da16268f9156e5c48e77743adbacc51c06e0bb1df150bdf2d0fd2e9f6631ca1b2684830b76b72dfff06b9e
|
7
|
+
data.tar.gz: a3a36894b7296ada17af461c3f61874f17c72be48f9307fc25b7b5e7940b6292a636249442f189fc38a8b966501bc45482202a3e7d9a5ddcf45d5bdd0e3b8078
|
data/Gemfile.lock
CHANGED
data/capistrano-nomad.gemspec
CHANGED
@@ -16,6 +16,8 @@ def nomad_docker_image_type(image_type, attributes = {})
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def nomad_namespace(namespace, **options, &block)
|
19
|
+
raise ArgumentError, "cannot define default nomad namespace" if namespace == :default
|
20
|
+
|
19
21
|
nomad_namespaces = fetch(:nomad_namespaces) || {}
|
20
22
|
nomad_namespaces[namespace] = options
|
21
23
|
set(:nomad_namespaces, nomad_namespaces)
|
@@ -53,7 +55,7 @@ def nomad_job(name, attributes = {})
|
|
53
55
|
|
54
56
|
define_tasks = lambda do |namespace: nil|
|
55
57
|
description_name = ""
|
56
|
-
description_name << "#{namespace}/" if namespace
|
58
|
+
description_name << "#{namespace}/" if namespace != :default
|
57
59
|
description_name << name.to_s
|
58
60
|
|
59
61
|
namespace(name) do
|
@@ -164,8 +166,10 @@ def nomad_job(name, attributes = {})
|
|
164
166
|
end
|
165
167
|
|
166
168
|
namespace(:nomad) do
|
167
|
-
# Define tasks for service
|
168
169
|
if @nomad_namespace
|
170
|
+
# Also define tasks without namespace for default Nomad namespace
|
171
|
+
define_tasks.call(namespace: @nomad_namespace) if @nomad_namespace == :default
|
172
|
+
|
169
173
|
namespace(@nomad_namespace) do
|
170
174
|
define_tasks.call(namespace: @nomad_namespace)
|
171
175
|
end
|
@@ -29,10 +29,10 @@ def capistrano_nomad_ensure_absolute_path(path)
|
|
29
29
|
path[0] == "/" ? path : "/#{path}"
|
30
30
|
end
|
31
31
|
|
32
|
-
def capistrano_nomad_build_file_path(parent_path, basename, kind: nil, namespace:
|
32
|
+
def capistrano_nomad_build_file_path(parent_path, basename, kind: nil, namespace: :default)
|
33
33
|
segments = [parent_path]
|
34
34
|
|
35
|
-
|
35
|
+
unless namespace == :default
|
36
36
|
case kind
|
37
37
|
|
38
38
|
# Always upload to namespace folder on remote
|
@@ -132,7 +132,7 @@ def capistrano_nomad_capture_nomad_command(*args)
|
|
132
132
|
output
|
133
133
|
end
|
134
134
|
|
135
|
-
def capistrano_nomad_find_job_task_details(name, namespace:
|
135
|
+
def capistrano_nomad_find_job_task_details(name, namespace: :default, task: nil)
|
136
136
|
task = task.presence || name
|
137
137
|
|
138
138
|
# Find alloc id that contains task
|
@@ -170,7 +170,7 @@ def capistrano_nomad_find_job_task_details(name, namespace: nil, task: nil)
|
|
170
170
|
}
|
171
171
|
end
|
172
172
|
|
173
|
-
def capistrano_nomad_exec_within_job(name, command, namespace:
|
173
|
+
def capistrano_nomad_exec_within_job(name, command, namespace: :default, task: nil)
|
174
174
|
capistrano_nomad_run_remotely do
|
175
175
|
if (task_details = capistrano_nomad_find_job_task_details(name, namespace: namespace, task: task))
|
176
176
|
capistrano_nomad_execute_nomad_command(
|
@@ -246,7 +246,7 @@ def capistrano_nomad_fetch_namespace_options(namespace)
|
|
246
246
|
fetch(:nomad_namespaces)&.dig(namespace)
|
247
247
|
end
|
248
248
|
|
249
|
-
def capistrano_nomad_fetch_job_options(name, *args, namespace:
|
249
|
+
def capistrano_nomad_fetch_job_options(name, *args, namespace: :default)
|
250
250
|
fetch(:nomad_jobs).dig(namespace, name.to_sym, *args)
|
251
251
|
end
|
252
252
|
|
@@ -254,7 +254,7 @@ def capistrano_nomad_fetch_job_var_files(name, *args)
|
|
254
254
|
capistrano_nomad_fetch_job_options(name, :var_files, *args) || []
|
255
255
|
end
|
256
256
|
|
257
|
-
def capistrano_nomad_fetch_jobs_names_by_namespace(namespace:
|
257
|
+
def capistrano_nomad_fetch_jobs_names_by_namespace(namespace: :default)
|
258
258
|
# Can pass tags via command line (e.g. TAG=foo or TAGS=foo,bar)
|
259
259
|
tags =
|
260
260
|
[ENV["TAG"], ENV["TAGS"]].map do |tag_args|
|
@@ -277,11 +277,11 @@ def capistrano_nomad_fetch_jobs_names_by_namespace(namespace: nil)
|
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
|
-
def capistrano_nomad_fetch_jobs_docker_image_types(names, namespace:
|
280
|
+
def capistrano_nomad_fetch_jobs_docker_image_types(names, namespace: :default)
|
281
281
|
names.map { |n| fetch(:nomad_jobs).dig(namespace, n.to_sym, :docker_image_types) }.flatten.compact.uniq
|
282
282
|
end
|
283
283
|
|
284
|
-
def capistrano_nomad_define_group_tasks(namespace:
|
284
|
+
def capistrano_nomad_define_group_tasks(namespace:)
|
285
285
|
define_tasks = lambda do |nomad_namespace: nil|
|
286
286
|
desc "Build #{nomad_namespace} job Docker images"
|
287
287
|
task :build do
|
@@ -429,7 +429,7 @@ def capistrano_nomad_plan_jobs(names, *args)
|
|
429
429
|
end
|
430
430
|
end
|
431
431
|
|
432
|
-
def capistrano_nomad_run_jobs(names, namespace:
|
432
|
+
def capistrano_nomad_run_jobs(names, namespace: :default, is_detached: true)
|
433
433
|
names.each do |name|
|
434
434
|
run_options = {
|
435
435
|
namespace: namespace,
|
@@ -501,7 +501,7 @@ def capistrano_nomad_stop_jobs(names, **options)
|
|
501
501
|
end
|
502
502
|
end
|
503
503
|
|
504
|
-
def capistrano_nomad_purge_jobs(names, namespace:
|
504
|
+
def capistrano_nomad_purge_jobs(names, namespace: :default, is_detached: true)
|
505
505
|
names.each do |name|
|
506
506
|
capistrano_nomad_execute_nomad_command(:stop, { namespace: namespace, purge: true, detach: is_detached }, name)
|
507
507
|
end
|
@@ -511,7 +511,7 @@ def capistrano_nomad_display_job_status(name, **options)
|
|
511
511
|
capistrano_nomad_execute_nomad_command(:status, options, name)
|
512
512
|
end
|
513
513
|
|
514
|
-
def capistrano_nomad_display_job_logs(name, namespace:
|
514
|
+
def capistrano_nomad_display_job_logs(name, namespace: :default, **options)
|
515
515
|
if (task_details = capistrano_nomad_find_job_task_details(name, namespace: namespace, task: ENV["TASK"]))
|
516
516
|
capistrano_nomad_execute_nomad_command(
|
517
517
|
:alloc,
|
@@ -534,7 +534,7 @@ def capistrano_nomad_tail_job_logs(*args, **options)
|
|
534
534
|
capistrano_nomad_display_job_logs(*args, **options.merge(tail: true, n: 50))
|
535
535
|
end
|
536
536
|
|
537
|
-
def capistrano_nomad_open_job_ui(name, namespace:
|
537
|
+
def capistrano_nomad_open_job_ui(name, namespace: :default)
|
538
538
|
run_locally do
|
539
539
|
url = "#{fetch(:nomad_ui_url)}/ui/jobs/#{name}"
|
540
540
|
url += "@#{namespace}" if namespace
|