ocean_kit 0.1.3 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b7e53bd320bed32a746bf8c938e41916adc797399bc99f31588b1a046e0251f
4
- data.tar.gz: bbc4ccb88be8a07bf60856eff18070c0506dd0b65493b2f2e8fefdae0a5593f3
3
+ metadata.gz: 42ede6cb8e3013e2811666c8be0eb81e1519ec1a613364a511839f25b6789ab9
4
+ data.tar.gz: 203f1b609829a882768a36f79a7efffb9b25707c71bbba0cefb86681d0498184
5
5
  SHA512:
6
- metadata.gz: 91c945c7f2b00964879a4c90db6b5d1190c5de0acc90dda89abeb64f682628ec2f5616d8276e315f3fedaa80bd4f30b89a27fa683488ba75b45059453bb54f2c
7
- data.tar.gz: 2054bd0e4293709c4616a9f40538d0f6b733a8e40537eb727802c943148fb42e8537534b1ebe428bc9a6b205fd32e624e989fd63d13d98d5cc097b29dbf5fbb1
6
+ metadata.gz: 78e8239b700e48e14480fb69430e156a2baf10893858130d7fe67a6e8e65b215de951308f1d73713cd3284742caaf9edf156d1e75c5eb5978a27a57b9c9c94bb
7
+ data.tar.gz: 3c5344925df8decdc54dfa18f0f781d5e964d42af0d2f33776ad80c33b7b4448d05e2e1f2540600509dc347ec3032d5435068c953b357e13b5afab4a568c8bec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ocean_kit (0.1.2)
4
+ ocean_kit (0.1.5)
5
5
  droplet_kit (~> 3.16, >= 3.16.1)
6
6
  pastel
7
7
  thor (~> 1.2)
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
- ```yml
28
- digital_ocean_token: your_digital_ocean_personal_access_token
29
- ```
27
+ ```yml
28
+ digital_ocean_token: your_digital_ocean_personal_access_token
29
+ ```
30
30
 
31
- For a list of available commands run
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
@@ -55,7 +61,7 @@ Commands:
55
61
  ocean_kit firewalls enable_all_ssh # Enables SSH on all firewalls
56
62
  ocean_kit firewalls enable_ssh [firewall_number] # Enable SSH on given firewall
57
63
  ocean_kit firewalls help [COMMAND] # Describe subcommands or one specific subcommand
58
- ocean_kit firewalls list # Lists all firewalls for account.
64
+ ocean_kit firewalls list # Lists all firewalls.
59
65
  ```
60
66
 
61
67
  ## Development
@@ -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/[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).
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
 
data/exe/ocean_kit CHANGED
@@ -2,4 +2,6 @@
2
2
 
3
3
  require "ocean_kit"
4
4
 
5
+ check_credentials_file
6
+
5
7
  OceanKit::Client.start(ARGV)
@@ -5,8 +5,16 @@ def do_client
5
5
  end
6
6
 
7
7
  def access_token
8
- credentials_file = YAML.load(File.read(File.expand_path("~/.ocean_kit/credentials.yml")))
9
8
  credentials_file["digital_ocean_token"]
10
- rescue => e
11
- puts pastel.red.bold("Error: #{e.message}")
9
+ end
10
+
11
+ def credentials_file
12
+ YAML.load(File.read(File.expand_path("~/.ocean_kit/credentials.yml")))
13
+ end
14
+
15
+ def check_credentials_file
16
+ if credentials_file.nil?
17
+ puts pastel.red.bold("Error: credentials file not found. Please run `ocean_kit config setup` first.")
18
+ exit 1
19
+ end
12
20
  end
@@ -3,3 +3,15 @@
3
3
  def pastel
4
4
  Pastel.new
5
5
  end
6
+
7
+ def default_text(text)
8
+ pastel.white(text)
9
+ end
10
+
11
+ def underline_text(text)
12
+ pastel.white.bold.underline(text)
13
+ end
14
+
15
+ def bold_text(text)
16
+ pastel.white.bold(text)
17
+ end
@@ -1 +1,3 @@
1
1
  require_relative "./firewalls"
2
+ require_relative "./droplets"
3
+ require_relative "./config"
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OceanKit
4
+ class Config < Thor
5
+ desc "setup", "Setup OceanKit environment"
6
+ def setup
7
+ # First create the ~/.ocean_kit directory if it doesn't exist
8
+ Dir.mkdir(File.expand_path("~/.ocean_kit")) unless File.directory?(File.expand_path("~/.ocean_kit"))
9
+ # Next create the credentials.yml file if it doesn't exist
10
+ unless File.file?(File.expand_path("~/.ocean_kit/credentials.yml"))
11
+ File.write(File.expand_path("~/.ocean_kit/credentials.yml"), <<~YAML)
12
+ ---
13
+ digital_ocean_token: <YOUR_DIGITAL_OCEAN_TOKEN>
14
+
15
+ YAML
16
+ end
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?
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OceanKit
4
+ class Droplets < Thor
5
+ desc "list", "Lists all droplers."
6
+ def list
7
+ puts underline_text("Droplets:\n")
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)
12
+ puts pastel.white.bold "Name: ", pastel.clear.white(droplet.name)
13
+ puts pastel.white.bold "ID: ", pastel.clear.white(droplet.id)
14
+ puts pastel.white.bold "Public IP: ", pastel.clear.white(droplet.networks.v4.first.ip_address)
15
+ puts pastel.white.bold "Region: ", pastel.clear.white(droplet.region.slug)
16
+ puts pastel.white.bold "Status: ", pastel.clear.white(droplet.status)
17
+ puts pastel.white.bold "Created: ", pastel.clear.white(droplet.created_at)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OceanKit
4
4
  class Firewalls < Thor
5
- desc "list", "Lists all firewalls for account."
5
+ desc "list", "Lists all firewalls."
6
6
  def list
7
7
  puts pastel.white.bold.underline("Firewalls:\n")
8
8
  do_client.firewalls.all.each_with_index do |firewall, index|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OceanKit
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/ocean_kit.rb CHANGED
@@ -11,7 +11,13 @@ require_relative "./ocean_kit/helpers/base"
11
11
 
12
12
  module OceanKit
13
13
  class Client < Thor
14
- desc "firewalls SUBCOMMAND ...ARGS", "manage your DO firewall"
14
+ desc "config SUBCOMMAND ...ARGS", "Create OceanKit folder and credentials.yml file"
15
+ subcommand "config", Config
16
+
17
+ desc "droplets SUBCOMMAND ...ARGS", "manage your Digital Ocean droplets"
18
+ subcommand "droplets", Droplets
19
+
20
+ desc "firewalls SUBCOMMAND ...ARGS", "manage your Digital Ocean firewalls"
15
21
  subcommand "firewalls", Firewalls
16
22
  end
17
23
 
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.3
4
+ version: 0.1.6
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-03-27 00:00:00.000000000 Z
11
+ date: 2022-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -83,6 +83,8 @@ files:
83
83
  - lib/ocean_kit/helpers/console.rb
84
84
  - lib/ocean_kit/helpers/firewalls.rb
85
85
  - lib/ocean_kit/resources/base.rb
86
+ - lib/ocean_kit/resources/config.rb
87
+ - lib/ocean_kit/resources/droplets.rb
86
88
  - lib/ocean_kit/resources/firewalls.rb
87
89
  - lib/ocean_kit/version.rb
88
90
  - ocean_kit.gemspec