vagrant-dnsdock-hostupdater 0.0.33 → 0.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/version.rb +1 -1
- metadata +1 -29
- data/Gemfile.lock +0 -29
- data/lib/hosts/aef/hosts.rb +0 -51
- data/lib/hosts/aef/hosts/comment.rb +0 -73
- data/lib/hosts/aef/hosts/element.rb +0 -108
- data/lib/hosts/aef/hosts/empty_element.rb +0 -50
- data/lib/hosts/aef/hosts/entry.rb +0 -123
- data/lib/hosts/aef/hosts/file.rb +0 -252
- data/lib/hosts/aef/hosts/helpers.rb +0 -121
- data/lib/hosts/aef/hosts/section.rb +0 -141
- data/lib/hosts/aef/hosts/version.rb +0 -29
- data/lib/hosts/aef/linebreak/linebreak.rb +0 -148
- data/lib/hosts/hosts.rb +0 -25
- data/lib/hosts/hosts/bare.rb +0 -23
- data/lib/vagrant-dnsdock-hostupdater/command.rb +0 -12
- data/lib/vagrant-dnsdock-hostupdater/plugin.rb +0 -90
- data/vagrant-dnsdock-hostupdater.gemspec +0 -28
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
module Aef
|
21
|
-
module Hosts
|
22
|
-
|
23
|
-
# The currently loaded library version
|
24
|
-
#
|
25
|
-
# Using Semantic Versioning (2.0.0-rc.1) rules
|
26
|
-
# @see http://semver.org/
|
27
|
-
VERSION = '0.1.1'.freeze
|
28
|
-
end
|
29
|
-
end
|
@@ -1,148 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@godobject.net>, 2009-2013
|
4
|
-
|
5
|
-
This file is part of Linebreak.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
require 'set'
|
21
|
-
|
22
|
-
# Namespace for projects of Alexander E. Fischer <aef@raxys.net>.
|
23
|
-
#
|
24
|
-
# If you want to be able to simply type Example instead of Aef::Example to
|
25
|
-
# address classes in this namespace simply write the following before using the
|
26
|
-
# classes.
|
27
|
-
#
|
28
|
-
# @example Including the namespace
|
29
|
-
# include Aef
|
30
|
-
# @author Alexander E. Fischer
|
31
|
-
module Aef
|
32
|
-
|
33
|
-
# Namespace for the linebreak library
|
34
|
-
module Linebreak
|
35
|
-
|
36
|
-
# Mapping table from symbol to actual linebreak sequence
|
37
|
-
#
|
38
|
-
# @private
|
39
|
-
BREAK_BY_SYSTEM = {
|
40
|
-
:unix => "\n",
|
41
|
-
:windows => "\r\n",
|
42
|
-
:mac => "\r"
|
43
|
-
}
|
44
|
-
|
45
|
-
# Mapping table from actual linebreak sequence to symbol
|
46
|
-
#
|
47
|
-
# @private
|
48
|
-
SYSTEM_BY_BREAK = BREAK_BY_SYSTEM.invert
|
49
|
-
|
50
|
-
# Regular expression for linebreak detection and extraction
|
51
|
-
#
|
52
|
-
# @private
|
53
|
-
BREAK_REGEXP = /(\r\n|[\r\n])/
|
54
|
-
|
55
|
-
# Detects encoding systems of a string.
|
56
|
-
#
|
57
|
-
# @param [String] input a String to be analysed
|
58
|
-
# @return [Set<Symbol>] the encoding systems present in the given String
|
59
|
-
def self.encodings(input)
|
60
|
-
if input.respond_to?(:to_s) then input = input.to_s
|
61
|
-
else raise ArgumentError, 'Input needs to be a string or must support to_s' end
|
62
|
-
|
63
|
-
occurences = Set.new
|
64
|
-
|
65
|
-
input.scan(BREAK_REGEXP).each do |linebreak|
|
66
|
-
occurences << SYSTEM_BY_BREAK[linebreak.first]
|
67
|
-
end
|
68
|
-
|
69
|
-
occurences
|
70
|
-
end
|
71
|
-
|
72
|
-
# Checks whether a string includes linebreaks of all the given encoding
|
73
|
-
# systems.
|
74
|
-
#
|
75
|
-
# @param [String] input a String to be analysed
|
76
|
-
# @param [Array<Symbol>] encodings one or more encoding systems
|
77
|
-
# @return [true, false] true if all of the given linebreak systems are
|
78
|
-
# present in the given String
|
79
|
-
def self.encoding?(input, *encodings)
|
80
|
-
systems = BREAK_BY_SYSTEM.keys
|
81
|
-
|
82
|
-
encodings.flatten!
|
83
|
-
encodings.each do |encoding|
|
84
|
-
unless systems.include?(encoding)
|
85
|
-
raise ArgumentError,
|
86
|
-
%{Invalid encoding system. Available systems: #{systems.join(', ')}. Arguments are expected as symbols or an array of symbols.}
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
Aef::Linebreak.encodings(input) == Set.new(encodings)
|
91
|
-
end
|
92
|
-
|
93
|
-
# Create a copy of a string with all the string's linebreaks replaced by
|
94
|
-
# linebreaks of a specific system or a given replacement.
|
95
|
-
#
|
96
|
-
# @overload encode(input, system)
|
97
|
-
# @param [String] input a String as conversion template
|
98
|
-
# @param [:unix, :windows, :mac] system a target linebreak system
|
99
|
-
#
|
100
|
-
# @overload encode(input, replacement)
|
101
|
-
# @param [String] input a String as conversion template
|
102
|
-
# @param [String] replacement a String to be the replacement for all
|
103
|
-
# linebreaks in the template
|
104
|
-
def self.encode(input, system_or_replacement = :unix)
|
105
|
-
if input.respond_to?(:to_s) then input = input.to_s
|
106
|
-
else raise ArgumentError, 'Input needs to be a string or must support to_s' end
|
107
|
-
|
108
|
-
input.gsub(BREAK_REGEXP,
|
109
|
-
BREAK_BY_SYSTEM[system_or_replacement] || system_or_replacement)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Detects encoding systems of a string.
|
113
|
-
#
|
114
|
-
# This method is supposed to be used as a method of String.
|
115
|
-
#
|
116
|
-
# @return [Set<Symbol>] the encoding systems present in the String
|
117
|
-
def linebreak_encodings
|
118
|
-
Aef::Linebreak.encodings(self)
|
119
|
-
end
|
120
|
-
|
121
|
-
# Checks whether a string includes linebreaks of all the given encoding
|
122
|
-
# systems.
|
123
|
-
#
|
124
|
-
# This method is supposed to be used as a method of String.
|
125
|
-
#
|
126
|
-
# @param [Array<Symbol>] encodings one or more encoding systems
|
127
|
-
# @return [true, false] true if all of the given linebreak systems are
|
128
|
-
# present in the given String
|
129
|
-
def linebreak_encoding?(*encodings)
|
130
|
-
Aef::Linebreak.encoding?(self, encodings)
|
131
|
-
end
|
132
|
-
|
133
|
-
# Create a copy of a string with all the string's linebreaks replaced by
|
134
|
-
# linebreaks of a specific system or a given replacement.
|
135
|
-
#
|
136
|
-
# This method is supposed to be used as a method of String.
|
137
|
-
#
|
138
|
-
# @overload encode(system)
|
139
|
-
# @param [:unix, :windows, :mac] system a target linebreak system
|
140
|
-
#
|
141
|
-
# @overload encode(replacement)
|
142
|
-
# @param [String] replacement a String to be the replacement for all
|
143
|
-
# linebreaks in the template
|
144
|
-
def linebreak_encode(system_or_replacement = :unix)
|
145
|
-
Aef::Linebreak.encode(self, system_or_replacement)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
data/lib/hosts/hosts.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
# Helper file to allow loading by gem name. Creates an alias for Aef::Hosts
|
21
|
-
# named simply Hosts if this name isn't used otherwise.
|
22
|
-
|
23
|
-
require_relative 'aef/hosts'
|
24
|
-
|
25
|
-
::Hosts = Aef::Hosts unless defined?(::Hosts)
|
data/lib/hosts/hosts/bare.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
# Require this file if you don't want an alias for Aef::Hosts named simply
|
21
|
-
# Hosts.
|
22
|
-
|
23
|
-
require_relative '../hosts'
|
@@ -1,90 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module DnsdockHostUpdater
|
3
|
-
|
4
|
-
module OS
|
5
|
-
def OS.windows?
|
6
|
-
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
7
|
-
end
|
8
|
-
|
9
|
-
def OS.mac?
|
10
|
-
(/darwin/ =~ RUBY_PLATFORM) != nil
|
11
|
-
end
|
12
|
-
|
13
|
-
def OS.unix?
|
14
|
-
!OS.windows?
|
15
|
-
end
|
16
|
-
|
17
|
-
def OS.linux?
|
18
|
-
OS.unix? and not OS.mac?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Plugin < Vagrant.plugin('2')
|
23
|
-
name "dnsdock-host-updater"
|
24
|
-
|
25
|
-
description <<-DESC
|
26
|
-
Updates hosts for docker containers on guest VM.
|
27
|
-
DESC
|
28
|
-
|
29
|
-
@started = false
|
30
|
-
|
31
|
-
# Add command for `$ vagrant dnsdock-host-updater`
|
32
|
-
# command 'dnsdock-host-updater' do
|
33
|
-
# require_relative 'command'
|
34
|
-
# Command
|
35
|
-
# end
|
36
|
-
|
37
|
-
def self.pid_path
|
38
|
-
File.expand_path('~/.docker-host-manager.pid')
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.log(msg)
|
42
|
-
puts "[vagrant-dnsdock-hostupdater] #{msg}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.pid
|
46
|
-
File.exist?(pid_path) ? File.read(pid_path) : nil
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.close_manager
|
50
|
-
if pid
|
51
|
-
log "Already running with PID: #{pid}"
|
52
|
-
begin
|
53
|
-
log "Attempting to stop server with PID: #{pid}"
|
54
|
-
Process.kill('KILL', pid.to_i)
|
55
|
-
rescue
|
56
|
-
log "Unable to kill process with ID: #{pid}. This may be because the process has already been terminated."
|
57
|
-
end
|
58
|
-
|
59
|
-
log "Cleaning up PID file: #{pid_path}"
|
60
|
-
File.delete(pid_path)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.init_plugin
|
65
|
-
server_path = File.expand_path('../../server.rb', __FILE__)
|
66
|
-
|
67
|
-
if @started
|
68
|
-
return
|
69
|
-
end
|
70
|
-
|
71
|
-
close_manager
|
72
|
-
|
73
|
-
pid = Process.spawn("ruby #{server_path}")
|
74
|
-
log "Started server with PID: #{pid}"
|
75
|
-
|
76
|
-
if pid
|
77
|
-
pid_file = File.open(pid_path, 'w')
|
78
|
-
pid_file << pid
|
79
|
-
pid_file.close
|
80
|
-
log "Wrote server PID (#{pid}) to #{pid_path}"
|
81
|
-
Process.detach(pid)
|
82
|
-
@started = true
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
action_hook(:up, :machine_action_up) { init_plugin }
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require_relative 'lib/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'vagrant-dnsdock-hostupdater'
|
5
|
-
s.version = Vagrant::DnsdockHostUpdater::VERSION
|
6
|
-
s.summary = 'Update hosts'
|
7
|
-
s.description = <<-DESCRIPTION
|
8
|
-
vagrant-dnsdock-hostupdater is a Vagrant plugin which provides the ability to keep the host machines hosts file
|
9
|
-
configured to point at bridged docker containers based on container names: e.g. <container_name>.local.signal.sh.
|
10
|
-
DNSDock should be configured on the guest machine to enable containers to resolve these hosts.
|
11
|
-
DESCRIPTION
|
12
|
-
s.authors = ['Brian Coit']
|
13
|
-
s.email = 'brian.coit@cellosignal.com'
|
14
|
-
s.files = Dir['{lib}/**/*'] + Dir['{lib}/vagrant-dnsdock-hostupdater*
|
15
|
-
'] + ['Rakefile', 'Gemfile', 'Gemfile.lock', 'vagrant-dnsdock-hostupdater.gemspec']
|
16
|
-
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
-
s.require_paths = ['lib']
|
18
|
-
s.homepage = 'https://bitbucket.org/briancoit'
|
19
|
-
s.license = 'ISC'
|
20
|
-
|
21
|
-
|
22
|
-
s.required_ruby_version = '>= 2.0.0'
|
23
|
-
|
24
|
-
s.add_runtime_dependency 'docker-api', '~> 1.33'
|
25
|
-
# gem 'hosts', '~> 0.1.1'
|
26
|
-
s.add_runtime_dependency 'log4r', '~> 1.1', '>= 1.1.10'
|
27
|
-
s.add_runtime_dependency 'linebreak', '~> 2.1', '>= 2.1.0'
|
28
|
-
end
|