capistrano-nomad 0.6.3 → 0.6.4

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: 1f13cb3a6f203bc88f1bad802dea89660937818fe4568824fb0f2aa9ed789fab
4
- data.tar.gz: '09f27219c86a2fe67e2d47a660cabdef3844517954feba31141d4c38fb20d6a5'
3
+ metadata.gz: 707ded6b01d5903708a362ef6e98f3c56d5e52fd1557bfad47f1844cb7d6c96e
4
+ data.tar.gz: 68ea61e7025400e99c97683b8f3390357a0f04cf5b173846bba378d8bdd5fa3d
5
5
  SHA512:
6
- metadata.gz: 3cd44e5fb4c6cbd3db75cc22f67ef116d0ece07965c1e20387cebee287bf28de7b09ee9d8cd5d9b0cff29a1bb0ae0a5d16d0deb451cdeb731ddcdd32fbfa0a57
7
- data.tar.gz: 9759e600f1bc654c9093b5e72606de756bf220271a11ee6a0b8fc770b78f78e638f4557ba6054e57326f4cd5ef4ee05de6183a66f1e0351fc9129bd5bbcf4177
6
+ metadata.gz: 19a5ee3bcddf663ed3820245f10d0c35dee3cf2d1659b44f61947696c7ea24c263696c3c25d6dba032d14293706f0b9b68ee3e9cdbd41b66309e43eb92a0e297
7
+ data.tar.gz: b20019a85564cc4eee312bfaa17934becab4b73c2505c7a0b9511b1759b320c56fda3656b7f2b80b3cd090e347f05f5c0a2ef3e283a078850636c37ea58f20fb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.6.3)
4
+ capistrano-nomad (0.6.4)
5
5
  activesupport (<= 7.0.8)
6
6
  byebug
7
7
  capistrano (~> 3.0)
data/README.md CHANGED
@@ -90,6 +90,12 @@ cap production nomad:app:console TASK=custom-task-name
90
90
  cap production nomad:analytics:grafana:console
91
91
  ```
92
92
 
93
+ Create missing and delete unused namespaces
94
+
95
+ ```shell
96
+ cap production nomad:all:replace_namespaces
97
+ ```
98
+
93
99
  ## Development
94
100
 
95
101
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "capistrano-nomad"
5
- spec.version = "0.6.3"
5
+ spec.version = "0.6.4"
6
6
  spec.authors = ["James Hu"]
7
7
 
8
8
  spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
@@ -116,7 +116,7 @@ end
116
116
  def capistrano_nomad_capture_nomad_command(*args)
117
117
  output = nil
118
118
 
119
- on(roles(:manager)) do |host|
119
+ on(roles(:manager)) do |_host|
120
120
  output = capistrano_nomad_run_nomad_command(:capture, *args)
121
121
  end
122
122
 
@@ -125,7 +125,7 @@ end
125
125
 
126
126
  def capistrano_nomad_exec_within_job(name, command, namespace: nil, task: nil)
127
127
  on(roles(:manager)) do
128
- task = name unless task
128
+ task ||= name
129
129
 
130
130
  # Find alloc id that contains task
131
131
  output = capistrano_nomad_capture_nomad_command(
@@ -53,6 +53,25 @@ namespace :nomad do
53
53
  capistrano_nomad_purge_jobs(names, namespace: namespace)
54
54
  end
55
55
  end
56
+
57
+ desc "Create missing and remove unused namespaces"
58
+ task :replace_namespaces do
59
+ output = capistrano_nomad_capture_nomad_command(:namespace, :list, t: "'{{range .}}{{ .Name }}|{{end}}'")
60
+ current_namespaces = output.split("|").compact.map(&:to_sym)
61
+ desired_namespaces = fetch(:nomad_jobs).keys
62
+ missing_namespaces = desired_namespaces - current_namespaces
63
+ unused_namespaces = current_namespaces - desired_namespaces
64
+
65
+ # Remove unused namespaces
66
+ unused_namespaces.each do |namespace|
67
+ capistrano_nomad_execute_nomad_command(:namespace, :delete, namespace)
68
+ end
69
+
70
+ # Create missing namespaces
71
+ missing_namespaces.each do |namespace|
72
+ capistrano_nomad_execute_nomad_command(:namespace, :apply, namespace)
73
+ end
74
+ end
56
75
  end
57
76
 
58
77
  namespace :docker_images do
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.6.3
4
+ version: 0.6.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: 2023-10-31 00:00:00.000000000 Z
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport