fog-linode 0.0.1.rc1

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.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rubocop.yml +12 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +17 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/CONTRIBUTORS.md +1 -0
  9. data/Gemfile +6 -0
  10. data/Gemfile.lock +79 -0
  11. data/LICENSE.md +20 -0
  12. data/README.md +74 -0
  13. data/Rakefile +13 -0
  14. data/bin/console +14 -0
  15. data/bin/setup +8 -0
  16. data/fog-linode.gemspec +34 -0
  17. data/lib/fog/linode.rb +17 -0
  18. data/lib/fog/linode/compute.rb +50 -0
  19. data/lib/fog/linode/compute/models/image.rb +23 -0
  20. data/lib/fog/linode/compute/models/images.rb +23 -0
  21. data/lib/fog/linode/compute/models/kernel.rb +19 -0
  22. data/lib/fog/linode/compute/models/kernels.rb +23 -0
  23. data/lib/fog/linode/compute/models/region.rb +14 -0
  24. data/lib/fog/linode/compute/models/regions.rb +23 -0
  25. data/lib/fog/linode/compute/models/server.rb +56 -0
  26. data/lib/fog/linode/compute/models/servers.rb +23 -0
  27. data/lib/fog/linode/compute/models/stack_script.rb +26 -0
  28. data/lib/fog/linode/compute/models/stack_scripts.rb +23 -0
  29. data/lib/fog/linode/compute/models/type.rb +32 -0
  30. data/lib/fog/linode/compute/models/types.rb +23 -0
  31. data/lib/fog/linode/compute/requests/create_server.rb +22 -0
  32. data/lib/fog/linode/compute/requests/delete_server.rb +17 -0
  33. data/lib/fog/linode/compute/requests/list_images.rb +16 -0
  34. data/lib/fog/linode/compute/requests/list_kernels.rb +16 -0
  35. data/lib/fog/linode/compute/requests/list_regions.rb +18 -0
  36. data/lib/fog/linode/compute/requests/list_servers.rb +16 -0
  37. data/lib/fog/linode/compute/requests/list_stack_scripts.rb +16 -0
  38. data/lib/fog/linode/compute/requests/list_types.rb +19 -0
  39. data/lib/fog/linode/compute/requests/update_server.rb +21 -0
  40. data/lib/fog/linode/compute/requests/view_image.rb +17 -0
  41. data/lib/fog/linode/compute/requests/view_kernel.rb +17 -0
  42. data/lib/fog/linode/compute/requests/view_region.rb +18 -0
  43. data/lib/fog/linode/compute/requests/view_server.rb +17 -0
  44. data/lib/fog/linode/compute/requests/view_stack_script.rb +17 -0
  45. data/lib/fog/linode/compute/requests/view_type.rb +18 -0
  46. data/lib/fog/linode/dns.rb +37 -0
  47. data/lib/fog/linode/dns/models/domain.rb +46 -0
  48. data/lib/fog/linode/dns/models/domain_record.rb +38 -0
  49. data/lib/fog/linode/dns/models/domain_records.rb +30 -0
  50. data/lib/fog/linode/dns/models/domains.rb +23 -0
  51. data/lib/fog/linode/dns/requests/create_domain.rb +22 -0
  52. data/lib/fog/linode/dns/requests/create_domain_record.rb +22 -0
  53. data/lib/fog/linode/dns/requests/delete_domain.rb +17 -0
  54. data/lib/fog/linode/dns/requests/delete_domain_record.rb +17 -0
  55. data/lib/fog/linode/dns/requests/list_domain_records.rb +19 -0
  56. data/lib/fog/linode/dns/requests/list_domains.rb +19 -0
  57. data/lib/fog/linode/dns/requests/update_domain.rb +21 -0
  58. data/lib/fog/linode/dns/requests/update_domain_record.rb +22 -0
  59. data/lib/fog/linode/dns/requests/view_domain.rb +18 -0
  60. data/lib/fog/linode/dns/requests/view_domain_record.rb +17 -0
  61. data/lib/fog/linode/paginated_collection.rb +44 -0
  62. data/lib/fog/linode/service.rb +37 -0
  63. data/lib/fog/linode/version.rb +5 -0
  64. metadata +247 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ee4a7ab726fb2a40e4df860b00f8fbabfd6c7658567bde14a89243d8e80e9afd
