capistrano-nomad 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38466c64a01144c2504b25cffc4d0a504323d8426a6d266b8596afbde174cc3b
4
- data.tar.gz: 4f1921130d34135d6399dc66014ae09fef023a32d468729c001da69b46677b6f
3
+ metadata.gz: aa62522fae2723d97c57456a2404393ab7a231b9a8b690662b819fc60f9670fd
4
+ data.tar.gz: 3cc2ec3994a56a70e3bf4de01d8676849661a80f42b259079461fa7b7f60e11a
5
5
  SHA512:
6
- metadata.gz: b19ed0fa9f0bd9f69b2679b26d282f2263307313b6376f95f32e65eb7ba08b7645e93d3e83232718a05abd5e8fc4ad378ba301d59a0fa6605cf0b5a30d08ffbf
7
- data.tar.gz: 9ea11f2baf2ba068b5150b0294dfbba1142e5a89bdec74fa692e338cc02f05a1bbb313633e80d496f7f0b4350f14a4659003c4e1c9be41339c45c3b2381c7799
6
+ metadata.gz: 13de2ccba1589cce0c24add2a284d1b1932d38fb0d2ec9f1a3ed3715167d99ca9e2b181746041b59f7a89d48113e00d0608f3dd5138fd07a288db6e6bfc019c4
7
+ data.tar.gz: f993181266c7eabe3580c8ebdb03bd39c0affe87415e77f099898d8753bb6eb6ef12463459c3a24b4de493cff09af51e6b0c13a85e7a767ec02b69b8d7e02e57
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.8.6)
4
+ capistrano-nomad (0.9.0)
5
5
  activesupport (<= 7.0.8)
6
6
  byebug
7
7
  capistrano (~> 3.0)
data/README.md CHANGED
@@ -101,9 +101,10 @@ nomad_docker_image_type :restic,
101
101
  nomad_job :backend, docker_image_types: [:backend], var_files: [:rails]
102
102
  nomad_job :frontend
103
103
  nomad_job :postgres, docker_image_types: [:postgres]
104
- nomad_job :redis, docker_image_types: [:redis]
105
- nomad_job :"traefik-default", template: :traefik, erb_vars: { role: :default }
106
- nomad_job :"traefik-secondary", template: :traefik, erb_vars: { role: :secondary }
104
+ nomad_job :redis, docker_image_types: [:redis], tags: [:redis]
105
+ nomad_job :"traefik-default", template: :traefik, erb_vars: { role: :default }, tags: [:traefik]
106
+ nomad_job :"traefik-secondary", template: :traefik, erb_vars: { role: :secondary }, tags: [:traefik]
107
+ nomad_job :"traefik-tertiary", template: :traefik, erb_vars: { role: :secondary }, tags: [:traefik]
107
108
 
108
109
  nomad_namespace :analytics do
109
110
  nomad_job :grafana
@@ -130,7 +131,7 @@ cap production nomad:analytics:grafana:restart
130
131
  cap production nomad:postgres:status
131
132
  ```
132
133
 
133
- Most tasks are also available for namespace or all
134
+ Most tasks are also available for namespace or `all`
134
135
 
135
136
  ```shell
136
137
  cap production nomad:analytics:deploy
@@ -139,6 +140,13 @@ cap production nomad:all:deploy
139
140
  cap production nomad:all:upload_run
140
141
  ```
141
142
 
143
+ Filter by tags
144
+
145
+ ```shell
146
+ cap production nomad:all:deploy tag=traefik
147
+ cap production nomad:all:upload_run tags=traefik,redis
148
+ ```
149
+
142
150
  Open console
143
151
 
144
152
  ```shell
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "capistrano-nomad"
5
- spec.version = "0.8.6"
5
+ spec.version = "0.9.0"
6
6
  spec.authors = ["James Hu"]
7
7
 
8
8
  spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
@@ -255,12 +255,26 @@ def capistrano_nomad_fetch_job_var_files(name, *args)
255
255
  end
256
256
 
257
257
  def capistrano_nomad_fetch_jobs_names_by_namespace(namespace: :all)
258
- jobs_names_by_namespace = fetch(:nomad_jobs).transform_values(&:keys)
258
+ # Can pass tags via command line (e.g. tag=foo or tags=foo,bar)
259
+ tags =
260
+ [ENV["tag"], ENV["tags"]].map do |tag_args|
261
+ next unless tag_args.presence
259
262
 
260
- # Filter by namespace unless it's all
261
- jobs_names_by_namespace = jobs_names_by_namespace.slice(namespace) unless namespace == :all
263
+ tag_args.split(",").map(&:presence).compact.map(&:to_sym)
264
+ end
265
+ .flatten
266
+ .compact
267
+
268
+ fetch(:nomad_jobs).each_with_object({}) do |(jobs_namespace, jobs_options), hash|
269
+ next if namespace != :all && namespace != jobs_namespace
270
+
271
+ hash[jobs_namespace] = jobs_options.each_with_object([]) do |(job_name, job_options), collection|
272
+ # Filter jobs by tags if specified
273
+ next if tags.any? && ((job_options[:tags]&.map(&:to_sym) || []) & tags).empty?
262
274
 
263
- jobs_names_by_namespace
275
+ collection << job_name
276
+ end
277
+ end
264
278
  end
265
279
 
266
280
  def capistrano_nomad_fetch_jobs_docker_image_types(names, namespace: nil)
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.8.6
4
+ version: 0.9.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: 2024-07-18 00:00:00.000000000 Z
11
+ date: 2024-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport