devbox_launcher 0.3.3 → 0.5.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: 7ed54fc2716507cd48b6e65acb08d38f1399c7d2a626a898ea0bdbeb70317f9d
4
- data.tar.gz: 13b0d4ba4c3b9ae2515040bddff831b746de65c1296d57be20df82bc7f99f722
3
+ metadata.gz: 0d2b9f957cb18b171f3d4acc9d802576b1bd768eb6afa6036ae23143b9403ab1
4
+ data.tar.gz: f0dc90ba120f6d34f42b0432b53728bd9caf40468262091dd2c88e15bdc16fcf
5
5
  SHA512:
6
- metadata.gz: 0c9720ff3bc730ad33b4d225a24796eca616615534d23f5d01c57be8c8291f0b37a0fc2d13092b2f84799c66ea513d6cc3b00bef3fd3e3559fe8d6ea107596e2
7
- data.tar.gz: a040326a3fe949841970a3d5fd26535dc2cbf06bec09bd30098f63744ff87ac7fd1184b3a79d4848571681b7cad7c91c6ebe89753781f6126c8b5372619790de
6
+ metadata.gz: ba367cf32efeef9ac13b46c9c3af638b1998ff7c335a458c4c4421e0c849a043e44fb97d904b69428936393fdc1754adef71ead9197c46d96beacb25e6bee909
7
+ data.tar.gz: 5b7b7216addc48d9982e9706069a7ecf293e5543f3d11c4aff7997882b2f274ab0fe3bbf6b98b1833008cc9354b8753c9e3591756e9df7ad82c949bd353e1cb4
data/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ 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
+ ## [0.5.1] - 2021-04-08
8
+ ### Fixed
9
+ - Use configured `zone` for describe as well
10
+
11
+ ## [0.5.0] - 2021-04-06
12
+ ### Added
13
+ - Ability to specify `zone` in config
14
+
15
+ ## [0.4.0]
16
+ ### Added
17
+ - Sync mutagen with two-way-resolved
18
+
19
+ ## [0.3.5]
20
+ ### Fixed
21
+ - When running commands, also rescue from whitelist of exceptions, and retry
22
+
23
+ ## [0.3.4]
24
+ ### Added
25
+ - Rescue from `Errno::ECONNREFUSED` and retry
26
+
7
27
  ## [0.3.3]
8
28
  ### Fixed
9
29
  - Support launching multiple boxes at the same time
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devbox_launcher (0.3.3)
4
+ devbox_launcher (0.5.1)
5
5
  activesupport (~> 6.0)
6
6
  bcrypt_pbkdf (~> 1.0)
7
7
  ed25519 (~> 1.2)
@@ -14,31 +14,31 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activesupport (6.0.3.1)
17
+ activesupport (6.1.3)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (>= 0.7, < 2)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- zeitwerk (~> 2.2, >= 2.2.2)
23
- bcrypt_pbkdf (1.0.1)
19
+ i18n (>= 1.6, < 2)
20
+ minitest (>= 5.1)
21
+ tzinfo (~> 2.0)
22
+ zeitwerk (~> 2.3)
23
+ bcrypt_pbkdf (1.1.0)
24
24
  byebug (11.0.1)
25
25
  coderay (1.1.2)
26
- concurrent-ruby (1.1.6)
26
+ concurrent-ruby (1.1.8)
27
27
  diff-lcs (1.3)
28
28
  ed25519 (1.2.4)
29
- i18n (1.8.2)
29
+ i18n (1.8.9)
30
30
  concurrent-ruby (~> 1.0)
31
31
  method_source (0.9.2)
32
- minitest (5.14.1)
32
+ minitest (5.14.4)
33
33
  net-ssh (5.2.0)
34
- os (1.1.0)
34
+ os (1.1.1)
35
35
  pry (0.12.2)
36
36
  coderay (~> 1.1.0)
37
37
  method_source (~> 0.9.0)
38
38
  pry-byebug (3.7.0)
39
39
  byebug (~> 11.0)
40
40
  pry (~> 0.10)
41
- rake (10.5.0)
41
+ rake (13.0.1)
42
42
  rspec (3.9.0)
43
43
  rspec-core (~> 3.9.0)
44
44
  rspec-expectations (~> 3.9.0)
@@ -54,11 +54,10 @@ GEM
54
54
  rspec-support (3.9.0)
55
55
  ruby-watchman (0.0.2)
