ocean_kit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +7 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +103 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +10 -0
- data/exe/ocean_kit +7 -0
- data/lib/helpers.rb +6 -0
- data/lib/ocean_kit/firewalls.rb +116 -0
- data/lib/ocean_kit/version.rb +5 -0
- data/lib/ocean_kit.rb +29 -0
- data/ocean_kit.gemspec +40 -0
- data/sig/ocean_kit.rbs +4 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 75b92697c923ba3bbd38986a848323ad9698ceb0d2efee2f966867f401870486
|
4
|
+
data.tar.gz: f7608656bda388738745ff19676e1109e8f5e53e7242137768b55ed0e068a9c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 369985ffe1b373181333a5f85316cf6fa197e6df49a45cd7bd25705949de5d35d762e785edbabe86c867d66be96ca77c0c2cdedb76c733d2115748a111bda29e
|
7
|
+
data.tar.gz: b1d14c0a7cfd969c5bd592700f5eaca224a6875e835e56ce276adc26dfa55994f2dfacd46e56ad72ceade3beafbc0490bf0aa46e4426dda774bd1365922e8b93
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.standard.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at leo.policastro@hey.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in ocean_kit.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "droplet_kit", "~> 3.16", ">= 3.16.1"
|
9
|
+
|
10
|
+
gem "pastel"
|
11
|
+
|
12
|
+
gem "rake", "~> 13.0"
|
13
|
+
|
14
|
+
gem "rspec", "~> 3.0"
|
15
|
+
|
16
|
+
gem "standard", "~> 1.3"
|
17
|
+
|
18
|
+
gem "thor", "~> 1.2", ">= 1.2.1"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ocean_kit (0.1.0)
|
5
|
+
droplet_kit (~> 3.16, >= 3.16.1)
|
6
|
+
pastel
|
7
|
+
thor (~> 1.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.8.0)
|
13
|
+
public_suffix (>= 2.0.2, < 5.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
axiom-types (0.1.1)
|
16
|
+
descendants_tracker (~> 0.0.4)
|
17
|
+
ice_nine (~> 0.11.0)
|
18
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
19
|
+
coercible (1.0.0)
|
20
|
+
descendants_tracker (~> 0.0.1)
|
21
|
+
descendants_tracker (0.0.4)
|
22
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
23
|
+
diff-lcs (1.5.0)
|
24
|
+
droplet_kit (3.16.1)
|
25
|
+
faraday (>= 0.15)
|
26
|
+
kartograph (~> 0.2.8)
|
27
|
+
resource_kit (~> 0.1.5)
|
28
|
+
virtus (~> 1.0.3)
|
29
|
+
equalizer (0.0.11)
|
30
|
+
faraday (2.2.0)
|
31
|
+
faraday-net_http (~> 2.0)
|
32
|
+
ruby2_keywords (>= 0.0.4)
|
33
|
+
faraday-net_http (2.0.1)
|
34
|
+
ice_nine (0.11.2)
|
35
|
+
kartograph (0.2.8)
|
36
|
+
parallel (1.22.1)
|
37
|
+
parser (3.1.1.0)
|
38
|
+
ast (~> 2.4.1)
|
39
|
+
pastel (0.8.0)
|
40
|
+
tty-color (~> 0.5)
|
41
|
+
public_suffix (4.0.6)
|
42
|
+
rainbow (3.1.1)
|
43
|
+
rake (13.0.6)
|
44
|
+
regexp_parser (2.2.1)
|
45
|
+
resource_kit (0.1.7)
|
46
|
+
addressable (>= 2.3.6, < 3.0.0)
|
47
|
+
rexml (3.2.5)
|
48
|
+
rspec (3.11.0)
|
49
|
+
rspec-core (~> 3.11.0)
|
50
|
+
rspec-expectations (~> 3.11.0)
|
51
|
+
rspec-mocks (~> 3.11.0)
|
52
|
+
rspec-core (3.11.0)
|
53
|
+
rspec-support (~> 3.11.0)
|
54
|
+
rspec-expectations (3.11.0)
|
55
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
+
rspec-support (~> 3.11.0)
|
57
|
+
rspec-mocks (3.11.0)
|
58
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
59
|
+
rspec-support (~> 3.11.0)
|
60
|
+
rspec-support (3.11.0)
|
61
|
+
rubocop (1.26.0)
|
62
|
+
parallel (~> 1.10)
|
63
|
+
parser (>= 3.1.0.0)
|
64
|
+
rainbow (>= 2.2.2, < 4.0)
|
65
|
+
regexp_parser (>= 1.8, < 3.0)
|
66
|
+
rexml
|
67
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
68
|
+
ruby-progressbar (~> 1.7)
|
69
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
70
|
+
rubocop-ast (1.16.0)
|
71
|
+
parser (>= 3.1.1.0)
|
72
|
+
rubocop-performance (1.13.3)
|
73
|
+
rubocop (>= 1.7.0, < 2.0)
|
74
|
+
rubocop-ast (>= 0.4.0)
|
75
|
+
ruby-progressbar (1.11.0)
|
76
|
+
ruby2_keywords (0.0.5)
|
77
|
+
standard (1.9.0)
|
78
|
+
rubocop (= 1.26.0)
|
79
|
+
rubocop-performance (= 1.13.3)
|
80
|
+
thor (1.2.1)
|
81
|
+
thread_safe (0.3.6)
|
82
|
+
tty-color (0.6.0)
|
83
|
+
unicode-display_width (2.1.0)
|
84
|
+
virtus (1.0.5)
|
85
|
+
axiom-types (~> 0.1)
|
86
|
+
coercible (~> 1.0)
|
87
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
88
|
+
equalizer (~> 0.0, >= 0.0.9)
|
89
|
+
|
90
|
+
PLATFORMS
|
91
|
+
arm64-darwin-21
|
92
|
+
|
93
|
+
DEPENDENCIES
|
94
|
+
droplet_kit (~> 3.16, >= 3.16.1)
|
95
|
+
ocean_kit!
|
96
|
+
pastel
|
97
|
+
rake (~> 13.0)
|
98
|
+
rspec (~> 3.0)
|
99
|
+
standard (~> 1.3)
|
100
|
+
thor (~> 1.2, >= 1.2.1)
|
101
|
+
|
102
|
+
BUNDLED WITH
|
103
|
+
2.3.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Leo Policastro
|
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,79 @@
|
|
1
|
+
# OceanKit
|
2
|
+
|
3
|
+
Digital Ocean CLI to update account settings.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ocean_kit'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ocean_kit
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
- OceanKit expects a `~/.ocean_kit/credentials.yml` file to exist on your computer, server etc.
|
24
|
+
|
25
|
+
- The file should have the following format:
|
26
|
+
|
27
|
+
```yml
|
28
|
+
digital_ocean_token: your_digital_ocean_personal_access_token
|
29
|
+
```
|
30
|
+
|
31
|
+
For a list of available commands run
|
32
|
+
|
33
|
+
```
|
34
|
+
$ ocean_kit
|
35
|
+
```
|
36
|
+
|
37
|
+
Sample Output:
|
38
|
+
|
39
|
+
```text
|
40
|
+
Commands:
|
41
|
+
ocean_kit firewalls SUBCOMMAND ...ARGS # manage your DO firewall
|
42
|
+
ocean_kit help [COMMAND] # Describe available commands or one specific command
|
43
|
+
```
|
44
|
+
|
45
|
+
```
|
46
|
+
ocean_kit firewalls
|
47
|
+
```
|
48
|
+
|
49
|
+
Sample output:
|
50
|
+
|
51
|
+
```text
|
52
|
+
Commands:
|
53
|
+
ocean_kit firewalls disable_all_ssh # Disables SSH on all firewalls
|
54
|
+
ocean_kit firewalls disable_ssh [firewall_number] # Disable SSH on given firewall
|
55
|
+
ocean_kit firewalls enable_all_ssh # Enables SSH on all firewalls
|
56
|
+
ocean_kit firewalls enable_ssh [firewall_number] # Enable SSH on given firewall
|
57
|
+
ocean_kit firewalls help [COMMAND] # Describe subcommands or one specific subcommand
|
58
|
+
ocean_kit firewalls list # Lists all firewalls for account.
|
59
|
+
```
|
60
|
+
|
61
|
+
## Development
|
62
|
+
|
63
|
+
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.
|
64
|
+
|
65
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ocean_kit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ocean_kit/blob/main/CODE_OF_CONDUCT.md).
|
70
|
+
|
71
|
+
- Currently only has very basic functionality to list firewalls, and enable or disable ssh on them.
|
72
|
+
|
73
|
+
## License
|
74
|
+
|
75
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
76
|
+
|
77
|
+
## Code of Conduct
|
78
|
+
|
79
|
+
Everyone interacting in the OceanKit project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/leopolicastro/ocean_kit/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/exe/ocean_kit
ADDED
data/lib/helpers.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OceanKit
|
4
|
+
class Firewalls < Thor
|
5
|
+
desc "list", "Lists all firewalls for account."
|
6
|
+
def list
|
7
|
+
puts pastel.white.bold.underline("Firewalls:\n")
|
8
|
+
do_client.firewalls.all.each_with_index do |firewall, index|
|
9
|
+
puts pastel.white.bold("[#{index}]: Firewall #{firewall.name} has #{firewall.droplet_ids.count} droplets")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "enable_all_ssh", "Enables SSH on all firewalls"
|
14
|
+
def enable_all_ssh
|
15
|
+
puts pastel.white.bold("Enabling SSH on all firewalls")
|
16
|
+
do_client.firewalls.all.each_with_index do |fw, index|
|
17
|
+
firewall = do_client.firewalls.find(id: fw.id)
|
18
|
+
inbound_rules = firewall_inbound_rules(firewall)
|
19
|
+
firewall.inbound_rules = add_ssh_rule(inbound_rules)
|
20
|
+
begin
|
21
|
+
update_firewall(firewall)
|
22
|
+
puts pastel.green.bold("SSH enabled on firewall #{firewall.name}")
|
23
|
+
rescue DropletKit::Error => e
|
24
|
+
puts pastel.red.bold("Error: #{e.message}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "disable_all_ssh", "Disables SSH on all firewalls"
|
30
|
+
def disable_all_ssh
|
31
|
+
puts pastel.white.bold("Disabling SSH on all firewalls")
|
32
|
+
do_client.firewalls.all.each_with_index do |fw, index|
|
33
|
+
firewall = do_client.firewalls.find(id: fw.id)
|
34
|
+
inbound_rules = firewall_inbound_rules(firewall)
|
35
|
+
firewall.inbound_rules = remove_ssh_rule(inbound_rules)
|
36
|
+
begin
|
37
|
+
update_firewall(firewall)
|
38
|
+
puts pastel.green.bold("SSH disabled on firewall #{firewall.name}")
|
39
|
+
rescue DropletKit::Error => e
|
40
|
+
puts pastel.red.bold("Error: #{e.message}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "enable_ssh [firewall_number]", "Enable SSH on given firewall"
|
46
|
+
def enable_ssh(number)
|
47
|
+
firewall = do_client.firewalls.find(id: fetch_firewall_id(number))
|
48
|
+
inbound_rules = firewall_inbound_rules(firewall)
|
49
|
+
firewall.inbound_rules = add_ssh_rule(inbound_rules)
|
50
|
+
begin
|
51
|
+
update_firewall(firewall)
|
52
|
+
puts pastel.green.bold("SSH enabled on firewall #{firewall.name}")
|
53
|
+
rescue DropletKit::Error => e
|
54
|
+
puts pastel.red.bold("Error: #{e.message}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "disable_ssh [firewall_number]", "Disable SSH on given firewall"
|
59
|
+
def disable_ssh(number)
|
60
|
+
firewall = do_client.firewalls.find(id: fetch_firewall_id(number))
|
61
|
+
inbound_rules = firewall_inbound_rules(firewall)
|
62
|
+
firewall.inbound_rules = remove_ssh_rule(inbound_rules)
|
63
|
+
begin
|
64
|
+
update_firewall(firewall)
|
65
|
+
puts pastel.green.bold("SSH disabled on firewall #{firewall.name}")
|
66
|
+
rescue DropletKit::Error => e
|
67
|
+
puts pastel.red.bold("Error: #{e.message}")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def fetch_firewall_id(number)
|
74
|
+
do_client.firewalls.all.each_with_index.filter { |firewall, index| index == number.to_i }.flatten.first.id
|
75
|
+
end
|
76
|
+
|
77
|
+
def update_firewall(firewall)
|
78
|
+
new_firewall = DropletKit::Firewall.new(
|
79
|
+
name: firewall.name,
|
80
|
+
inbound_rules: firewall.inbound_rules.map { |rule| new_inbound_rule(rule) },
|
81
|
+
outbound_rules: firewall.outbound_rules,
|
82
|
+
droplet_ids: firewall.droplet_ids,
|
83
|
+
tags: firewall.tags
|
84
|
+
)
|
85
|
+
do_client.firewalls.update(new_firewall, id: firewall.id)
|
86
|
+
end
|
87
|
+
|
88
|
+
def firewall_inbound_rules(firewall)
|
89
|
+
firewall.inbound_rules.map(&:to_h)
|
90
|
+
end
|
91
|
+
|
92
|
+
def new_inbound_rule(rule)
|
93
|
+
DropletKit::FirewallInboundRule.new(
|
94
|
+
protocol: rule[:protocol],
|
95
|
+
ports: rule[:ports],
|
96
|
+
sources: rule[:sources]
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def remove_ssh_rule(rules_array)
|
101
|
+
rules_array.delete_if { |r| r[:ports] == "22" }
|
102
|
+
end
|
103
|
+
|
104
|
+
def add_ssh_rule(rules_array)
|
105
|
+
rules_array << {protocol: "tcp", ports: "22", sources: {addresses: ["0.0.0.0/0", "::/0"]}}
|
106
|
+
end
|
107
|
+
|
108
|
+
def pastel
|
109
|
+
Pastel.new
|
110
|
+
end
|
111
|
+
|
112
|
+
def find_firewall_by_id(id)
|
113
|
+
do_client.firewalls.find(id:)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/lib/ocean_kit.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "droplet_kit"
|
4
|
+
require "pastel"
|
5
|
+
require "thor"
|
6
|
+
require "yaml"
|
7
|
+
|
8
|
+
require_relative "ocean_kit/version"
|
9
|
+
require_relative "./ocean_kit/firewalls"
|
10
|
+
|
11
|
+
module OceanKit
|
12
|
+
class Client < Thor
|
13
|
+
desc "firewalls SUBCOMMAND ...ARGS", "manage your DO firewall"
|
14
|
+
subcommand "firewalls", Firewalls
|
15
|
+
|
16
|
+
no_commands {
|
17
|
+
def client
|
18
|
+
DropletKit::Client.new(access_token: access_token)
|
19
|
+
end
|
20
|
+
|
21
|
+
def access_token
|
22
|
+
credentials_file = YAML.load(File.read(File.expand_path("~/.ocean_kit/credentials.yml")))
|
23
|
+
credentials_file["digital_ocean_token"]
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
class Error < StandardError; end
|
29
|
+
end
|
data/ocean_kit.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/ocean_kit/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ocean_kit"
|
7
|
+
spec.version = OceanKit::VERSION
|
8
|
+
spec.authors = ["Leo Policastro"]
|
9
|
+
spec.email = ["leo.policastro@hey.com"]
|
10
|
+
|
11
|
+
spec.summary = "Digital Ocean CLI Kit"
|
12
|
+
spec.description = "CLI tool to manage your digital ocean account."
|
13
|
+
spec.homepage = "https://github.com/leopolicastro/ocean_kit"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md."
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
spec.add_dependency "thor", "~> 1.2"
|
32
|
+
spec.add_dependency "droplet_kit", "~> 3.16", ">= 3.16.1"
|
33
|
+
spec.add_dependency "pastel"
|
34
|
+
|
35
|
+
# Uncomment to register a new dependency of your gem
|
36
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
37
|
+
|
38
|
+
# For more information and examples about making a new gem, check out our
|
39
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
40
|
+
end
|
data/sig/ocean_kit.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ocean_kit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leo Policastro
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: droplet_kit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.16'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.16.1
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.16'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.16.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pastel
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: CLI tool to manage your digital ocean account.
|
62
|
+
email:
|
63
|
+
- leo.policastro@hey.com
|
64
|
+
executables:
|
65
|
+
- ocean_kit
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- ".rspec"
|
70
|
+
- ".rubocop.yml"
|
71
|
+
- ".standard.yml"
|
72
|
+
- CHANGELOG.md
|
73
|
+
- CODE_OF_CONDUCT.md
|
74
|
+
- Gemfile
|
75
|
+
- Gemfile.lock
|
76
|
+
- LICENSE.txt
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- exe/ocean_kit
|
80
|
+
- lib/helpers.rb
|
81
|
+
- lib/ocean_kit.rb
|
82
|
+
- lib/ocean_kit/firewalls.rb
|
83
|
+
- lib/ocean_kit/version.rb
|
84
|
+
- ocean_kit.gemspec
|
85
|
+
- sig/ocean_kit.rbs
|
86
|
+
homepage: https://github.com/leopolicastro/ocean_kit
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata:
|
90
|
+
homepage_uri: https://github.com/leopolicastro/ocean_kit
|
91
|
+
source_code_uri: https://github.com/leopolicastro/ocean_kit
|
92
|
+
changelog_uri: https://github.com/leopolicastro/ocean_kit/CHANGELOG.md.
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 2.6.0
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubygems_version: 3.3.7
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Digital Ocean CLI Kit
|
112
|
+
test_files: []
|