devbox_launcher 0.6.0 → 1.0.0

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: c48092de409744a2c52020e6caf65cf2d06377ab686aca517ede0b9790b0d414
4
- data.tar.gz: 7cdae080f466ead661718d23bc320f424049cc118887aab9402d5043f0d05184
3
+ metadata.gz: f36523ab1ba2737746a95069dc0bd49e1e182b9449ff8af6ad7ba2c8eba6fac5
4
+ data.tar.gz: 4d9ec6e2cf0df27fe3ae57d2860312272140a238ab43b460dc1b8b706982f77b
5
5
  SHA512:
6
- metadata.gz: 32574d16bae08ed7470449b7c36cdd6acc9f76b176e9e5342b9a70a49da9001debee5ee4793bb0295221606e07158e6aa20984f7d762d462bd8fbfb69ec36923
7
- data.tar.gz: 94fee4aa07ef525c2b5c4de214bc2452aa7c8c8f9a2e7a43103d0a0c6e9c3a6c72f76bbe66a93601006d8532efe46b42a211a9d2fbdc96c194907f800d8ff257
6
+ metadata.gz: 272f2e79480f5439a98797833bb21709ca4137a04f3ea46b0a70b3c473ccac66a0e53e688699923d2a71fed52e11bc704f3ff08fbefb41d86888bc35388251d5
7
+ data.tar.gz: 0321766ede0a716eb6e3d3745213ea2e810cfd74b3fde853dc98627354ac92f610e5983e50f043812eab0d6fb017784801b0780d204a6640ef5dbc29b22194dd
data/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.0.0] - 2021-12-20
8
+ ### Changed
9
+ - Update compatibility with mutagen 0.12.0. Drops support for previous versions
10
+
11
+ ## [0.7.1] - 2021-10-14
12
+ ### Fixed
13
+ - Explicitly require fileutils for Ruby 3.0 compatibility
14
+
15
+ ## [0.7.0] - 2021-09-23
16
+ ### Added
17
+ - Add ability to set a box's user and identity_file
18
+
19
+ ## [0.6.1] - 2021-09-22
20
+ ### Fixed
21
+ - Do not blow up if mutagen is not configured
22
+
7
23
  ## [0.6.0] - 2021-09-21
8
24
  ### Changed
9
25
  - Ability to configure multiple boxes under one account
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devbox_launcher (0.6.0)
4
+ devbox_launcher (1.0.0)
5
5
  activesupport (~> 6.0)
6
6
  bcrypt_pbkdf (~> 1.0)
7
7
  ed25519 (~> 1.2)
@@ -14,7 +14,7 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activesupport (6.1.4.1)
17
+ activesupport (6.1.4.4)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 1.6, < 2)
20
20
  minitest (>= 5.1)
@@ -26,12 +26,12 @@ GEM
26
26
  concurrent-ruby (1.1.9)
27
27
  diff-lcs (1.3)
28
28
  ed25519 (1.2.4)
29
- i18n (1.8.10)
29
+ i18n (1.8.11)
30
30
  concurrent-ruby (~> 1.0)
31
31
  method_source (0.9.2)
32
- minitest (5.14.4)
32
+ minitest (5.15.0)
33
33
  net-ssh (5.2.0)
34
- os (1.1.1)
34
+ os (1.1.4)
35
35
  pry (0.12.2)
36
36
  coderay (~> 1.1.0)
37
37
  method_source (~> 0.9.0)
@@ -57,7 +57,7 @@ GEM
57
57
  thor (1.1.0)
58
58
  tzinfo (2.0.4)
59
59
  concurrent-ruby (~> 1.0)
60
- zeitwerk (2.4.2)
60
+ zeitwerk (2.5.1)
61
61
 
62
62
  PLATFORMS
63
63
  ruby
@@ -70,4 +70,4 @@ DEPENDENCIES
70
70
  rspec (~> 3.0)
71
71
 
72
72
  BUNDLED WITH
73
- 2.1.4
73
+ 2.2.28
data/README.md CHANGED
@@ -23,8 +23,10 @@ ramon@email.com:
23
23
  alpha: /mnt/c/Users/me/src # local machine
24
24
  beta: ~/src # remote machine
25
25
  ramon@company.com:
