capistrano-nomad 0.4.0 → 0.4.2

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: decb45a7958cc1a3b2bc96d8d48e72ff6132d160eac93e81e995b59661dfc5ff
4
- data.tar.gz: adaf5bb0a848328cfd830f861b1f8ff744e46bba6eab66f9180fdd21f1bad57b
3
+ metadata.gz: 02c77eac2e5164a6644400d4eca6b03b57dffac252ad90d224f3b2c184bbda6c
4
+ data.tar.gz: da268efd0e1118b5fab7b1190469b3b3154221dfedf641a4f2fd41b416f9cb94
5
5
  SHA512:
6
- metadata.gz: cac6624d0caceedcd3ac833d87a3a498d0a023b74d604b626413df62f15e107324a538035d93e9a39800eba57dddca4b6a70a8bd4825fed99a002411634254a5
7
- data.tar.gz: 3a622b2f506d8a3d98f5c97646fa6da662b8b6ea86e86c9e315c10a62ef4f88acd7befc7f22167f52b8de3b0d9ea9fc8dfccf5924da7da74a061f3b1ba450ea8
6
+ metadata.gz: c5b1c53a098c84fa455ed9774376fe646a154436e96d2807050b0cb510484073d7993040571ba231f547478e4a43ee3f105690d7899f8f6a38dac3992567e88f
7
+ data.tar.gz: a3936fbea10215f136ef8630d5ca0d8253991af7bf16d02b5a7d1615eeaaa11fc6ed38376608a0cfe21b301d34d245196adb5941749fad885f2d574bbd2f523d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.4.0)
4
+ capistrano-nomad (0.4.2)
5
5
  activesupport (<= 7.0.8)
6
6
  byebug
7
7
  capistrano (~> 3.0)
data/README.md CHANGED
@@ -42,7 +42,7 @@ nomad_namespace :analytics do
42
42
  end
43
43
  ```
44
44
 
45
- Utilize tasks
45
+ Deploy with
46
46
 
47
47
  ```shell
48
48
  cap production nomad:app:deploy
@@ -50,6 +50,14 @@ cap production nomad:redis:purge
50
50
  cap production nomad:analytics:grafana:deploy
51
51
  ```
52
52
 
53
+ Open console with
54
+
55
+ ```shell
56
+ cap production nomad:app:console
57
+ cap production nomad:app:console TASK=custom-task-name
58
+ cap production nomad:analytics:grafana:console
59
+ ```
60
+
53
61
  ## Development
54
62
 
55
63
  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.4.0"
5
+ spec.version = "0.4.2"
6
6
  spec.authors = ["James Hu"]
7
7
 
8
8
  spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
@@ -76,19 +76,13 @@ def capistrano_nomad_build_docker_image_for_type(image_type)
76
76
  "--platform linux/amd64",
77
77
  ]
78
78
 
79
- build_args =
80
- if attributes[:build_args].is_a?(Proc)
81
- proc_args = attributes[:build_args].arity == 1 ? [capistrano_nomad_fetch_git_commit_id] : []
82
-
83
- attributes[:build_args].call(*proc_args)
84
- else
85
- attributes[:build_args]
86
- end
87
-
88
79
  if (target = attributes[:target])
89
80
  args << "--target #{target}"
90
81
  end
91
82
 
83
+ build_args = attributes[:build_args]
84
+ build_args = build_args.call if build_args&.is_a?(Proc)
85
+
92
86
  (build_args || []).each do |key, value|
93
87
  args << "--build-arg #{key}=#{value}"
94
88
  end
@@ -107,9 +107,9 @@ def nomad_job(name, attributes = {})
107
107
  end
108
108
  end
109
109
 
110
- desc "Open console to #{description_name} job"
110
+ desc "Open console to #{description_name} job. Specify task by passing TASK environment variable"
111
111
  task :console do
112
- capistrano_nomad_exec_within_job(name, "/bin/bash", namespace: namespace)
112
+ capistrano_nomad_exec_within_job(name, "/bin/bash", namespace: namespace, task: ENV["TASK"].presence)
113
113
  end
114
114
  end
115
115
  end
@@ -4,6 +4,6 @@ def capistrano_nomad_git
4
4
  @capistrano_nomad_git ||= Git.open(".")
5
5
  end
6
6
 
7
- def capistrano_nomad_fetch_git_commit_id
8
- capistrano_nomad_git.log.first.sha
7
+ def capistrano_nomad_git_commit_id
8
+ @capistrano_nomad_git_commit_id ||= capistrano_nomad_git.log.first.sha
9
9
  end
@@ -105,8 +105,14 @@ def capistrano_nomad_execute_nomad_command(*args)
105
105
  end
106
106
  end
107
107
 
108
- def capistrano_nomad_exec_within_job(name, command, namespace: nil)
109
- capistrano_nomad_execute_nomad_command(:alloc, :exec, { namespace: namespace, task: name, job: name }, command)
108
+ def capistrano_nomad_exec_within_job(name, command, namespace: nil, task: nil)
109
+ capistrano_nomad_execute_nomad_command(
110
+ :alloc,
111
+ :exec,
112
+ { namespace: namespace, task: task || name, job: true },
113
+ name,
114
+ command,
115
+ )
110
116
  end
111
117
 
112
118
  def capistrano_nomad_upload_file(local_path:, remote_path:, erb_vars: {})
@@ -122,7 +128,7 @@ def capistrano_nomad_upload_file(local_path:, remote_path:, erb_vars: {})
122
128
  erb = ERB.new(File.open(local_path).read, trim_mode: "-")
123
129
 
124
130
  final_erb_vars = {
125
- git_commit_id: fetch(:current_revision) || capistrano_nomad_fetch_git_commit_id,
131
+ git_commit_id: fetch(:current_revision) || capistrano_nomad_git_commit_id,
126
132
  docker_image_types: docker_image_types,
127
133
  }
128
134
 
@@ -6,7 +6,7 @@ class Capistrano::SCM::GitLocal < Capistrano::SCM::Plugin
6
6
  namespace :git_local do
7
7
  task :set_current_revision do
8
8
  on release_roles :manager do
9
- set :current_revision, capistrano_nomad_fetch_git_commit_id
9
+ set :current_revision, capistrano_nomad_git_commit_id
10
10
  end
11
11
  end
12
12
 
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.4.0
4
+ version: 0.4.2
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-11 00:00:00.000000000 Z
11
+ date: 2023-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport