linode-ip 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +75 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/linode-ip +10 -0
- data/lib/linode/ip.rb +79 -0
- data/lib/linode/ip/version.rb +7 -0
- data/linode-ip.gemspec +46 -0
- data/spec/linode/ip_spec.rb +85 -0
- data/spec/spec_helper.rb +16 -0
- metadata +122 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f6d6d2855bf028b80f17cbd75c0bdc8331032b0f75f88c4f10a0de2722b9f25d
|
|
4
|
+
data.tar.gz: 79150bb9a78e6f9a24e99fa4fa0b21221961a096ea70cdd127a6f0f3e5aed6bc
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cc9362426f0da6f2ca819bf85c2e12ab978c8667935e3e5d5f34e67c0d7891418444cfc283aa66fcd099a889e621b9c98ef35dd0eda76ed8c0c97960787f7891
|
|
7
|
+
data.tar.gz: 3fd087b026fdb4116f6925fc28de4b24b78079b9ce96bfd8ac2e81a62dadcdd90934a61e45b73f1332931180e3bf40bfb71e0627d30073026053c0b0ab8822dd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at dtkinzer@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
linode-ip (1.0.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.0)
|
|
10
|
+
diff-lcs (1.3)
|
|
11
|
+
jaro_winkler (1.5.4)
|
|
12
|
+
parallel (1.19.1)
|
|
13
|
+
parser (2.7.0.2)
|
|
14
|
+
ast (~> 2.4.0)
|
|
15
|
+
rainbow (3.0.0)
|
|
16
|
+
rake (10.5.0)
|
|
17
|
+
rspec (3.9.0)
|
|
18
|
+
rspec-core (~> 3.9.0)
|
|
19
|
+
rspec-expectations (~> 3.9.0)
|
|
20
|
+
rspec-mocks (~> 3.9.0)
|
|
21
|
+
rspec-core (3.9.1)
|
|
22
|
+
rspec-support (~> 3.9.1)
|
|
23
|
+
rspec-expectations (3.9.0)
|
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
25
|
+
rspec-support (~> 3.9.0)
|
|
26
|
+
rspec-mocks (3.9.1)
|
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
+
rspec-support (~> 3.9.0)
|
|
29
|
+
rspec-support (3.9.2)
|
|
30
|
+
rubocop (0.79.0)
|
|
31
|
+
jaro_winkler (~> 1.5.1)
|
|
32
|
+
parallel (~> 1.10)
|
|
33
|
+
parser (>= 2.7.0.1)
|
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
35
|
+
ruby-progressbar (~> 1.7)
|
|
36
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
|
37
|
+
ruby-progressbar (1.10.1)
|
|
38
|
+
unicode-display_width (1.6.1)
|
|
39
|
+
|
|
40
|
+
PLATFORMS
|
|
41
|
+
ruby
|
|
42
|
+
|
|
43
|
+
DEPENDENCIES
|
|
44
|
+
bundler (~> 1.17)
|
|
45
|
+
linode-ip!
|
|
46
|
+
rake (~> 10.0)
|
|
47
|
+
rspec (~> 3.0)
|
|
48
|
+
rubocop
|
|
49
|
+
|
|
50
|
+
BUNDLED WITH
|
|
51
|
+
1.17.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 David Kinzer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Linode::Ip
|
|
2
|
+
|
|
3
|
+
This gem adds the linode-ip executable that takes a match string and returns
|
|
4
|
+
the ipv4 address of a linode whose label matches the string. If there is more
|
|
5
|
+
than one match then an interactive session is enabled that allows the user to
|
|
6
|
+
pick from a list of matches or to change the matching string.
|
|
7
|
+
|
|
8
|
+
This gem assumes that the `linode-cli` is available
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Add this line to your application's Gemfile:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem 'linode-ip'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
And then execute:
|
|
19
|
+
|
|
20
|
+
$ bundle
|
|
21
|
+
|
|
22
|
+
Or install it yourself as:
|
|
23
|
+
|
|
24
|
+
$ gem install linode-ip
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Example:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
linode-ip traefik
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Returns the ip address of the linode labeled traefik.
|
|
35
|
+
|
|
36
|
+
Note that the matching string can be a regex.
|
|
37
|
+
|
|
38
|
+
If more than one match is found, then a session is opened allowing the user to choose between possible matches.
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
> linode-ip qa
|
|
42
|
+
Multiple matching linodes found:
|
|
43
|
+
-------------------------------
|
|
44
|
+
(0) cob-qa-solr-1
|
|
45
|
+
(1) qa-tupress-web
|
|
46
|
+
(2) ojs3-qa
|
|
47
|
+
(3) cob-qa-web
|
|
48
|
+
(4) manifold_qa
|
|
49
|
+
(5) funcake_qa
|
|
50
|
+
(6) aggregator_qa
|
|
51
|
+
(7) airflow_qa
|
|
52
|
+
|
|
53
|
+
[u] Update linode matcher
|
|
54
|
+
[e] exit
|
|
55
|
+
|
|
56
|
+
Choose a lionde or command?
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Development
|
|
60
|
+
|
|
61
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
62
|
+
|
|
63
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dkinzer/linode-ip. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
72
|
+
|
|
73
|
+
## Code of Conduct
|
|
74
|
+
|
|
75
|
+
Everyone interacting in the Linode::Ip project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dkinzer/linode-ip/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'linode/ip'
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/linode-ip
ADDED
data/lib/linode/ip.rb
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'linode/ip/version'
|
|
4
|
+
require 'json'
|
|
5
|
+
|
|
6
|
+
module Linode
|
|
7
|
+
# Method for fetching ip of linode matching a label.
|
|
8
|
+
module Ip
|
|
9
|
+
class Error < StandardError; end
|
|
10
|
+
|
|
11
|
+
def fetch(name)
|
|
12
|
+
matched_linodes = maching_linodes(linodes, name)
|
|
13
|
+
|
|
14
|
+
return if matched_linodes.empty?
|
|
15
|
+
|
|
16
|
+
return matched_linodes[0]['ipv4'].first if matched_linodes.count == 1
|
|
17
|
+
|
|
18
|
+
n = select_linodes_index(matched_linodes)
|
|
19
|
+
|
|
20
|
+
if n == 'u'
|
|
21
|
+
fetch(read_matcher)
|
|
22
|
+
else
|
|
23
|
+
matched_linodes[n]['ipv4'].first
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def linodes
|
|
30
|
+
@linodes ||= JSON.parse(`linode-cli --json linodes list`)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def select_linodes_index(linodes)
|
|
34
|
+
puts_which_linodes(linodes)
|
|
35
|
+
process_linodes_selection(linodes, STDIN.gets.chomp)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def read_matcher
|
|
39
|
+
puts 'What matcher should I use?'
|
|
40
|
+
STDIN.gets.chomp
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def maching_linodes(linodes, name)
|
|
44
|
+
linodes
|
|
45
|
+
.select { |linode| linode['label'].match?(/#{name}/) }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def puts_which_linodes(linodes)
|
|
49
|
+
puts 'Multiple matching linodes found:'
|
|
50
|
+
puts '-------------------------------'
|
|
51
|
+
linodes.each_with_index do |linode, n|
|
|
52
|
+
puts "(#{n}) #{linode['label']}"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
puts
|
|
56
|
+
puts '[u] Update linode matcher'
|
|
57
|
+
puts '[e] exit'
|
|
58
|
+
puts
|
|
59
|
+
puts 'Choose a lionde or command?'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def process_linodes_selection(linodes, selection)
|
|
63
|
+
if (0...linodes.count).map(&:to_s).include?(selection)
|
|
64
|
+
selection.to_i
|
|
65
|
+
elsif selection == 'e'
|
|
66
|
+
puts_good_bye
|
|
67
|
+
elsif selection == 'u'
|
|
68
|
+
selection
|
|
69
|
+
else
|
|
70
|
+
select_linodes_index(linodes)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def puts_good_bye
|
|
75
|
+
puts 'Good bye!'
|
|
76
|
+
exit
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
data/linode-ip.gemspec
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require 'linode/ip/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = 'linode-ip'
|
|
9
|
+
spec.version = Linode::Ip::VERSION
|
|
10
|
+
spec.authors = ['David Kinzer']
|
|
11
|
+
spec.email = ['dtkinzer@gmail.com']
|
|
12
|
+
|
|
13
|
+
spec.summary = 'Gets the ip address of linode with maching label'
|
|
14
|
+
spec.description = %w[ Adds the linode-ip executable for getting ip address
|
|
15
|
+
of linode with matching label. ]
|
|
16
|
+
spec.homepage = 'https://github.com/dkinzer/linode-ip'
|
|
17
|
+
spec.license = 'MIT'
|
|
18
|
+
|
|
19
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the
|
|
20
|
+
# 'allowed_push_host' to allow pushing to a single host or delete this
|
|
21
|
+
# section to allow pushing to any host.
|
|
22
|
+
if spec.respond_to?(:metadata)
|
|
23
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
24
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
25
|
+
spec.metadata['changelog_uri'] = spec.homepage + '/blob/master/CHANGELOG.md'
|
|
26
|
+
else
|
|
27
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
|
28
|
+
'public gem pushes.'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Specify which files should be added to the gem when it is released.
|
|
32
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been
|
|
33
|
+
# added into git.
|
|
34
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
35
|
+
`git ls-files -z`
|
|
36
|
+
.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/ }) }
|
|
37
|
+
end
|
|
38
|
+
spec.bindir = 'exe'
|
|
39
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
40
|
+
spec.require_paths = ['lib']
|
|
41
|
+
|
|
42
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
|
43
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
44
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
45
|
+
spec.add_development_dependency 'rubocop', '~> 0.79'
|
|
46
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rubocop: disable Metrics/BlockLength
|
|
4
|
+
RSpec.describe Linode::Ip do
|
|
5
|
+
subject { Class.extend(Linode::Ip) }
|
|
6
|
+
|
|
7
|
+
it 'has a version number' do
|
|
8
|
+
expect(Linode::Ip::VERSION).not_to be nil
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
before do
|
|
12
|
+
allow(subject).to receive(:linodes) { linodes }
|
|
13
|
+
allow(subject).to receive(:select_linodes_index) { selection }
|
|
14
|
+
allow(subject).to receive(:read_matcher) { matcher }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'linodes is empty' do
|
|
18
|
+
let(:linodes) { [] }
|
|
19
|
+
|
|
20
|
+
it 'does not fetch any ips' do
|
|
21
|
+
expect(subject.fetch('foo')).to be_nil
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context 'linodes does not have a match' do
|
|
26
|
+
let(:linodes) { [{ 'label' => 'bar' }] }
|
|
27
|
+
|
|
28
|
+
it 'does not fetch any ips' do
|
|
29
|
+
expect(subject.fetch('foo')).to be_nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'linodes has a single matching node' do
|
|
34
|
+
let(:linodes) { [{ 'label' => 'foo', 'ipv4' => ['host.ip'] }] }
|
|
35
|
+
|
|
36
|
+
it 'fetches the ip' do
|
|
37
|
+
expect(subject.fetch('foo')).to eq('host.ip')
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context 'there are multiple matching linodes' do
|
|
42
|
+
let(:linodes) do
|
|
43
|
+
[{ 'label' => 'foo0', 'ipv4' => ['host.ip0'] },
|
|
44
|
+
{ 'label' => 'foo1', 'ipv4' => ['host.ip1'] },
|
|
45
|
+
{ 'label' => 'foo2', 'ipv4' => ['host.ip2'] }]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
let(:selection) { 1 }
|
|
49
|
+
|
|
50
|
+
it 'fetches the selected linode ip' do
|
|
51
|
+
expect(subject.fetch('foo')).to eq('host.ip1')
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context 'we choose to update the matcher with single match' do
|
|
56
|
+
let(:linodes) do
|
|
57
|
+
[{ 'label' => 'foo0', 'ipv4' => ['host.ip0'] },
|
|
58
|
+
{ 'label' => 'foo1', 'ipv4' => ['host.ip1'] },
|
|
59
|
+
{ 'label' => 'bar', 'ipv4' => ['host.ipbar'] }]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
let(:selection) { 'u' }
|
|
63
|
+
let(:matcher) { 'bar' }
|
|
64
|
+
|
|
65
|
+
it 'fetches the newly matched linode' do
|
|
66
|
+
expect(subject.fetch('foo')).to eq('host.ipbar')
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'we choose to update the matcher with no match' do
|
|
71
|
+
let(:linodes) do
|
|
72
|
+
[{ 'label' => 'foo0', 'ipv4' => ['host.ip0'] },
|
|
73
|
+
{ 'label' => 'foo1', 'ipv4' => ['host.ip1'] },
|
|
74
|
+
{ 'label' => 'bar', 'ipv4' => ['host.ipbar'] }]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
let(:selection) { 'u' }
|
|
78
|
+
let(:matcher) { 'buzz' }
|
|
79
|
+
|
|
80
|
+
it 'fetches the newly matched linode' do
|
|
81
|
+
expect(subject.fetch('foo')).to be_nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
# rubocop: enable Metrics/BlockLength
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'linode/ip'
|
|
5
|
+
|
|
6
|
+
RSpec.configure do |config|
|
|
7
|
+
# Enable flags like --only-failures and --next-failure
|
|
8
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
|
9
|
+
|
|
10
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
11
|
+
config.disable_monkey_patching!
|
|
12
|
+
|
|
13
|
+
config.expect_with :rspec do |c|
|
|
14
|
+
c.syntax = :expect
|
|
15
|
+
end
|
|
16
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: linode-ip
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- David Kinzer
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-02-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.17'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.17'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0.79'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0.79'
|
|
69
|
+
description: '["Adds", "the", "linode-ip", "executable", "for", "getting", "ip", "address",
|
|
70
|
+
"of", "linode", "with", "matching", "label."]'
|
|
71
|
+
email:
|
|
72
|
+
- dtkinzer@gmail.com
|
|
73
|
+
executables:
|
|
74
|
+
- linode-ip
|
|
75
|
+
extensions: []
|
|
76
|
+
extra_rdoc_files: []
|
|
77
|
+
files:
|
|
78
|
+
- ".gitignore"
|
|
79
|
+
- ".rspec"
|
|
80
|
+
- ".travis.yml"
|
|
81
|
+
- CHANGELOG.md
|
|
82
|
+
- CODE_OF_CONDUCT.md
|
|
83
|
+
- Gemfile
|
|
84
|
+
- Gemfile.lock
|
|
85
|
+
- LICENSE.txt
|
|
86
|
+
- README.md
|
|
87
|
+
- Rakefile
|
|
88
|
+
- bin/console
|
|
89
|
+
- bin/setup
|
|
90
|
+
- exe/linode-ip
|
|
91
|
+
- lib/linode/ip.rb
|
|
92
|
+
- lib/linode/ip/version.rb
|
|
93
|
+
- linode-ip.gemspec
|
|
94
|
+
- spec/linode/ip_spec.rb
|
|
95
|
+
- spec/spec_helper.rb
|
|
96
|
+
homepage: https://github.com/dkinzer/linode-ip
|
|
97
|
+
licenses:
|
|
98
|
+
- MIT
|
|
99
|
+
metadata:
|
|
100
|
+
homepage_uri: https://github.com/dkinzer/linode-ip
|
|
101
|
+
source_code_uri: https://github.com/dkinzer/linode-ip
|
|
102
|
+
changelog_uri: https://github.com/dkinzer/linode-ip/blob/master/CHANGELOG.md
|
|
103
|
+
post_install_message:
|
|
104
|
+
rdoc_options: []
|
|
105
|
+
require_paths:
|
|
106
|
+
- lib
|
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">="
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0'
|
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
117
|
+
requirements: []
|
|
118
|
+
rubygems_version: 3.0.3
|
|
119
|
+
signing_key:
|
|
120
|
+
specification_version: 4
|
|
121
|
+
summary: Gets the ip address of linode with maching label
|
|
122
|
+
test_files: []
|