26
- project: development-254604
27
- box: ramon
26
+ - project: development-254604
27
+ box: ramon
28
+ user: another_user # only needed if ramon_company_com is not the user
29
+ identity_file: /path/to/ssh-private # ~/.ssh/google_compute_engine by default
28
30
  ```
29
31
 
30
32
  To start and create the mutagen session:
@@ -10,7 +10,6 @@ module DevboxLauncher
10
10
  ]
11
11
  WAIT_BOOT_IN_SECONDS = 10.freeze
12
12
  MAX_BOOT_RETRIES = 20
13
- DEFAULT_IDENTIFY_FILE_PATH = "~/.ssh/google_compute_engine".freeze
14
13
  SSH_CONFIG_PATH = File.expand_path("~/.ssh/config").freeze
15
14
  CONFIG_PATH = File.expand_path("~/.devbox_launcher.yml").freeze
16
15
  CONFIG = YAML.load_file(CONFIG_PATH).freeze
@@ -34,7 +33,7 @@ module DevboxLauncher
34
33
 
35
34
  wait_boot
36
35
 
37
- reset_mutagen_session
36
+ mutagen_session.reset
38
37
 
39
38
  connect_mosh || connect_ssh
40
39
  end
@@ -104,7 +103,7 @@ module DevboxLauncher
104
103
  args = {
105
104
  "HostName" => description.ip,
106
105
  "User" => username,
107
- "IdentityFile" => DEFAULT_IDENTIFY_FILE_PATH,
106
+ "IdentityFile" => box_config.identity_file,
108
107
  }
109
108
  args.each do |key, value|
110
109
  ssh_config.set(hostname, key, value)
@@ -112,68 +111,10 @@ module DevboxLauncher
112
111
  ssh_config.save
113
112
  end
114
113
 
115
- def reset_mutagen_session
116
- return if !mutagen_config.configured?
117
-
118
- terminate_mutagen_session
119
- create_mutagen_session
120
- watch_alpha if OS.linux?
121
- end
122
-
123
- def terminate_mutagen_session
124
- puts "Terminating mutagen session..."
125
- terminate_mutagen_cmd =
126
- %Q(mutagen terminate --label-selector=#{label})
127
- terminate_mutagen_stdout,
128
- terminate_mutagen_stderr,
129
- terminate_mutagen_status =
130
- Open3.capture3(terminate_mutagen_cmd)
131
-
132
- if not terminate_mutagen_status.success?
133
- # mutagen prints to stdout and stderr
134
- msg = "Failed to terminate mutagen sessions: " \
135
- "#{terminate_mutagen_stdout} -" \
136
- "#{terminate_mutagen_stderr}"
137
- fail msg
138
- end
139
- end
140
-
141
114
  def label
142
115
  "#{username}=#{name}"
143
116
  end
144
117
 
145
- def create_mutagen_session
146
- puts "Create mutagen session syncing local " \
147
- "#{mutagen_config.alpha_dir} with " \
148
- "#{hostname} #{mutagen_config.beta_dir}"
149
-
150
- create_mutagen_cmd = [
151
- "mutagen sync create",
152
- mutagen_config.alpha_dir,
153
- "#{hostname}:#{mutagen_config.beta_dir}",
154
- "--label=#{label}",
155
- ]
156
- create_mutagen_cmd << "--watch-mode-alpha=no-watch" if OS.linux?
157
-
158
- create_mutagen_stdout,
159
- create_mutagen_stderr,
160
- create_mutagen_status =
161
- Open3.capture3(create_mutagen_cmd.join(" "))
162
-
163
- if not create_mutagen_status.success?
164
- # mutagen prints to stdout and stderr
165
- msg = "Failed to create mutagen sessions: " \
166
- "#{create_mutagen_stdout} -" \
167
- "#{create_mutagen_stderr}"
168
- fail msg
169
- end
170
- end
171
-
172
- def watch_alpha
173
- watchman = Watchman.new(dir: mutagen_config.alpha_dir)
174
- watchman.trigger("mutagen sync flush --label-selector=#{label}")
175
- end
176
-
177
118
  def box_name_from_config
178
119
  passed_in_box_name = @account_and_box_name.split("/")[1]
179
120
 
@@ -206,7 +147,7 @@ module DevboxLauncher
206
147
  end
207
148
 
208
149
  def username
209
- @username ||= account.gsub(/\W/, "_")
150
+ @username ||= box_config.user || account.gsub(/\W/, "_")
210
151
  end
211
152
 
212
153
  def account_config
@@ -247,6 +188,13 @@ module DevboxLauncher
247
188
  ].join(" ")
248
189
  end
249
190
 
191
+ def mutagen_session
192
+ @mutagen_session ||= MutagenSession.new(
193
+ label: label,
194
+ config: mutagen_config,
195
+ hostname: hostname,
196
+ )
197
+ end
250
198
 
251
199
  end
252
200
  end
@@ -1,6 +1,8 @@
1
1
  module DevboxLauncher
2
2
  class BoxConfig
3
3
 
4
+ DEFAULT_IDENTIFY_FILE_PATH = "~/.ssh/google_compute_engine".freeze
5
+
4
6
  attr_reader :config
5
7
 
6
8
  def initialize(config)
@@ -8,7 +10,7 @@ module DevboxLauncher
8
10
  end
9
11
 
10
12
  def mutagen_config
11
- Mutagen.new(config[:mutagen])
13
+ MutagenConfig.new(config[:mutagen])
12
14
  end
13
15
 
14
16
  def project
@@ -19,5 +21,13 @@ module DevboxLauncher
19
21
  config[:zone]
20
22
  end
21
23
 
24
+ def user
25
+ config[:user]
26
+ end
27
+
28
+ def identity_file
29
+ config[:identity_file] || DEFAULT_IDENTIFY_FILE_PATH
30
+ end
31
+
22
32
  end
23
33
  end
@@ -8,7 +8,8 @@ module DevboxLauncher
8
8
  end
9
9
 
10
10
  def configured?
11
- [config, alpha_dir, beta_dir].none?(&:nil?)
11
+ return false if config.nil?
12
+ [alpha_dir, beta_dir].all?(&:present?)
12
13
  end
13
14
 
14
15
  def alpha_dir
@@ -0,0 +1,24 @@
1
+ module DevboxLauncher
2
+ class MutagenConfig
3
+
4
+ attr_reader :config
5
+
6
+ def initialize(config)
7
+ @config = config
8
+ end
9
+
10
+ def configured?
11
+ return false if config.nil?
12
+ [alpha_dir, beta_dir].all?(&:present?)
13
+ end
14
+
15
+ def alpha_dir
16
+ config[:alpha]
17
+ end
18
+
19
+ def beta_dir
20
+ config[:beta]
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,83 @@
1
+ module DevboxLauncher
2
+ class MutagenSession
3
+
4
+ attr_reader :label, :config, :hostname
5
+
6
+ def initialize(label:, config:, hostname:)
7
+ @label = label
8
+ @config = config
9
+ @hostname = hostname
10
+ end
11
+
12
+ def create
13
+ puts "Create mutagen session syncing local " \
14
+ "#{config.alpha_dir} with " \
15
+ "#{hostname} #{config.beta_dir}"
16
+
17
+ create_stdout,
18
+ create_stderr,
19
+ create_status =
20
+ Open3.capture3(create_cmd)
21
+
22
+ if not create_status.success?
23
+ # mutagen prints to stdout and stderr
24
+ msg = "Failed to create mutagen sessions: " \
25
+ "#{create_stdout} -" \
26
+ "#{create_stderr}"
27
+ fail msg
28
+ end
29
+ end
30
+
31
+ def linux?
32
+ OS.linux?
33
+ end
34
+
35
+ def create_cmd
36
+ str = [
37
+ "mutagen sync create",
38
+ config.alpha_dir,
39
+ "#{hostname}:#{config.beta_dir}",
40
+ "--label=#{label}",
41
+ ]
42
+ str << "--watch-mode-alpha=no-watch" if linux?
43
+ str.join(" ")
44
+ end
45
+
46
+ def terminate_cmd
47
+ %Q(mutagen sync terminate --label-selector=#{label})
48
+ end
49
+
50
+ def terminate
51
+ puts "Terminating mutagen session..."
52
+ terminate_stdout,
53
+ terminate_stderr,
54
+ terminate_status =
55
+ Open3.capture3(terminate_cmd)
56
+
57
+ if not terminate_status.success?
58
+ # mutagen prints to stdout and stderr
59
+ msg = "Failed to terminate mutagen sessions: " \
60
+ "#{terminate_stdout} -" \
61
+ "#{terminate_stderr}"
62
+ fail msg
63
+ end
64
+ end
65
+
66
+ def watch_alpha
67
+ watchman.trigger("mutagen sync flush --label-selector=#{label}")
68
+ end
69
+
70
+ def watchman
71
+ @watchman ||= Watchman.new(dir: config.alpha_dir)
72
+ end
73
+
74
+ def reset
75
+ return if !config.configured?
76
+
77
+ terminate
78
+ create
79
+ watch_alpha if linux?
80
+ end
81
+
82
+ end
83
+ end
@@ -1,3 +1,3 @@
1
1
  module DevboxLauncher
2
- VERSION = "0.6.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -3,6 +3,7 @@ require "active_support/core_ext/object/blank"
3
3
  require "ssh-config"
4
4
  require "open3"
5
5
  require "thor"
6
+ require "fileutils"
6
7
  require "net/ssh"
7
8
  require "os"
8
9
  require "ruby-watchman"
@@ -18,7 +19,8 @@ end
18
19
  require "devbox_launcher/cli"
19
20
  require "devbox_launcher/watchman"
20
21
  require "devbox_launcher/models/description"
21
- require "devbox_launcher/models/mutagen"
22
+ require "devbox_launcher/models/mutagen_config"
23
+ require "devbox_launcher/models/mutagen_session"
22
24
  require "devbox_launcher/models/box"
23
25
  require "devbox_launcher/models/account_config"
24
26
  require "devbox_launcher/models/box_config"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devbox_launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -195,6 +195,8 @@ files:
195
195
  - lib/devbox_launcher/models/box_config.rb
196
196
  - lib/devbox_launcher/models/description.rb
197
197
  - lib/devbox_launcher/models/mutagen.rb
198
+ - lib/devbox_launcher/models/mutagen_config.rb
199
+ - lib/devbox_launcher/models/mutagen_session.rb
198
200
  - lib/devbox_launcher/version.rb
199
201
  - lib/devbox_launcher/watchman.rb
200
202
  homepage: https://github.com/bloom-solutions/devbox_launcher