capistrano-nomad 0.7.0 → 0.7.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/capistrano-nomad.gemspec +1 -1
- data/lib/capistrano/nomad/helpers/docker.rb +2 -2
- data/lib/capistrano/nomad/helpers/dsl.rb +5 -3
- data/lib/capistrano/nomad/helpers/nomad.rb +33 -36
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eac8deb55e886ac97912499380a208f03ef15f7f952123afda2d6f8910e30df0
|
4
|
+
data.tar.gz: 730715ed63a01273775a7dccc403993866d73cb562de7cf70d0c22cf2754b493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 933da9e873b7d6ed030983f0a441a157a4b2bac6c8803076a6dbeebb2bf3afeb922e57d5d3f5ba1b437f9da371386c9a09676d4e3f8dc32e68e3bfa86e5ae4b8
|
7
|
+
data.tar.gz: a87d69e22c6df4fcb9189a43279e399e27d9a625d1a86d728626fba63327daeed6a924113f019ed639d2782fae6db47367fbcd2568337faeafe9410ed3176b9f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/capistrano-nomad.gemspec
CHANGED
@@ -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
|
-
#
|
137
|
-
|
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
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
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!(
|
221
|
+
upload!(string_io, remote_path)
|
225
222
|
end
|
226
223
|
end
|
227
224
|
end
|