ocean_kit 0.1.4 ā 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -5
- data/lib/ocean_kit/helpers/client.rb +1 -3
- data/lib/ocean_kit/helpers/firewalls.rb +8 -0
- data/lib/ocean_kit/resources/config.rb +1 -0
- data/lib/ocean_kit/resources/droplets.rb +4 -3
- data/lib/ocean_kit/resources/firewalls.rb +26 -0
- data/lib/ocean_kit/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e56758dbb6997beaaf3d41ee3c9a5522141d7867f48911b6d137d1262887b89e
|
4
|
+
data.tar.gz: d863b404fd0f3a23c57fbe7ea1ebef79434e7ea4dea9d116b24cf171e52e9902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd0f095267d7fd7b06ae1ef103e1b47fd290a50258e0e959de0cfd890b62feb6631b6b8176901bdb6d58b2e689769be514fa645e4cac763af83797ca73074f7e
|
7
|
+
data.tar.gz: f56d1c507cf56e33666406e8a6813fb86a256b1bedf2784cd1057e0344d62e6ce5f465512e6ef03ed287099c0adb97c4aae8f4fda87f674ba69d49abe1bde57b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,11 +24,17 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
- The file should have the following format:
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
```yml
|
28
|
+
digital_ocean_token: your_digital_ocean_personal_access_token
|
29
|
+
```
|
30
30
|
|
31
|
-
|
31
|
+
- You can also generate the file and folder by running:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
$ ocean_kit config setup
|
35
|
+
```
|
36
|
+
|
37
|
+
For a full list of available commands run
|
32
38
|
|
33
39
|
```
|
34
40
|
$ ocean_kit
|
@@ -66,7 +72,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
66
72
|
|
67
73
|
## Contributing
|
68
74
|
|
69
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/leopolicastro/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/leopolicastro/ocean_kit/blob/main/CODE_OF_CONDUCT.md).
|
70
76
|
|
71
77
|
- Currently only has very basic functionality to list firewalls, and enable or disable ssh on them.
|
72
78
|
|
@@ -6,8 +6,6 @@ end
|
|
6
6
|
|
7
7
|
def access_token
|
8
8
|
credentials_file["digital_ocean_token"]
|
9
|
-
rescue => e
|
10
|
-
puts pastel.red.bold("Error: #{e.message}")
|
11
9
|
end
|
12
10
|
|
13
11
|
def credentials_file
|
@@ -16,7 +14,7 @@ end
|
|
16
14
|
|
17
15
|
def check_credentials_file
|
18
16
|
if credentials_file.nil?
|
19
|
-
puts pastel.red.bold("Error: credentials file not found. Please run `ocean_kit setup` first.")
|
17
|
+
puts pastel.red.bold("Error: credentials file not found. Please run `ocean_kit config setup` first.")
|
20
18
|
exit 1
|
21
19
|
end
|
22
20
|
end
|
@@ -34,3 +34,11 @@ end
|
|
34
34
|
def add_ssh_rule(rules_array)
|
35
35
|
rules_array << {protocol: "tcp", ports: "22", sources: {addresses: ["0.0.0.0/0", "::/0"]}}
|
36
36
|
end
|
37
|
+
|
38
|
+
def add_http_rule(rules_array)
|
39
|
+
rules_array << {protocol: "tcp", ports: "80", sources: {addresses: ["0.0.0.0/0", "::/0"]}}
|
40
|
+
end
|
41
|
+
|
42
|
+
def remove_http_rule(rules_array)
|
43
|
+
rules_array.delete_if { |r| r[:ports] == "80" }
|
44
|
+
end
|
@@ -15,6 +15,7 @@ module OceanKit
|
|
15
15
|
YAML
|
16
16
|
end
|
17
17
|
puts pastel.green.bold("Successfully setup OceanKit environment.")
|
18
|
+
puts pastel.white.bold("Please add your Digital Ocean personal access token your credentials in ~/.ocean_kit/credentials.yml") if access_token.nil?
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -4,16 +4,17 @@ module OceanKit
|
|
4
4
|
class Droplets < Thor
|
5
5
|
desc "list", "Lists all droplers."
|
6
6
|
def list
|
7
|
-
puts underline_text("Droplets
|
8
|
-
puts pastel.blue.bold "š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³\n"
|
7
|
+
puts underline_text("Droplets:\n")
|
9
8
|
do_client.droplets.all.each_with_index do |droplet, index|
|
9
|
+
puts "------------------------------\n"
|
10
|
+
|
11
|
+
puts pastel.white.bold "#: ", pastel.clear.white(index + 1)
|
10
12
|
puts pastel.white.bold "Name: ", pastel.clear.white(droplet.name)
|
11
13
|
puts pastel.white.bold "ID: ", pastel.clear.white(droplet.id)
|
12
14
|
puts pastel.white.bold "Public IP: ", pastel.clear.white(droplet.networks.v4.first.ip_address)
|
13
15
|
puts pastel.white.bold "Region: ", pastel.clear.white(droplet.region.slug)
|
14
16
|
puts pastel.white.bold "Status: ", pastel.clear.white(droplet.status)
|
15
17
|
puts pastel.white.bold "Created: ", pastel.clear.white(droplet.created_at)
|
16
|
-
puts pastel.blue.bold "\nš³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³š³\n"
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -68,5 +68,31 @@ module OceanKit
|
|
68
68
|
puts pastel.red.bold("Error: #{e.message}")
|
69
69
|
end
|
70
70
|
end
|
71
|
+
|
72
|
+
desc "enable port 80", "Enable HTTP on given firewall"
|
73
|
+
def enable_http(number)
|
74
|
+
firewall = fetch_firewall(number)
|
75
|
+
inbound_rules = firewall_inbound_rules(firewall)
|
76
|
+
firewall.inbound_rules = add_http_rule(inbound_rules)
|
77
|
+
begin
|
78
|
+
update_firewall(firewall)
|
79
|
+
puts pastel.green.bold("HTTP enabled on firewall #{firewall.name}")
|
80
|
+
rescue DropletKit::Error => e
|
81
|
+
puts pastel.red.bold("Error: #{e.message}")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "disable_http [firewall_number]", "Disable HTTP on given firewall"
|
86
|
+
def disable_http(number)
|
87
|
+
firewall = fetch_firewall(number)
|
88
|
+
inbound_rules = firewall_inbound_rules(firewall)
|
89
|
+
firewall.inbound_rules = remove_http_rule(inbound_rules)
|
90
|
+
begin
|
91
|
+
update_firewall(firewall)
|
92
|
+
puts pastel.green.bold("HTTP disabled on firewall #{firewall.name}")
|
93
|
+
rescue DropletKit::Error => e
|
94
|
+
puts pastel.red.bold("Error: #{e.message}")
|
95
|
+
end
|
96
|
+
end
|
71
97
|
end
|
72
98
|
end
|
data/lib/ocean_kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocean_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo Policastro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
|
-
rubygems_version: 3.3.
|
114
|
+
rubygems_version: 3.3.10
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Digital Ocean CLI Kit
|