capistrano-nomad 0.10.1 → 0.10.4

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: 76af53f1a2764deb4b91363674b6627d7b6017a30609e067d42b66cdbd5c9fc0
4
- data.tar.gz: 64825bb8a9bdccf833f23cb36aeb10cba6f516bbac8e6690193eb1674339fb94
3
+ metadata.gz: 44bb762da0b1f230e620bf5dded1c46fb791af7b3fa10bd55b8625bb378acf46
4
+ data.tar.gz: 3a9d575d16aeacd9cc6ffbd1b7c228eac10e8b158b8606da91afa8d10fe796ce
5
5
  SHA512:
6
- metadata.gz: d359a15febd84d1303360f8d9c51faf026fa6388cf6a8b97edc7fa99cee59007c4999d040935bad0351ad1fa3bc1aca5908819b1cd1fc302d711b09a7d3a42e6
7
- data.tar.gz: 5bf77756a9d1dc2bc28ded978f0523fff65059932154c1930545dd4b06930012d45ed646108f593802e606559b2aa4c2cae867f2012bef83245308b30d1a52dd
6
+ metadata.gz: fb3ec9b2cb4977a3b0834f8ce7d856efaf74325d5079f086f29b06bb9a4658dfba067e137f32cf362d34884cce1d781ea688e40cb8a58d341c51dba477e23862
7
+ data.tar.gz: 1e4beb478de4f084f058b295aaeb08bf92cce4a03397ee1cdae2eb447a25c90804ac79baa758199c696a4479da928cfddc24680978854662d9d795315e32e3b3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.10.1)
4
+ capistrano-nomad (0.10.4)
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.1"
5
+ spec.version = "0.10.4"
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
@@ -32,7 +32,7 @@ end
32
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
@@ -135,14 +135,18 @@ end
135
135
  def capistrano_nomad_find_job_task_details(name, namespace: :default, task: nil)
136
136
  task = task.presence || name
137
137
 
138
- # Find alloc id that contains task
138
+ # Find alloc id that contains task that is also running
139
139
  allocs_output = capistrano_nomad_capture_nomad_command(
140
140
  :job,
141
141
  :allocs,
142
- { namespace: namespace, t: "'{{range .}}{{ .ID }},{{ .TaskGroup }}|{{end}}'" },
142
+ { namespace: namespace, t: "'{{range .}}{{ .ID }},{{ .ClientStatus }},{{ .TaskGroup }}|{{end}}'" },
143
143
  name,
144
144
  )
145
- alloc_id = allocs_output.split("|").map { |s| s.split(",") }.find { |_, t| t == task.to_s }&.first
145
+ alloc_id = allocs_output
146
+ .split("|")
147
+ .map { |s| s.split(",") }
148
+ .find { |_, s, t| s == "running" && t == task.to_s }
149
+ &.first
146
150
 
147
151
  # Can't continue if we can't choose an alloc id
148
152
  return unless alloc_id
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-nomad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Hu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-28 00:00:00.000000000 Z
11
+ date: 2024-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport