harbr 0.1.95 → 0.1.97

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: 5deda148fd004720248f93466e9a63066acaf37facae18a5982b82ade03e16fb
4
- data.tar.gz: 9104a70061f3f0ead6243d52a5bd8c3158d9bbd30a4144c66b7a2ed76ab93d75
3
+ metadata.gz: 6523337d1554b46139ffb2f876b7b6a2370ae7ee20446cd2e97f9c3f92ead769
4
+ data.tar.gz: 64ed1fdda1a29df228e1ce3131966a14dd2d588e52d8b1728a37f0d91766c272
5
5
  SHA512:
6
- metadata.gz: 58f55fe7801cc3e9fe18461c689db319b6d85aabcabd35101997664adb0ff57359f1b7400bbaff571b9c867e8645f8901ba8d1094b1097f27a51a75bc30b9544
7
- data.tar.gz: 332fb0f0fbb1d6351213ab073ef2ce058e40715da46e01cf20a1fd6ee3fe9f711e685b2c22c35a897569fb1871ec26e88383296f156206f114758ffb8d271aa9
6
+ metadata.gz: fd8a9c7b340d50d75ad4504c391a9c94ddba5e2b442ecfb0042c8b88fe153b90d412a853ac8b7e3e236c5593aba5c597295e36c08f2feec24c63f4f86287c4e5
7
+ data.tar.gz: e14a7cdadc6f73879df16e52012e9104e8f6f0d208f4a597bb596bb1b7cd2cec256167e15dca6d98ef5b400961f02f2b3debd3542380c3b67d7ecfe7d5bf9f6f
data/exe/harbr CHANGED
@@ -86,11 +86,10 @@ class HarbrCLI < Thor
86
86
  puts "Error: #{e.message}"
87
87
  end
88
88
  end
89
-
90
89
  def run_jobs(container, version)
91
- puts "Running tasks for container: #{container}, version: #{version}"
92
- Harbr::Job.perform_async(container, version, "next")
93
- puts "deploy next version #{version} of #{container}"
90
+ check_file_exists("/var/harbr/containers/#{container}/versions/#{version}/config/manifest.yml") do
91
+ `harbr deploy #{container} #{version} --next`
92
+ end
94
93
  end
95
94
 
96
95
  def create_traefik_config(containers)
@@ -134,7 +133,6 @@ class HarbrCLI < Thor
134
133
  container_repo = Harbr::Container::Repository.new
135
134
 
136
135
  ["live.#{name}", "next.#{name}", name].each do |container_name|
137
-
138
136
  container_repo.get_by_name(container_name).each do |container|
139
137
  `port release #{container.port}`
140
138
  puts "released port #{container.port} successfully."
@@ -213,17 +211,29 @@ class HarbrCLI < Thor
213
211
  end
214
212
 
215
213
  desc "deploy", "deploy a container to production"
216
- def deploy(name)
217
- /versions\/(?<version>\d*)/ =~ `ls -l /var/harbr/containers/#{name}/next`
218
- version = $1
219
- raise "Ooops! next version not found!" if version.nil?
214
+ method_option :live, type: :boolean, default: false, aliases: "-l", desc: "deploy to live environment"
215
+ method_option :next, type: :boolean, default: false, aliases: "-n", desc: "deploy to next environment"
216
+ def deploy(name,version=nil)
217
+
218
+ if options[:live]
219
+ /versions\/(?<version>\d*)/ =~ `ls -l /var/harbr/containers/#{name}/next`
220
+ version = $1
221
+ raise "Ooops! next version not found!" if version.nil?
220
222
 
221
- Harbr::Job.perform_async(name, version, "live")
223
+ Harbr::Job.perform_async(name, version, "live")
222
224
 
