-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vagrantplugins
61 lines (48 loc) · 1.26 KB
/
.vagrantplugins
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require "erb"
require "ostruct"
module SequelPro
class Command < Vagrant.plugin(2, :command)
def self.synopsis
"open connection to MySQL in Sequel Pro"
end
def execute
config = Chassis.config
opts = OptionParser.new
argv = parse_options(opts)
@env.ui.info("Generating SPF file...")
# Load the SPF template
template_path = File.join(File.dirname(__FILE__), "template.spf")
template = ERB.new(File.read(template_path), nil, "%<>")
with_target_vms(argv) do |machine|
# Collect data
ssh_info = machine.ssh_info
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
data = {
"ssh" => {
"host" => ssh_info[:host],
"port" => ssh_info[:port],
"user" => ssh_info[:username],
"private_key_path" => ssh_info[:private_key_path],
}
}
data = config.merge(data)
# Output template
content = template.result OpenStruct.new(data).instance_eval { binding }
# Write it to the file
path = File.join(@env.local_data_path, "sequel.spf")
file = File.open(path, "w")
file.write(content)
file.close()
# And, open it.
system("open \"#{path}\"")
end
0
end
end
class SequelProPlugin < Vagrant.plugin("2")
name "Sequel Pro"
command "sequel" do
Command
end
end
end