fulmar 1.7.5 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21eff8bc3cf11335690de38f4e3903ec3f59b170
4
- data.tar.gz: 6f03076d288c0704c75ac30e1d274d5747d5a714
3
+ metadata.gz: 2d20b737b6af1583286258dc2f016a9e513efb35
4
+ data.tar.gz: 9b422f9364ec4c4ce227734bf0fb01efe5faf2ac
5
5
  SHA512:
6
- metadata.gz: f07c2ff44a86b15b5190bffd699a3bfc5e6cd780361db9364fde401d808d957d9f78462d6e902aecdd0b6704f1abfdbfdf84e913a79306578278f705e343077b
7
- data.tar.gz: 6db7c318dda2c0a6f9c5087bdaf5ef66795dca43b136298ee6c08ea82dc84c12b524ff2913c380227871b19bfaeef3e974d3d00ffa7c8328054fc6345a66ceea
6
+ metadata.gz: f86764318b194d621a9259ed8b08b39bc647a3a3a7c03e9ea7721829220da70e95d2a36e3f063920890bd39e1b4a8c5a61b45c1bef3ab3a7b0d024122bb46004
7
+ data.tar.gz: 55a2081e314963646e7c22d4db62d4118b001f3ea6a7643c6dae3364a29fe0a72a4b050840829bfcbdb4bb5fbc5b4eb361f05bdbb971990229333e13344e0a49
@@ -7,6 +7,15 @@ module Fulmar
7
7
  class SSHConfigService
8
8
  CONFIG_FILE = "#{ENV['HOME']}/.ssh/config"
9
9
  KNOWN_HOST_FILE = "#{ENV['HOME']}/.ssh/known_hosts"
10
+ CONFIG_MAP = {
11
+ hostname: 'Hostname',
12
+ port: 'Port',
13
+ user: 'User',
14
+ proxycommand: 'ProxyCommand',
15
+ checkhostip: 'CheckHostIP',
16
+ stricthostkeychecking: 'StrictHostKeyChecking',
17
+ identityfile: 'IdentityFile'
18
+ }
10
19
 
11
20
  def initialize(config)
12
21
  @config = config
@@ -21,7 +30,7 @@ module Fulmar
21
30
  if host_exists?(data[:hostname])
22
31
  puts "Host #{data[:hostname]} exists, skipping..." if @config[:debug]
23
32
  else
24
- add_host(data[:hostname], data)
33
+ add_host(data[:hostname], data[:ssh_config])
25
34
  end
26
35
  end
27
36
  end
@@ -30,7 +39,7 @@ module Fulmar
30
39
  input_file = File.open(KNOWN_HOST_FILE, 'r')
31
40
  output_file = File.open(KNOWN_HOST_FILE + '.temp', 'w')
32
41
  while (line = input_file.gets)
33
- output_file.puts(line) unless /^\[?#{hostname.gsub('.', '\\.')}(?:\]:\d+)? /.match(line)
42
+ output_file.puts(line) unless /^\[?#{hostname.gsub('.', '\\.')}(?:\]:\d+)?[ ,]/.match(line)
34
43
  end
35
44
  input_file.close
36
45
  output_file.close
@@ -51,17 +60,20 @@ module Fulmar
51
60
  end
52
61
 
53
62
  # Adds a host to the ssh config file
54
- def add_host(hostname, host_config = {})
55
- puts "Adding host #{host_config[:hostname]}..." if @config[:debug]
63
+ def add_host(hostname, ssh_config = {})
64
+ puts "Adding host #{hostname}..." if @config[:debug]
56
65
  config_file = File.open(CONFIG_FILE, 'a')
57
66
 
67
+ unless ssh_config[:identityfile].blank? or ssh_config[:identityfile][0, 1] == '/'
68
+ ssh_config[:identityfile] = @config.base_path + '/' + ssh_config[:identityfile]
69
+ end
70
+
58
71
  config_file.puts "\n" # Add some space between this and the second last entry
59
72
  config_file.puts "# Automatically generated by fulmar for project #{@config.project.description}"
60
73
  config_file.puts "Host #{hostname}"
61
- config_file.puts " Hostname #{host_config[:config_hostname]}" unless host_config[:config_hostname].blank?
62
- config_file.puts " Port #{host_config[:config_port]}" unless host_config[:config_port].blank?
63
- config_file.puts " User #{host_config[:config_user]}" unless host_config[:config_user].blank?
64
- config_file.puts " ProxyCommand #{host_config[:config_proxycommand]}" unless host_config[:config_proxycommand].blank?
74
+ CONFIG_MAP.keys.each do |key|
75
+ config_file.puts " #{CONFIG_MAP[key]} #{ssh_config[key]}" unless ssh_config[key].blank?
76
+ end
65
77
 
66
78
  config_file.close
67
79
  end
@@ -69,7 +81,7 @@ module Fulmar
69
81
  private
70
82
 
71
83
  def config_valid?(host_config)
72
- (!host_config[:hostname].blank? && !host_config[:config_hostname].blank?)
84
+ (!host_config[:hostname].blank? && !host_config[:ssh_config].nil?)
73
85
  end
74
86
  end
75
87
  end
@@ -1,4 +1,4 @@
1
1
  # Provides a global version number
2
2
  module Fulmar
3
- VERSION = '1.7.5'
3
+ VERSION = '1.8.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fulmar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.5
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Siegl