capistrano-nomad 0.9.0 → 0.9.2

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: aa62522fae2723d97c57456a2404393ab7a231b9a8b690662b819fc60f9670fd
4
- data.tar.gz: 3cc2ec3994a56a70e3bf4de01d8676849661a80f42b259079461fa7b7f60e11a
3
+ metadata.gz: '064875b4478852c18387c8084ff4b0e5c2cb4e9377a6854724f46119b416ecf5'
4
+ data.tar.gz: 15069bfd33db0a2b497a7e6a1adf816669df6ba0b508364fb8a26728e46ae329
5
5
  SHA512:
6
- metadata.gz: 13de2ccba1589cce0c24add2a284d1b1932d38fb0d2ec9f1a3ed3715167d99ca9e2b181746041b59f7a89d48113e00d0608f3dd5138fd07a288db6e6bfc019c4
7
- data.tar.gz: f993181266c7eabe3580c8ebdb03bd39c0affe87415e77f099898d8753bb6eb6ef12463459c3a24b4de493cff09af51e6b0c13a85e7a767ec02b69b8d7e02e57
6
+ metadata.gz: eff94039fa9b7c506fbe139670639d326423c409813c4a10c97c15e79256f4bc5f65a181a2d8608af9bdd0aa51aeaeb999ad27e02836b2af8815b961999f8470
7
+ data.tar.gz: 255c76c93ba40a4fd35206b31d511a7a42e2954c4e4f072154effe68643e66a938fd0aacd3f029e7e5cfa37f13f82cb924606ab4bc2fc61be92234c5e3d7428d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.9.0)
4
+ capistrano-nomad (0.9.2)
5
5
  activesupport (<= 7.0.8)
6
6
  byebug
7
7
  capistrano (~> 3.0)
data/README.md CHANGED
@@ -102,11 +102,14 @@ 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
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]
108
-
109
- nomad_namespace :analytics do
105
+ nomad_job :"traefik-default", template: :admin,
106
+ erb_vars: { role: :default },
107
+ tags: [:traefik]
108
+ nomad_job :"traefik-secondary", template: :admin,
109
+ erb_vars: { role: :secondary },
110
+ tags: [:traefik]
111
+
112
+ nomad_namespace :analytics, tags: [:admin] do
110
113
  nomad_job :grafana
111
114
  end
112
115
 
@@ -131,20 +134,15 @@ cap production nomad:analytics:grafana:restart
131
134
  cap production nomad:postgres:status
132
135
  ```
133
136
 
134
- Most tasks are also available for namespace or `all`
137
+ Tasks can go by namespace or `all` namespaces, and can also be filtered by tags
135
138
 
136
139
  ```shell
137
140
  cap production nomad:analytics:deploy
138
141
  cap production nomad:analytics:upload_run
139
142
  cap production nomad:all:deploy
143
+ cap production nomad:all:deploy TAG=admin
140
144
  cap production nomad:all:upload_run
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
145
+ cap production nomad:all:upload_run TAGS=admin,redis
148
146
  ```
149
147
 
150
148
  Open console
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "capistrano-nomad"
5
- spec.version = "0.9.0"
5
+ spec.version = "0.9.2"
6
6
  spec.authors = ["James Hu"]
7
7
 
8
8
  spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
@@ -36,6 +36,13 @@ def nomad_namespace(namespace, **options, &block)
36
36
  end
37
37
 
38
38
  def nomad_job(name, attributes = {})
39
+ attributes[:tags] ||= []
40
+
41
+ # Tags added to namespace should be added to all jobs within
42
+ if (nomad_namespace_options = capistrano_nomad_fetch_namespace_options(@nomad_namespace))
43
+ attributes[:tags] += nomad_namespace_options[:tags] || []
44
+ end
45
+
39
46
  nomad_jobs = fetch(:nomad_jobs) || Hash.new { |h, n| h[n] = {} }
40
47
  nomad_jobs[@nomad_namespace][name] = attributes
41
48
 
@@ -243,7 +243,7 @@ def capistrano_nomad_upload(local_path:, remote_path:, erb_vars: {})
243
243
  end
244
244
 
245
245
  def capistrano_nomad_fetch_namespace_options(namespace)
246
- fetch(:nomad_namespaces).dig(namespace)
246
+ fetch(:nomad_namespaces)&.dig(namespace)
247
247
  end
248
248
 
249
249
  def capistrano_nomad_fetch_job_options(name, *args, namespace: nil)
@@ -255,9 +255,9 @@ 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
- # Can pass tags via command line (e.g. tag=foo or tags=foo,bar)
258
+ # Can pass tags via command line (e.g. TAG=foo or TAGS=foo,bar)
259
259
  tags =
260
- [ENV["tag"], ENV["tags"]].map do |tag_args|
260
+ [ENV["TAG"], ENV["TAGS"]].map do |tag_args|
261
261
  next unless tag_args.presence
262
262
 
263
263
  tag_args.split(",").map(&:presence).compact.map(&:to_sym)
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.9.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Hu