Skip to content

Commit

Permalink
Added user and identity file to box config
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Vega and Ramon Tayag authored and luiscvega committed Sep 23, 2021
1 parent e444bd8 commit 539424f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ [email protected]:
alpha: /mnt/c/Users/me/src # local machine
beta: ~/src # remote machine
[email protected]:
project: development-254604
box: ramon
- project: development-254604
box: ramon
user: another_user # only needed if ramon_company_com is not the user
identity_file: /path/to/ssh-private # ~/.ssh/google_compute_engine by default
```
To start and create the mutagen session:
Expand Down
5 changes: 2 additions & 3 deletions lib/devbox_launcher/models/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Box
]
WAIT_BOOT_IN_SECONDS = 10.freeze
MAX_BOOT_RETRIES = 20
DEFAULT_IDENTIFY_FILE_PATH = "~/.ssh/google_compute_engine".freeze
SSH_CONFIG_PATH = File.expand_path("~/.ssh/config").freeze
CONFIG_PATH = File.expand_path("~/.devbox_launcher.yml").freeze
CONFIG = YAML.load_file(CONFIG_PATH).freeze
Expand Down Expand Up @@ -104,7 +103,7 @@ def set_ssh_config!
args = {
"HostName" => description.ip,
"User" => username,
"IdentityFile" => DEFAULT_IDENTIFY_FILE_PATH,
"IdentityFile" => box_config.identity_file,
}
args.each do |key, value|
ssh_config.set(hostname, key, value)
Expand Down Expand Up @@ -206,7 +205,7 @@ def hostname
end

def username
@username ||= account.gsub(/\W/, "_")
@username ||= box_config.user || account.gsub(/\W/, "_")
end

def account_config
Expand Down
10 changes: 10 additions & 0 deletions lib/devbox_launcher/models/box_config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module DevboxLauncher
class BoxConfig

DEFAULT_IDENTIFY_FILE_PATH = "~/.ssh/google_compute_engine".freeze

attr_reader :config

def initialize(config)
Expand All @@ -19,5 +21,13 @@ def zone
config[:zone]
end

def user
config[:user]
end

def identity_file
config[:identity_file] || DEFAULT_IDENTIFY_FILE_PATH
end

end
end

0 comments on commit 539424f

Please sign in to comment.