capistrano-nomad 0.5.1 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b71f2fc4375d471be5284038182715e6a4673dfb047b24f94409d9249509706
4
- data.tar.gz: 04d0c5906845f755b6c265b8f3ff943a3dcff1b2d4d4df66591f3e9aacb80063
3
+ metadata.gz: fd8143ad35ea4f16a890256e65a5a73fab979acd0e63fa5471e8c75248c5fad8
4
+ data.tar.gz: cdf8f7552d3512ea4968208690ec537040915e42a59b51aef4bd8c85c81e95a1
5
5
  SHA512:
6
- metadata.gz: 3417e1276e5e377db5e52051c39f5955a3ba50cd83243e51d6f1a2919d2e4eda7a602ee55bab9a0c91f4e4d85fc4505c18886e8164608515bc681b663d641b60
7
- data.tar.gz: 66fbf60d498d0b312256a6788292c9c5ad9e84384c34152e0d000c2045267bae57b96483cdd894f0f5a5f138ba3b89c179c2d265b8eebb4c29c3a496918ed19c
6
+ metadata.gz: 52b3e33004964a0ea317bcd55478d02aa2088ded9c7df715be7119028588b9c3f848e63fd4fa8a85f3345c9e5203579428a71b79c3debfe16e5028b37183d477
7
+ data.tar.gz: f972389f3c4411a75162961f0545605ab87c92d6a81d4192db78e457bd320c8a87bccdcf3a61bb9f9e556c6f64d4b99cb3347752113951612edeb89b3fb9d2e4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.5.1)
4
+ capistrano-nomad (0.6.1)
5
5
  activesupport (<= 7.0.8)
6
6
  byebug
7
7
  capistrano (~> 3.0)
data/README.md CHANGED
@@ -31,14 +31,39 @@ require "capistrano/nomad"
31
31
  install_plugin Capistrano::Nomad
32
32
  ```
33
33
 
34
- Define Nomad jobs within `deploy.rb`
34
+ Within `deploy.rb`
35
35
 
36
36
  ```ruby
37
- nomad_job :app
38
- nomad_job :redis
37
+ set :nomad_jobs_path, "nomad/jobs"
38
+ set :nomad_var_files_path, "nomad/vars"
39
+
40
+ # Accessible in all .erb files
41
+ set :nomad_erb_vars, (lambda do
42
+ {
43
+ env_name: fetch(:stage).to_sym,
44
+ domain: fetch(:domain),
45
+ foo: "bar,"
46
+ }
47
+ end)
48
+
49
+ # Docker image types
50
+ nomad_docker_image_type :backend,
51
+ path: "local/path/backend",
52
+ alias: ->(image_type:) { "gcr.io/axsuul/#{image_type}" },
53
+ target: "release",
54
+ build_args: { foo: "bar" }
55
+ nomad_docker_image_type :redis,
56
+ path: "/absolute/path/redis",
57
+ alias: "gcr.io/axsuul/redis"
58
+
59
+ # Jobs
60
+ nomad_job :frontend
61
+ nomad_job :backend, docker_image_types: [:backend], var_files: [:rails]
62
+ nomad_job :redis, docker_image_types: [:redis]
39
63
 
40
64
  nomad_namespace :analytics do
41
65
  nomad_job :grafana
66
+ nomad_job :"node-exporter"
42
67
  end
43
68
  ```
44
69
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "capistrano-nomad"
5
- spec.version = "0.5.1"
5
+ spec.version = "0.6.1"
6
6
  spec.authors = ["James Hu"]
7
7
 
8
8
  spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
@@ -101,7 +101,7 @@ def capistrano_nomad_build_docker_image_for_type(image_type)
101
101
  image_alias_args << "--tag #{tag}"
102
102
  end
103
103
 
104
- execute("docker build #{image_alias_args.join(' ')} .#{capistrano_nomad_root.join(attributes[:path])}")
104
+ execute("docker build #{image_alias_args.join(' ')} #{capistrano_nomad_root.join(attributes[:path])}")
105
105
  end
106
106
  end
107
107
 
@@ -35,6 +35,10 @@ class CapistranoNomadErbNamespace
35
35
  # rubocop:enable Style/MissingRespondToMissing
36
36
  end
37
37
 
38
+ def capistrano_nomad_ensure_absolute_path(path)
39
+ path[0] == "/" ? path : "/#{path}"
40
+ end
41
+
38
42
  def capistrano_nomad_build_file_path(parent_path, basename, namespace: nil)
39
43
  segments = [parent_path]
40
44
  segments << namespace if namespace
@@ -51,11 +55,11 @@ def capistrano_nomad_build_base_var_file_path(*args)
51
55
  capistrano_nomad_build_file_path(fetch(:nomad_var_files_path), *args)
52
56
  end
53
57
 
54
- def capistrano_nomad_build_local_path(path, *args)
55
- local_path = ".#{capistrano_nomad_root.join(path)}"
58
+ def capistrano_nomad_build_local_path(path)
59
+ local_path = capistrano_nomad_root.join(path)
56
60
 
57
61
  # Determine if it has .erb appended or not
58
- found_local_path = [local_path, "#{local_path}.erb"].find { |path| File.exist?(path) }
62
+ found_local_path = [local_path, "#{local_path}.erb"].find { |each_local_path| File.exist?(each_local_path) }
59
63
 
60
64
  raise StandardError, "Could not find local path: #{path}" unless found_local_path
61
65
 
@@ -71,11 +75,11 @@ def capistrano_nomad_build_local_var_file_path(name, *args)
71
75
  end
72
76
 
73
77
  def capistrano_nomad_build_release_job_path(*args)
74
- "#{release_path}#{capistrano_nomad_build_base_job_path(*args)}"
78
+ "#{release_path}#{capistrano_nomad_ensure_absolute_path(capistrano_nomad_build_base_job_path(*args))}"
75
79
  end
76
80
 
77
81
  def capistrano_nomad_build_release_var_file_path(*args)
78
- "#{release_path}#{capistrano_nomad_build_base_var_file_path(*args)}"
82
+ "#{release_path}#{capistrano_nomad_ensure_absolute_path(capistrano_nomad_build_base_var_file_path(*args))}"
79
83
  end
80
84
 
81
85
  def capistrano_nomad_run_nomad_command(kind, *args)
@@ -9,8 +9,8 @@ require_relative "nomad/helpers/nomad"
9
9
  module Capistrano
10
10
  class Nomad < Capistrano::Plugin
11
11
  def set_defaults
12
- set_if_empty(:nomad_jobs_path, "/nomad/jobs")
13
- set_if_empty(:nomad_var_files_path, "/nomad/var_files")
12
+ set_if_empty(:nomad_jobs_path, "nomad/jobs")
13
+ set_if_empty(:nomad_var_files_path, "nomad/var_files")
14
14
  set_if_empty(:nomad_docker_image_alias, ->(**) {})
15
15
  end
16
16
 
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.5.1
4
+ version: 0.6.1
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-23 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport