capistrano-nomad 0.10.0 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9993fb04b78b68b03c055faa66454360543c92108f2e410f7156bedf7158f763
4
- data.tar.gz: 20b4708abc11215f259bc46b8b4c7f4f0606fb0d2ff7e3c862c799b850ead5ee
3
+ metadata.gz: 9e53ea71739d8bf0e6a35acc8fc6cf53b38793e2cb84406eabcbcae39eb3c95a
4
+ data.tar.gz: 9acd6a38e395394f5b6fd2c29b7f79ff57ab4b5f03580b507131f4f14fa0e73c
5
5
  SHA512:
6
- metadata.gz: 86d6750e7e181d120db5b56da6c5b7b083310901939e452aee8e7a6de12db22544f2c1accfe8fb9790c75c188644ed0108446a8281875566b0d6243ae8db6191
7
- data.tar.gz: f80d0003e093e3ed5e0fefc69b6b89db158064145c7c21573944b8fc88f8beb40a1cb0b40fbbbb956856bbc637f217a72001c5a1de10ed992ea46e6fd45b8809
6
+ metadata.gz: b40e9dc02e6e447f20ba8f22c8c2916512b6d16204da16268f9156e5c48e77743adbacc51c06e0bb1df150bdf2d0fd2e9f6631ca1b2684830b76b72dfff06b9e
7
+ data.tar.gz: a3a36894b7296ada17af461c3f61874f17c72be48f9307fc25b7b5e7940b6292a636249442f189fc38a8b966501bc45482202a3e7d9a5ddcf45d5bdd0e3b8078
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.10.0)
4
+ capistrano-nomad (0.10.3)
5
5
  activesupport (<= 7.0.8)
6
6
  byebug
7
7
  capistrano (~> 3.0)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "capistrano-nomad"
5
- spec.version = "0.10.0"
5
+ spec.version = "0.10.3"
6
6
  spec.authors = ["James Hu"]
7
7
 
8
8
  spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
@@ -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: nil)
32
+ def capistrano_nomad_build_file_path(parent_path, basename, kind: nil, namespace: :default)
33
33
  segments = [parent_path]
34
34
 
35
- if namespace
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: nil, task: nil)
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: nil, task: nil)
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: nil)
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: nil)
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: nil)
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: nil)
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: nil, is_detached: true)
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: nil, is_detached: true)
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: nil, **options)
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: nil)
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
@@ -1,6 +1,6 @@
1
1
  namespace :nomad do
2
2
  # Define tasks for all jobs
3
- capistrano_nomad_define_group_tasks
3
+ capistrano_nomad_define_group_tasks(namespace: nil)
4
4
 
5
5
  desc "Create missing and remove unused namespaces"
6
6
  task :modify_namespaces do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-nomad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Hu