capistrano-nomad 0.7.0 → 0.7.1

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: d227d6f15f433cd6410884afc5572cf9c7e115a7365e00e244d3b95ca320f148
4
- data.tar.gz: a0cdd0e131319cd0f1a17a926afe70619d24550018de9731c96a610b075300c2
3
+ metadata.gz: eac8deb55e886ac97912499380a208f03ef15f7f952123afda2d6f8910e30df0
4
+ data.tar.gz: 730715ed63a01273775a7dccc403993866d73cb562de7cf70d0c22cf2754b493
5
5
  SHA512:
6
- metadata.gz: fd4aec6aecd6698d4ed23d4e1a2c3d3e8ded18467c1a4d8daee191e29304e2f91f85ca7d604681dba4ec6cb885308f0fb6985fb4e9d952e459fc7859a3b3917a
7
- data.tar.gz: 6009d60f5bd99e35fdb2961f6b9d860ea9db40ac844cebacf87b21ae58381eeefd35022fb58c7a6b88fa74da7e3acff3ee26a0f9a71a92e1b61495102bf53a21
6
+ metadata.gz: 933da9e873b7d6ed030983f0a441a157a4b2bac6c8803076a6dbeebb2bf3afeb922e57d5d3f5ba1b437f9da371386c9a09676d4e3f8dc32e68e3bfa86e5ae4b8
7
+ data.tar.gz: a87d69e22c6df4fcb9189a43279e399e27d9a625d1a86d728626fba63327daeed6a924113f019ed639d2782fae6db47367fbcd2568337faeafe9410ed3176b9f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.7.0)
4
+ capistrano-nomad (0.7.1)
5
5
  activesupport (<= 7.0.8)
6
6
  byebug
7
7
  capistrano (~> 3.0)
data/README.md CHANGED
@@ -61,7 +61,7 @@ end
61
61
 
62
62
  # Use hosted Docker image
63
63
  nomad_docker_image_type :postgres,
64
- alias_digest: "postgres:5.0.0"
64
+ alias: "postgres:5.0.0"
65
65
 
66
66
  # Use Docker image that will be built locally relative to project and push
67
67
  nomad_docker_image_type :backend,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "capistrano-nomad"
5
- spec.version = "0.7.0"
5
+ spec.version = "0.7.1"
6
6
  spec.authors = ["James Hu"]
7
7
 
8
8
  spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
@@ -133,8 +133,8 @@ def capistrano_nomad_push_docker_image_for_type(image_type, is_manifest_updated:
133
133
  return false unless [:local_push, :remote_push].include?(attributes[:strategy])
134
134
 
135
135
  run_locally do
136
- # Don't push Docker image if alias digest is already passed in
137
- unless alias_digest
136
+ # Only push Docker image if it was built from path
137
+ if attributes[:path]
138
138
  interaction_handler = CapistranoNomadDockerPushImageInteractionHandler.new
139
139
  image_alias = capistrano_nomad_build_docker_image_alias(image_type)
140
140
 
@@ -3,13 +3,15 @@ require "active_support/core_ext/hash"
3
3
  def nomad_docker_image_type(image_type, attributes = {})
4
4
  docker_image_types = fetch(:nomad_docker_image_types) || {}
5
5
  docker_image_types[image_type] = attributes.reverse_merge(
6
- # In case image doesn't get pushed, this will still be populated
7
- alias_digest: attributes[:alias],
8
-
9
6
  # By default build and push Docker image locally
10
7
  strategy: :local_push,
11
8
  )
12
9
 
10
+ raise ArgumentError, "passing in alias_digest is not allowed!" if attributes[:alias_digest]
11
+
12
+ # If Docker image doesn't get pushed, this will still be populated
13
+ docker_image_types[image_type][:alias_digest] = attributes[:alias]
14
+
13
15
  set(:nomad_docker_image_types, docker_image_types)
14
16
  end
15
17
 
@@ -180,48 +180,45 @@ def capistrano_nomad_upload(local_path:, remote_path:, erb_vars: {})
180
180
  Dir.glob("#{local_path}/*").each do |path|
181
181
  capistrano_nomad_upload(local_path: path, remote_path: "#{remote_path}/#{File.basename(path)}")
182
182
  end
183
+
184
+ # If file, attempt to always parse it as ERB
183
185
  else
184
- io =
185
- if File.extname(local_path) == ".erb"
186
- docker_image_types = fetch(:nomad_docker_image_types)
187
- docker_image_types_manifest = capistrano_nomad_read_docker_image_types_manifest
188
-
189
- # Merge manifest into image types
190
- docker_image_types_manifest.each do |manifest_image_type, manifest_attributes|
191
- docker_image_types[manifest_image_type]&.merge!(manifest_attributes) || {}
192
- end
193
-
194
- # Parse manifest files using ERB
195
- erb = ERB.new(File.open(local_path).read, trim_mode: "-")
196
-
197
- final_erb_vars = {
198
- git_commit_id: fetch(:current_revision) || capistrano_nomad_git_commit_id,
199
- docker_image_types: docker_image_types,
200
- }
201
-
202
- # Add global ERB vars
203
- final_erb_vars.merge!(fetch(:nomad_template_vars) || {})
204
-
205
- # Add job-specific ERB vars
206
- final_erb_vars.merge!(erb_vars)
207
-
208
- # We use a custom namespace class so that we can include helper methods into the namespace to make them available
209
- # for template to access
210
- namespace = CapistranoNomadErbNamespace.new(
211
- context: self,
212
- vars: final_erb_vars,
213
- )
214
-
215
- StringIO.new(erb.result(namespace.instance_eval { binding }))
216
- else
217
- File.open(local_path)
218
- end
186
+ docker_image_types = fetch(:nomad_docker_image_types)
187
+ docker_image_types_manifest = capistrano_nomad_read_docker_image_types_manifest
188
+
189
+ # Merge manifest into image types
190
+ docker_image_types_manifest.each do |manifest_image_type, manifest_attributes|
191
+ docker_image_types[manifest_image_type]&.merge!(manifest_attributes) || {}
192
+ end
193
+
194
+ # Parse manifest files using ERB
195
+ erb = ERB.new(File.open(local_path).read, trim_mode: "-")
196
+
197
+ final_erb_vars = {
198
+ git_commit_id: fetch(:current_revision) || capistrano_nomad_git_commit_id,
199
+ docker_image_types: docker_image_types,
200
+ }
201
+
202
+ # Add global ERB vars
203
+ final_erb_vars.merge!(fetch(:nomad_template_vars) || {})
204
+
205
+ # Add job-specific ERB vars
206
+ final_erb_vars.merge!(erb_vars)
207
+
208
+ # We use a custom namespace class so that we can include helper methods into the namespace to make them available
209
+ # for template to access
210
+ namespace = CapistranoNomadErbNamespace.new(
211
+ context: self,
212
+ vars: final_erb_vars,
213
+ )
214
+
215
+ string_io = StringIO.new(erb.result(namespace.instance_eval { binding }))
219
216
 
220
217
  capistrano_nomad_run_remotely do
221
218
  # Ensure parent directory exists
222
219
  execute(:mkdir, "-p", File.dirname(remote_path))
223
220
 
224
- upload!(io, remote_path)
221
+ upload!(string_io, remote_path)
225
222
  end
226
223
  end
227
224
  end
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.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Hu