223
- /versions\/(?<version>\d*)/ =~ `ls -l /var/harbr/containers/#{name}/live`
224
- `ln -sf /var/harbr/containers/#{name}/version/#{$1} /var/harbr/containers/#{name}/rollback`
225
+ /versions\/(?<version>\d*)/ =~ `ls -l /var/harbr/containers/#{name}/live`
226
+ `ln -sf /var/harbr/containers/#{name}/version/#{$1} /var/harbr/containers/#{name}/rollback`
225
227
 
226
- puts "deploy version #{version} of #{name} to live environment"
228
+ puts "deploy version #{version} of #{name} to live environment"
229
+ end
230
+
231
+ if options[:next]
232
+ `ln -sf /var/harbr/containers/#{name}/version/#{version} /var/harbr/containers/#{name}/next`
233
+ Harbr::Job.perform_async(name, version, "next")
234
+ puts "deploy version #{version} of #{name} to next environment"
235
+ end
236
+
227
237
  end
228
238
 
229
239
  desc "rollback", "rollback last deploy"
data/lib/harbr/job.rb CHANGED
@@ -42,7 +42,7 @@ module Harbr
42
42
  def collate_containers(name, host, port, host_header_aliases = [])
43
43
  containers = Harbr::Container::Repository.new
44
44
  container = containers.find_by_header(host)
45
-
45
+
46
46
  if container.nil?
47
47
  container = Harbr::Container.new
48
48
  container.name = name
@@ -56,10 +56,8 @@ module Harbr
56
56
  containers.update(container)
57
57
  end
58
58
 
59
-
60
59
  if host_header_aliases
61
60
  host_header_aliases.each do |host_header_alias|
62
-
63
61
  container = Harbr::Container.new
64
62
  container.name = "#{name} -> #{host_header_alias}"
65
63
  container.host_header = host_header_alias
@@ -67,30 +65,26 @@ module Harbr
67
65
  container.port = port
68
66
  containers.create(container) unless containers.find_by_header(host_header_alias)
69
67
 
70
- if(container.name.start_with?("live"))
68
+ if container.name.start_with?("live")
71
69
 
72
- plain_name = host_header_alias.gsub("live.","")
70
+ plain_name = host_header_alias.gsub("live.", "")
73
71
  container = Harbr::Container.new
74
72
  container.name = "#{name} -> #{plain_name}"
75
73
  container.host_header = plain_name
76
74
  container.ip = "127.0.0.1"
77
- container.port = port
78
-
75
+ container.port = port
79
76
 
80
77
  unless containers.find_by_header(container.host_header)
81
78
  containers.create(container)
82
79
  end
83
80
 
84
81
  end
85
-
86
82
  end
87
83
  end
88
84
 
89
85
  containers.all
90
86
  end
91
87
 
92
-
93
-
94
88
  def write_to_file(path, contents)
95
89
  dirname = File.dirname(path)
96
90
  FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
@@ -117,7 +111,7 @@ module Harbr
117
111
  private
118
112
 
119
113
  def remove_dot_from_string(str)
120
- str.sub('.', '')
114
+ str.sub(".", "")
121
115
  end
122
116
 
123
117
  def check_file_exists(path)
@@ -159,14 +153,14 @@ module Harbr
159
153
 
160
154
  if env == "live"
161
155
  `rm -f /var/harbr/containers/#{name}/live` if Dir.exist?("/var/harbr/containers/#{name}/live")
162
- `ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/live`
156
+ `ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/live`
163
157
  end
164
-
158
+
165
159
  if env == "next"
166
160
  `rm -f /var/harbr/containers/#{name}/next` if Dir.exist?("/var/harbr/containers/#{name}/next")
167
- `ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/next`
161
+ `ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/next`
168
162
  end
169
-
163
+
170
164
  bundle_install_if_needed(version_path)
171
165
 
172
166
  create_runit_scripts(name, port, env)
data/lib/harbr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Harbr
4
- VERSION = "0.1.95"
4
+ VERSION = "0.1.97"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harbr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.95
4
+ version: 0.1.97
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delaney Kuldvee Burke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-06 00:00:00.000000000 Z
11
+ date: 2024-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen