red_drop 0.3.2 → 0.4.0

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: 0d28d88532deca7906c0a221dea00ed41441a10327fe2b0f8645683fd3212051
4
- data.tar.gz: 4092ed01f7810eb0f9f44862422a55a7d6657ca8dfc2b91baf1ad5353a40d18f
3
+ metadata.gz: 39b5e008df5f5d43afd211101c2ac866a9446c310a2ebbbb153924c5071984e2
4
+ data.tar.gz: b56a8836f6013f1c85e5d791389dd007986a7f62d4dfc98473e3402312537d2f
5
5
  SHA512:
6
- metadata.gz: 6b3924b1f24754a170c46b7f09bf6fcc35e5ab079999f6f448ed7bdd6fbe23e7e94613aa7df2413a20c99ea8d17f796620018cd71db3df18fadd03d800eb9e55
7
- data.tar.gz: bf86b6c9813d0e560f5d9b89ab7dc4d66dc5d6a6fe58a1167ce2f06d90ca0532bde3f685d100567fa1fb2dadeb3ea4a7b311e77e710a0cd32f1abd0a1ca3b1aa
6
+ metadata.gz: 07fb962ef9b66d417b6c6467727946c559da5e3bca564368ca5173255afe41f4ce540277ab4a0f8f2b18a45c28d00ce8e268024e37c93f310ee6c96cb5892420
7
+ data.tar.gz: 8575bbfb5f2e53383b1b00e0c7ea3514910bc6e59d9be538c878190f0c91ae5fd30a2c0064566e1e1212a937cee5ccd144d63b57a9282be49d3693b53354e3b7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- red_drop (0.3.2)
4
+ red_drop (0.4.0)
5
5
  droplet_kit (~> 3.18)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
- # red_drop
1
+ # red_drop:drop_of_blood: [![Gem Version](https://badge.fury.io/rb/red_drop.svg)](https://badge.fury.io/rb/red_drop)
2
2
 
3
- Simple cli for automating droplet management with sane defaults baked in.
3
+ Simple "interactive" cli for automating digitalocean droplet management with sane defaults baked in for research and development.
4
+
5
+ Expirementing with the cloud can be expensive and stressful when you have to manually setup and take down Virtual Machines in order to avoid unwanted charges.
6
+
7
+ Have you ever wonderd "Hmmm... If only there was a simple way to have a linux server in the cloud so that I can fully take advantage of all those free new member credits"?
8
+
9
+ Most tools are not geared towards automating provisioning for simple research and development on cloud platforms. In fact they can be quite overwhelming with the multitude of different configurations they provide on all their cloud services.
10
+
11
+ red_drop is an easy to use tool that will take the stress out of provisioning and destroying droplets with reasonable configurations for research and development on digitalocean's cloud.
4
12
 
5
13
  ## Installation
6
14
 
@@ -14,8 +22,18 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
22
 
15
23
  ## Usage
16
24
 
25
+ After installing the gem, simply enter the following command:
26
+
17
27
  $ red_drop
18
28
 