4
+ data.tar.gz: eb9bb4c56943eb1c152935978cc58d3dd156ad002e20b26b9d4ca5aebe814f54
5
+ SHA512:
6
+ metadata.gz: ba775d0df9224b266473c5e65e7a7e00d946743c3e269353a4e8da375f833507d7abf5c7cdf3af6190dd1038e4d5fd179fd2fb431501e5e04b77fb832cebb09e
7
+ data.tar.gz: d179fae945e81ef023634ce8783279d0da45e1bd01e4285be7ab62ceedd3680f2fb3bb422128ed2fcc1e683e1d4e341286708b021db771c92f089648b6a428b4
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ LineLength:
2
+ Enabled: false
3
+ MethodLength:
4
+ Enabled: false
5
+ BlockLength:
6
+ Enabled: false
7
+ ClassLength:
8
+ Enabled: false
9
+ Style/FrozenStringLiteralComment:
10
+ Enabled: false
11
+ Style/NumericLiterals:
12
+ Enabled: false
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ fog-linode
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.4.5
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+
6
+ rvm:
7
+ - 2.0.0
8
+ - 2.1.0
9
+ - 2.1.1
10
+ - 2.1.5
11
+ - 2.2.10
12
+ - 2.3.7
13
+ - 2.4.4
14
+ - 2.5.1
15
+ - jruby-head
16
+
17
+ before_install: gem install bundler "< 2"
@@ -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 TODO: Write your email address. 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/CONTRIBUTORS.md ADDED
@@ -0,0 +1 @@
1
+ * Charles Treatman (ctreatman@linode.com)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in fog-linode.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,79 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fog-linode (0.0.1.rc1)
5
+ fog-core (~> 1.43)
6
+ fog-json (~> 1.0.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.6.0)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ ast (2.4.0)
14
+ builder (3.2.3)
15
+ crack (0.4.3)
16
+ safe_yaml (~> 1.0.0)
17
+ docile (1.3.1)
18
+ excon (0.64.0)
19
+ fog-core (1.45.0)
20
+ builder
21
+ excon (~> 0.58)
22
+ formatador (~> 0.2)
23
+ fog-json (1.0.2)
24
+ fog-core (~> 1.0)
25
+ multi_json (~> 1.10)
26
+ formatador (0.2.5)
27
+ hashdiff (0.3.9)
28
+ jaro_winkler (1.5.2)
29
+ json (2.2.0)
30
+ metaclass (0.0.4)
31
+ minitest (5.11.3)
32
+ mocha (1.8.0)
33
+ metaclass (~> 0.0.1)
34
+ multi_json (1.13.1)
35
+ parallel (1.17.0)
36
+ parser (2.6.2.1)
37
+ ast (~> 2.4.0)
38
+ psych (3.1.0)
39
+ public_suffix (3.0.3)
40
+ rainbow (3.0.0)
41
+ rake (10.5.0)
42
+ rubocop (0.67.2)
43
+ jaro_winkler (~> 1.5.1)
44
+ parallel (~> 1.10)
45
+ parser (>= 2.5, != 2.5.1.1)
46
+ psych (>= 3.1.0)
47
+ rainbow (>= 2.2.2, < 4.0)
48
+ ruby-progressbar (~> 1.7)
49
+ unicode-display_width (>= 1.4.0, < 1.6)
50
+ ruby-progressbar (1.10.0)
51
+ safe_yaml (1.0.5)
52
+ simplecov (0.16.1)
53
+ docile (~> 1.1)
54
+ json (>= 1.8, < 3)
55
+ simplecov-html (~> 0.10.0)
56
+ simplecov-html (0.10.2)
57
+ unicode-display_width (1.5.0)
58
+ vcr (4.0.0)
59
+ webmock (3.5.1)
60
+ addressable (>= 2.3.6)
61
+ crack (>= 0.3.2)
62
+ hashdiff
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ bundler (~> 1.16)
69
+ fog-linode!
70
+ minitest (~> 5.0)
71
+ mocha
72
+ rake (~> 10.0)
73
+ rubocop
74
+ simplecov
75
+ vcr
76
+ webmock
77
+
78
+ BUNDLED WITH
79
+ 1.16.6
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 [CONTRIBUTORS.md](https://github.com/Linode/fog-linode/blob/master/CONTRIBUTORS.md)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Fog::Linode
2
+
3
+ This is the plugin Gem to talk to [Linode](https://linode.com) clouds via [`fog`](https://github.com/fog/fog).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fog-linode'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fog-linode
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'fog/linode'
25
+
26
+ compute = Fog::Compute.new(provider: :linode, linode_token: '<your LinodeAPIv4 access token>')
27
+ all_kernels = compute.kernels.all # Fetch all kernels from the Linode API
28
+ kvm_kernels = compute.kernels.all(filters: { kvm: true }) # Fetch all KVM kernels from the Linode API
29
+ kvm_kernels_page_2 = compute.kernels.all(page: 2, filters: { kvm: true }) # Fetch only the 2nd page of KVM kernels
30
+ finnix = compute.kernels.get('linode/finnix-legacy') # Load details for a single kernel
31
+
32
+ # Complex filtering
33
+ wordpress_stack_scripts = compute.stack_scripts.all(filters: { description: { '+contains': 'WordPress' } }) # Load all StackScripts with a description containing 'WordPress'
34
+
35
+ # Creating a Linode instance
36
+ regions = compute.regions.all
37
+ types = compute.types.all
38
+ images = compute.images.all({filters: { label: { '+contains': 'CentOS' } } })
39
+ server = compute.servers.new
40
+ server.region = regions[2].id
41
+ server.type = types[4].id
42
+ server.image = images.first.id
43
+ server.root_pass = '<password>'
44
+ server.save
45
+
46
+ # Updating a Linode instance
47
+ server.tags = ['add', 'some', 'tags']
48
+ server.save
49
+
50
+ # Working with Linode Domains
51
+ dns = Fog::DNS.new(provider: :linode, linode_token: '<your LinodeAPIv4 access token>')
52
+ all_domains = dns.domains.all # Load all Linode Domains on your account
53
+ exsiting_domain = dns.domains.get(1234567890) # Load details for a single Linode Domain on your account
54
+
55
+ new_domain = dns.domains.new
56
+ new_domain.domain = 'fog-linode.example.com'
57
+ new_domain.type = 'master'
58
+ new_domain.soa_email = 'fog-linode@example.com'
59
+ new_domain.save # Create the new domain
60
+ ```
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
65
+
66
+ 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).
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Linode/fog-linode. 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.
71
+
72
+ ## Code of Conduct
73
+
74
+ Everyone interacting in the Fog::Linode project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Linode/fog-linode/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'rubocop/rake_task'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs.push 'spec'
7
+ t.test_files = FileList['spec/**/*_spec.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+ RuboCop::RakeTask.new
12
+
13
+ task default: %i[rubocop test]
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'fog/linode'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'fog/linode/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'fog-linode'
7
+ spec.version = Fog::Linode::VERSION
8
+ spec.authors = ['Charles Treatman']
9
+ spec.email = ['charles.treatman@gmail.com']
10
+
11
+ spec.summary = "Module for the 'fog' gem to support Linode cloud services."
12
+ spec.description = "This library can be used as a module for 'fog' or as standalone provider
13
+ to use the Linode cloud services in applications."
14
+ spec.homepage = 'https://github.com/Linode/fog-linode'
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'minitest', '~> 5.0'
25
+ spec.add_development_dependency 'mocha'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'simplecov'
29
+ spec.add_development_dependency 'vcr'
30
+ spec.add_development_dependency 'webmock'
31
+
32
+ spec.add_dependency 'fog-core', '~> 1.43'
33
+ spec.add_dependency 'fog-json', '~> 1.0.2'
34
+ end
data/lib/fog/linode.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'fog/core'
2
+ require 'fog/json'
3
+ require 'fog/linode/version'
4
+ require 'fog/linode/service'
5
+
6
+ module Fog
7
+ # Main Linode fog provider module
8
+ module Linode
9
+ extend Fog::Provider
10
+
11
+ autoload :Compute, File.expand_path('linode/compute', __dir__)
12
+ autoload :DNS, File.expand_path('linode/dns', __dir__)
13
+
14
+ service(:compute, 'Compute')
15
+ service(:dns, 'DNS')
16
+ end
17
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module Linode
3
+ # Fog service class for Linode Compute service
4
+ class Compute < Fog::Service
5
+ requires :linode_token
6
+
7
+ request_path 'fog/linode/compute/requests'
8
+ request :list_types
9
+ request :view_type
10
+ request :list_kernels
11
+ request :view_kernel
12
+ request :list_regions
13
+ request :view_region
14
+ request :list_stack_scripts
15
+ request :view_stack_script
16
+ request :list_images
17
+ request :view_image
18
+ request :create_server
19
+ request :list_servers
20
+ request :view_server
21
+ request :update_server
22
+ request :delete_server
23
+
24
+ model_path 'fog/linode/compute/models'
25
+ collection :types
26
+ model :type
27
+ collection :kernels
28
+ model :kernel
29
+ collection :regions
30
+ model :region
31
+ collection :servers
32
+ model :server
33
+ collection :stack_scripts
34
+ model :stack_script
35
+ collection :images
36
+ model :image
37
+
38
+ # Real implementation for Linode Compute service
39
+ class Real < Service
40
+ end
41
+
42
+ # Mock service for unit tests
43
+ # NOTE: we do not currently use this, but Fog throws an
44
+ # error if it's not defined for a Service class
45
+ class Mock
46
+ def initialize(_options = {}); end
47
+ end
48
+ end
49
+ end
50
+ end