devbox_launcher 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.travis.yml +0 -0
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +3 -3
- data/LICENSE.txt +0 -0
- data/README.md +13 -9
- data/Rakefile +0 -0
- data/lib/devbox_launcher/cli.rb +1 -0
- data/lib/devbox_launcher/models/account_config.rb +22 -0
- data/lib/devbox_launcher/models/box.rb +52 -14
- data/lib/devbox_launcher/models/box_config.rb +23 -0
- data/lib/devbox_launcher/version.rb +1 -1
- data/lib/devbox_launcher.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c48092de409744a2c52020e6caf65cf2d06377ab686aca517ede0b9790b0d414
|
4
|
+
data.tar.gz: 7cdae080f466ead661718d23bc320f424049cc118887aab9402d5043f0d05184
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32574d16bae08ed7470449b7c36cdd6acc9f76b176e9e5342b9a70a49da9001debee5ee4793bb0295221606e07158e6aa20984f7d762d462bd8fbfb69ec36923
|
7
|
+
data.tar.gz: 94fee4aa07ef525c2b5c4de214bc2452aa7c8c8f9a2e7a43103d0a0c6e9c3a6c72f76bbe66a93601006d8532efe46b42a211a9d2fbdc96c194907f800d8ff257
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ 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.6.0] - 2021-09-21
|
8
|
+
### Changed
|
9
|
+
- Ability to configure multiple boxes under one account
|
10
|
+
|
7
11
|
## [0.5.2] - 2021-05-31
|
8
12
|
### Added
|
9
13
|
- Ignore VCS as recommended by mutagen
|
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
devbox_launcher (0.
|
4
|
+
devbox_launcher (0.6.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.
|
17
|
+
activesupport (6.1.4.1)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 1.6, < 2)
|
20
20
|
minitest (>= 5.1)
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
bcrypt_pbkdf (1.1.0)
|
24
24
|
byebug (11.0.1)
|
25
25
|
coderay (1.1.2)
|
26
|
-
concurrent-ruby (1.1.
|
26
|
+
concurrent-ruby (1.1.9)
|
27
27
|
diff-lcs (1.3)
|
28
28
|
ed25519 (1.2.4)
|
29
29
|
i18n (1.8.10)
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -16,14 +16,12 @@ Create the config file at `~/.devbox_launcher.yml` so you type less. This is an
|
|
16
16
|
|
17
17
|
```yml
|
18
18
|
ramon@email.com:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
alpha: /mnt/c/Users/me/src # local machine
|
26
|
-
beta: ~/src # remote machine
|
19
|
+
- box: your-instance-name
|
20
|
+
project: general-192303
|
21
|
+
zone: us-central1-a
|
22
|
+
mutagen:
|
23
|
+
alpha: /mnt/c/Users/me/src # local machine
|
24
|
+
beta: ~/src # remote machine
|
27
25
|
ramon@company.com:
|
28
26
|
project: development-254604
|
29
27
|
box: ramon
|
@@ -35,7 +33,13 @@ To start and create the mutagen session:
|
|
35
33
|
devbox start your-username
|
36
34
|
```
|
37
35
|
|
38
|
-
|
36
|
+
- Want to ssh in immediately?
|
37
|
+
- Add `--ssh` switch
|
38
|
+
- Want to mosh in immediately?
|
39
|
+
- Add `--mosh` switch. Mosh needs to be [installed](https://mosh.org/) in your development machine.
|
40
|
+
- More than one box with the same Google Cloud account?
|
41
|
+
- Pass in the box in your command, via `devbox start user@domain.com/box-name`
|
42
|
+
- No need to configure `box:` in the YAML file
|
39
43
|
|
40
44
|
Note: Linux users that sync mutagen sessions need to install [Watchman](https://facebook.github.io/watchman/).
|
41
45
|
|
data/Rakefile
CHANGED
File without changes
|
data/lib/devbox_launcher/cli.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module DevboxLauncher
|
2
|
+
class AccountConfig
|
3
|
+
|
4
|
+
attr_reader :account_name
|
5
|
+
|
6
|
+
def initialize(account_name, config)
|
7
|
+
@account_name = account_name
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_box_config(box_name)
|
12
|
+
box_config = @config.find { |c| c["box"] == box_name }
|
13
|
+
|
14
|
+
if box_config.nil?
|
15
|
+
fail "No box config found for #{box_name} under account #{account_name}"
|
16
|
+
end
|
17
|
+
|
18
|
+
BoxConfig.new(box_config)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -15,13 +15,17 @@ module DevboxLauncher
|
|
15
15
|
CONFIG_PATH = File.expand_path("~/.devbox_launcher.yml").freeze
|
16
16
|
CONFIG = YAML.load_file(CONFIG_PATH).freeze
|
17
17
|
|
18
|
-
attr_reader :
|
18
|
+
attr_reader :account_and_box_name, :options
|
19
19
|
|
20
|
-
def initialize(
|
21
|
-
@
|
20
|
+
def initialize(account_and_box_name, options)
|
21
|
+
@account_and_box_name = account_and_box_name
|
22
22
|
@options = options
|
23
23
|
end
|
24
24
|
|
25
|
+
def account
|
26
|
+
@account ||= @account_and_box_name.split("/")[0]
|
27
|
+
end
|
28
|
+
|
25
29
|
def start
|
26
30
|
start_stdout, start_stderr, start_status =
|
27
31
|
Open3.capture3(start_cmd)
|
@@ -32,7 +36,7 @@ module DevboxLauncher
|
|
32
36
|
|
33
37
|
reset_mutagen_session
|
34
38
|
|
35
|
-
connect_mosh
|
39
|
+
connect_mosh || connect_ssh
|
36
40
|
end
|
37
41
|
|
38
42
|
def start_cmd
|
@@ -46,6 +50,13 @@ module DevboxLauncher
|
|
46
50
|
system(mosh_cmd)
|
47
51
|
end
|
48
52
|
|
53
|
+
def connect_ssh
|
54
|
+
return if options[:ssh].nil?
|
55
|
+
|
56
|
+
ssh_cmd = %Q(ssh #{hostname})
|
57
|
+
system(ssh_cmd)
|
58
|
+
end
|
59
|
+
|
49
60
|
def wait_boot(tries: 1)
|
50
61
|
Net::SSH.start(hostname, username, timeout: WAIT_BOOT_IN_SECONDS) do |ssh|
|
51
62
|
puts "[#{ssh.exec!('date').chomp}] Machine booted"
|
@@ -89,16 +100,16 @@ module DevboxLauncher
|
|
89
100
|
|
90
101
|
def set_ssh_config!
|
91
102
|
FileUtils.touch(SSH_CONFIG_PATH)
|
92
|
-
|
103
|
+
ssh_config = ConfigFile.new
|
93
104
|
args = {
|
94
105
|
"HostName" => description.ip,
|
95
106
|
"User" => username,
|
96
107
|
"IdentityFile" => DEFAULT_IDENTIFY_FILE_PATH,
|
97
108
|
}
|
98
109
|
args.each do |key, value|
|
99
|
-
|
110
|
+
ssh_config.set(hostname, key, value)
|
100
111
|
end
|
101
|
-
|
112
|
+
ssh_config.save
|
102
113
|
end
|
103
114
|
|
104
115
|
def reset_mutagen_session
|
@@ -163,8 +174,31 @@ module DevboxLauncher
|
|
163
174
|
watchman.trigger("mutagen sync flush --label-selector=#{label}")
|
164
175
|
end
|
165
176
|
|
177
|
+
def box_name_from_config
|
178
|
+
passed_in_box_name = @account_and_box_name.split("/")[1]
|
179
|
+
|
180
|
+
case account_config.count
|
181
|
+
when 0
|
182
|
+
fail "You have to specify box configuration"
|
183
|
+
when 1
|
184
|
+
account_config.first[:box]
|
185
|
+
else
|
186
|
+
account_config[name]
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
166
190
|
def name
|
167
|
-
@name
|
191
|
+
return @name if @name
|
192
|
+
passed_in_box_name = @account_and_box_name.split("/")[1]
|
193
|
+
|
194
|
+
name = passed_in_box_name.presence || box_name_from_config
|
195
|
+
|
196
|
+
if name.blank?
|
197
|
+
fail "box name must be given either in the CLI or in config. " \
|
198
|
+
"See README.md."
|
199
|
+
end
|
200
|
+
|
201
|
+
@name = name
|
168
202
|
end
|
169
203
|
|
170
204
|
def hostname
|
@@ -175,25 +209,29 @@ module DevboxLauncher
|
|
175
209
|
@username ||= account.gsub(/\W/, "_")
|
176
210
|
end
|
177
211
|
|
178
|
-
def
|
179
|
-
return @
|
212
|
+
def account_config
|
213
|
+
return @account_config if @account_config
|
180
214
|
|
181
215
|
if not CONFIG.has_key?(account)
|
182
216
|
fail "No config in #{CONFIG_PATH} found for #{account}"
|
183
217
|
end
|
184
218
|
|
185
|
-
@
|
219
|
+
@account_config = AccountConfig.new(account, CONFIG[account])
|
220
|
+
end
|
221
|
+
|
222
|
+
def box_config
|
223
|
+
account_config.find_box_config(name)
|
186
224
|
end
|
187
225
|
|
188
226
|
def mutagen_config
|
189
|
-
@mutagen_config ||=
|
227
|
+
@mutagen_config ||= box_config.mutagen_config
|
190
228
|
end
|
191
229
|
|
192
230
|
def cmd_args_for(method)
|
193
231
|
args = {
|
194
|
-
project:
|
232
|
+
project: box_config.project,
|
195
233
|
account: account,
|
196
|
-
zone:
|
234
|
+
zone: box_config.zone,
|
197
235
|
}.each_with_object([]) do |(key, val), arr|
|
198
236
|
next if val.blank?
|
199
237
|
arr << ["--#{key}", val].join("=")
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module DevboxLauncher
|
2
|
+
class BoxConfig
|
3
|
+
|
4
|
+
attr_reader :config
|
5
|
+
|
6
|
+
def initialize(config)
|
7
|
+
@config = config.with_indifferent_access
|
8
|
+
end
|
9
|
+
|
10
|
+
def mutagen_config
|
11
|
+
Mutagen.new(config[:mutagen])
|
12
|
+
end
|
13
|
+
|
14
|
+
def project
|
15
|
+
config[:project]
|
16
|
+
end
|
17
|
+
|
18
|
+
def zone
|
19
|
+
config[:zone]
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/devbox_launcher.rb
CHANGED
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.
|
4
|
+
version: 0.6.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-
|
11
|
+
date: 2021-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -190,7 +190,9 @@ files:
|
|
190
190
|
- devbox_launcher.gemspec
|
191
191
|
- lib/devbox_launcher.rb
|
192
192
|
- lib/devbox_launcher/cli.rb
|
193
|
+
- lib/devbox_launcher/models/account_config.rb
|
193
194
|
- lib/devbox_launcher/models/box.rb
|
195
|
+
- lib/devbox_launcher/models/box_config.rb
|
194
196
|
- lib/devbox_launcher/models/description.rb
|
195
197
|
- lib/devbox_launcher/models/mutagen.rb
|
196
198
|
- lib/devbox_launcher/version.rb
|
@@ -218,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
220
|
- !ruby/object:Gem::Version
|
219
221
|
version: '0'
|
220
222
|
requirements: []
|
221
|
-
rubygems_version: 3.1.
|
223
|
+
rubygems_version: 3.1.6
|
222
224
|
signing_key:
|
223
225
|
specification_version: 4
|
224
226
|
summary: Conveniently launch your devbox
|