56
56
  ssh-config (0.1.3)
57
- thor (1.0.1)
58
- thread_safe (0.3.6)
59
- tzinfo (1.2.7)
60
- thread_safe (~> 0.1)
61
- zeitwerk (2.3.0)
57
+ thor (1.1.0)
58
+ tzinfo (2.0.4)
59
+ concurrent-ruby (~> 1.0)
60
+ zeitwerk (2.4.2)
62
61
 
63
62
  PLATFORMS
64
63
  ruby
@@ -67,7 +66,7 @@ DEPENDENCIES
67
66
  bundler (~> 2.0)
68
67
  devbox_launcher!
69
68
  pry-byebug
70
- rake (~> 10.0)
69
+ rake (~> 13.0)
71
70
  rspec (~> 3.0)
72
71
 
73
72
  BUNDLED WITH
data/README.md CHANGED
@@ -4,13 +4,9 @@ Start devboxes quickly
4
4
 
5
5
  ## Installation
6
6
 
7
- Install the gem:
8
-
9
- ```sh
10
- gem install devbox_launcher
11
- ```
12
-
13
- Setup gcloud init with the project that contains your VM.
7
+ - Install the gem: `gem install devbox_launcher`
8
+ - Setup `gcloud init` with the project that contains your VM
9
+ - Install [mutagen](https://mutagen.io)
14
10
 
15
11
  ## Usage
16
12
 
@@ -21,6 +17,9 @@ Create the config file at `~/.devbox_launcher.yml` so you type less. This is an
21
17
  ```yml
22
18
  ramon@email.com:
23
19
  project: general-192303
20
+ # zone not necessarily required, but sometimes starting the box
21
+ # fails without this:
22
+ zone: us-central1-a
24
23
  box: your-instance-name
25
24
  mutagen:
26
25
  alpha: /mnt/c/Users/me/src # local machine
@@ -36,7 +35,7 @@ To start and create the mutagen session:
36
35
  devbox start your-username
37
36
  ```
38
37
 
39
- If you want to mosh in immediately, add the `--mosh` switch.
38
+ If you want to mosh in immediately, add the `--mosh` switch. Yes, mosh needs to be [installed](https://mosh.org/) in your development machine.
40
39
 
41
40
  Note: Linux users that sync mutagen sessions need to install [Watchman](https://facebook.github.io/watchman/).
42
41
 
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_development_dependency "bundler", "~> 2.0"
33
- spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rake", "~> 13.0"
34
34
  spec.add_development_dependency "rspec", "~> 3.0"
35
35
 
36
36
  spec.add_runtime_dependency "thor", "~> 1.0"
@@ -1,4 +1,5 @@
1
1
  require "active_support/core_ext/hash/indifferent_access"
2
+ require "active_support/core_ext/object/blank"
2
3
  require "ssh-config"
3
4
  require "open3"
4
5
  require "thor"
@@ -6,6 +6,7 @@ module DevboxLauncher
6
6
  Net::SSH::Disconnect,
7
7
  Errno::ECONNRESET,
8
8
  Errno::ETIMEDOUT,
9
+ Errno::ECONNREFUSED,
9
10
  ]
10
11
  WAIT_BOOT_IN_SECONDS = 10.freeze
11
12
  DEFAULT_IDENTIFY_FILE_PATH = "~/.ssh/google_compute_engine".freeze
@@ -21,7 +22,7 @@ module DevboxLauncher
21
22
 
22
23
  def start
23
24
  start_stdout, start_stderr, start_status =
24
- Open3.capture3(start_cmd)
25
+ run_command(start_cmd)
25
26
 
26
27
  set_ssh_config!(hostname, {
27
28
  username: username,
@@ -80,7 +81,7 @@ module DevboxLauncher
80
81
 
81
82
  describe_command = %Q(gcloud compute instances describe #{name})
82
83
  describe_stdout, describe_stderr, describe_status =
83
- Open3.capture3(describe_command)
84
+ run_command(describe_command)
84
85
 
85
86
  if !describe_status.success?
86
87
  msg = "Problem fetching the description of #{name}. "
@@ -137,7 +138,7 @@ module DevboxLauncher
137
138
  terminate_mutagen_stdout,
138
139
  terminate_mutagen_stderr,
139
140
  terminate_mutagen_status =
140
- Open3.capture3(terminate_mutagen_command)
141
+ run_command(terminate_mutagen_command)
141
142
 
142
143
  if not terminate_mutagen_status.success?
143
144
  # mutagen prints to stdout and stderr
@@ -157,13 +158,14 @@ module DevboxLauncher
157
158
  alpha_dir,
158
159
  "#{hostname}:#{beta_dir}",
159
160
  "--label=#{username}",
161
+ "--sync-mode=two-way-resolved",
160
162
  ]
161
163
  create_mutagen_command << "--watch-mode-alpha=no-watch" if OS.linux?
162
164
 
163
165
  create_mutagen_stdout,
164
166
  create_mutagen_stderr,
165
167
  create_mutagen_status =
166
- Open3.capture3(create_mutagen_command.join(" "))
168
+ run_command(create_mutagen_command.join(" "))
167
169
 
168
170
  if not create_mutagen_status.success?
169
171
  # mutagen prints to stdout and stderr
@@ -201,5 +203,12 @@ module DevboxLauncher
201
203
  @config = CONFIG[account].with_indifferent_access
202
204
  end
203
205
 
206
+ def run_command(command, tries: 0)
207
+ Open3.capture3(command)
208
+ rescue *WAIT_BOOT_RESCUED_EXCEPTIONS
209
+ sleep WAIT_BOOT_IN_SECONDS
210
+ run_command(command, tries+1)
211
+ end
212
+
204
213
  end
205
214
  end
@@ -35,21 +35,7 @@ module DevboxLauncher
35
35
  end
36
36
 
37
37
  def start_cmd
38
- args = {
39
- project: config[:project],
40
- account: account,
41
- }.map do |(key, val)|
42
- ["--#{key}", val].join("=")
43
- end.join(" ")
44
-
45
- [
46
- "gcloud",
47
- "compute",
48
- "instances",
49
- "start",
50
- name,
51
- args
52
- ].join(" ")
38
+ cmd_args_for('start')
53
39
  end
54
40
 
55
41
  def connect_mosh
@@ -99,21 +85,7 @@ module DevboxLauncher
99
85
  end
100
86
 
101
87
  def describe_cmd
102
- args = {
103
- project: config[:project],
104
- account: account,
105
- }.map do |(key, val)|
106
- ["--#{key}", val].join("=")
107
- end.join(" ")
108
-
109
- [
110
- "gcloud",
111
- "compute",
112
- "instances",
113
- "describe",
114
- name,
115
- args
116
- ].join(" ")
88
+ cmd_args_for('describe')
117
89
  end
118
90
 
119
91
  def set_ssh_config!
@@ -218,5 +190,26 @@ module DevboxLauncher
218
190
  @mutagen_config ||= Mutagen.new(config[:mutagen])
219
191
  end
220
192
 
193
+ def cmd_args_for(method)
194
+ args = {
195
+ project: config[:project],
196
+ account: account,
197
+ zone: config[:zone],
198
+ }.each_with_object([]) do |(key, val), arr|
199
+ next if val.blank?
200
+ arr << ["--#{key}", val].join("=")
201
+ end.join(" ")
202
+
203
+ [
204
+ "gcloud",
205
+ "compute",
206
+ "instances",
207
+ method,
208
+ name,
209
+ args
210
+ ].join(" ")
211
+ end
212
+
213
+
221
214
  end
222
215
  end
@@ -1,3 +1,3 @@
1
1
  module DevboxLauncher
2
- VERSION = "0.3.3"
2
+ VERSION = "0.5.1"
3
3
  end
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.3.3
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +164,7 @@ dependencies:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
166
  version: 0.0.2
167
- description:
167
+ description:
168
168
  email:
169
169
  - ramon.tayag@gmail.com
170
170
  executables:
@@ -204,7 +204,7 @@ metadata:
204
204
  homepage_uri: https://github.com/bloom-solutions/devbox_launcher
205
205
  source_code_uri: https://github.com/bloom-solutions/devbox_launcher
206
206
  changelog_uri: https://github.com/bloom-solutions/devbox_launcher/blob/master/CHANGELOG.md
207
- post_install_message:
207
+ post_install_message:
208
208
  rdoc_options: []
209
209
  require_paths:
210
210
  - lib
@@ -219,8 +219,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  requirements: []
222
- rubygems_version: 3.0.8
223
- signing_key:
222
+ rubygems_version: 3.1.4
223
+ signing_key:
224
224
  specification_version: 4
225
225
  summary: Conveniently launch your devbox
226
226
  test_files: []