29
+ It will then try to look for a valid authentication token. If it can't find one it will prompt you for one. You can find yours or generate one from the API tab on your digitalocean dashboard panel.
30
+
31
+ In order to use this tool you will need a digitalocean account with a payment method on your account. You can use the referral badge below to sign up with $200 of free credit for 60 days to use as your payment method.
32
+
33
+ [![DigitalOcean Referral Badge](https://web-platforms.sfo2.digitaloceanspaces.com/WWW/Badge%203.svg)](https://www.digitalocean.com/?refcode=9a321408e86f&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)
34
+
35
+ The referral badge above will also help fund research and developmet on the project.
36
+
19
37
  ## Development
20
38
 
21
39
  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.
@@ -28,13 +46,26 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/sergio
28
46
 
29
47
  ### Todos
30
48
 
31
- - Refactor: status module to match delete module droplets data structure
32
- - Refactor: delete module while loop to match that of red_drop.rb
33
49
  - Research: TDD whether its w/ minitest or rspec
34
- - Research: converting delete module droplets array to hash to avoid accidental deletions
35
- - Research: status module to get ip address of runnning droplets
36
- - Research: delete module to get droplet status before executing
37
- - Research: using cloud_init to automate server config for SSH, ufw, docker
50
+ - Research: authenticating ssh key on DigitalOcean to eventually disable password login
51
+ - Research: delete and status class to filter droplet destroy status before puts droplets
52
+ - Research: \# frozen_string_literal: true "magic comment"
53
+ - Research: File system programming in Ruby
54
+ - Research: replacing droplet_kit wrapper for vanilla Faraday http client library
55
+ - Features: cloud-init cloud-config.yaml for user_data in create class request
56
+ - Research: including created_at when puts droplets
57
+
58
+ ### Useful Links
59
+
60
+ [Ruby language reference](https://www.ruby-lang.org/en/)
61
+
62
+ [RubyGems docs](https://guides.rubygems.org/)
63
+
64
+ [Faraday: http client library](https://lostisland.github.io/faraday/)
65
+
66
+ [DigitalOcean API reference](https://docs.digitalocean.com/reference/api/)
67
+
68
+ [cloud-init reference](https://cloudinit.readthedocs.io/en/latest/topics/modules.html)
38
69
 
39
70
  ## License
40
71
 
@@ -5,8 +5,9 @@ class Create
5
5
 
6
6
  def execute
7
7
  puts "loading... \n\n"
8
+ #user_data = File.read("cloud-config.yaml")
8
9
 
9
- droplet = DropletKit::Droplet.new(name: 'drop', region: 'nyc1', size: 's-1vcpu-512mb-10gb', image: 'ubuntu-22-04-x64')
10
+ droplet = DropletKit::Droplet.new(name: 'RedDrop', region: 'nyc1', size: 's-1vcpu-512mb-10gb', image: 'ubuntu-22-04-x64')
10
11
  response = @client.droplets.create(droplet)
11
12
 
12
13
  puts "Your droplet: #{response.id}, is being provisioned.\n"
@@ -4,31 +4,33 @@ class Delete
4
4
  end
5
5
 
6
6
  def execute
7
- puts "loading... \n\n"
7
+ puts "loading... \n"
8
8
 
9
9
  droplets = @client.droplets.all.map { |droplet| droplet.to_h }
10
10
 
11
11
  if droplets.length == 0
12
- puts "There are no droplets in your DigitalOcean cloud.\n"
12
+ puts "\nThere are no droplets in your DigitalOcean cloud.\n"
13
13
  return
14
14
  end
15
15
 
16
- puts "option: droplet_id\n"
17
- droplets.each_with_index { |droplet, index| puts "#{index}: #{droplet[:id]}" }
18
- puts "\nPlease enter an option for a droplet to delete?\n\n"
19
- num = gets.to_i
16
+ hash = {}
17
+ droplets.each_with_index { |drop, i| hash[i.to_s] = drop }
18
+ droplets = hash
20
19
 
21
- while not droplets[num]
22
- puts "\n#{num} is not a valid option, please enter a valid option\n\n"
23
- num = gets.to_i
20
+ option = nil
21
+
22
+ until droplets.has_key? option
23
+ puts "\noption: droplet_id\n"
24
+ droplets.each { |key, droplet| puts "#{key}: #{droplet[:id]}" }
25
+ puts "\nPlease enter an option for a droplet to delete?\n\n"
26
+
27
+ option = gets.chomp
24
28
  end
25
29
 
26
- response = @client.droplets.delete(id: droplets[num][:id])
30
+ response = @client.droplets.delete(id: droplets[option][:id])
27
31
 
28
32
  if response
29
33
  puts "\ndelete request processed succesfully\n\n"
30
- else
31
- result
32
34
  end
33
35
  end
34
36
  end
@@ -6,16 +6,24 @@ class Status
6
6
  def execute
7
7
  puts "loading... \n\n"
8
8
 
9
- droplets = @client.droplets.all.map { |droplet| { "droplet_id" => droplet.id, "status" => droplet.status } }
10
- status = { "new" => "provisioning", "active" => "running" }
11
- droplets.each { |drop| drop["status"] = status[drop["status"]] }
9
+ droplets = @client.droplets.all.map { |droplet| droplet.to_h }
12
10
 
13
11
  if droplets.length == 0
14
12
  puts "There are no droplets in your DigitalOcean cloud."
15
13
  return
16
14
  end
17
15
 
18
- droplets.each { |droplet| puts droplet}
16
+ droplets.each do |droplet|
17
+ droplet[:networks] = droplet[:networks][:v4].find { |n| n[:type] == "public" }
18
+
19
+ if droplet[:networks]
20
+ droplet[:ip] = "running on #{droplet[:networks][:ip_address]}"
21
+ else
22
+ droplet[:ip] = "ip not yet assigned, try again in a minute"
23
+ end
24
+
25
+ puts "droplet: #{droplet[:id]} #{droplet[:ip]}"
26
+ end
19
27
  end
20
28
  end
21
29
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedDrop
4
- VERSION = "0.3.2"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red_drop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Ortiz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-09 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest-reporters