Skip to content

Commit f0eec2b

Browse files
committed
Ready to publish
1 parent c3e30ee commit f0eec2b

File tree

9 files changed

+61
-20
lines changed

9 files changed

+61
-20
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Gemfile.lock
2+
pkg/

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## 0.1.0
2+
* Birthday!

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ source 'https://rubygems.org'
22

33
gemspec
44

5-
gem 'kuby', path: '../kuby'
6-
75
group :development, :test do
6+
gem 'kuby', path: '../kuby'
87
gem 'pry-byebug'
98
gem 'rake'
109
end

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Cameron Dutro
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 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,
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 THE
21+
SOFTWARE.

Rakefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'bundler'
2+
require 'rspec/core/rake_task'
3+
require 'rubygems/package_task'
4+
5+
require 'kuby/digitalocean'
6+
7+
Bundler::GemHelper.install_tasks
8+
9+
task default: :spec
10+
11+
desc 'Run specs'
12+
RSpec::Core::RakeTask.new do |t|
13+
t.pattern = './spec/**/*_spec.rb'
14+
end

kuby-digitalocean.gemspec

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ Gem::Specification.new do |s|
66
s.version = ::Kuby::DigitalOcean::VERSION
77
s.authors = ['Cameron Dutro']
88
s.email = ['camertron@gmail.com']
9-
s.homepage = 'http://github.com/camertron/kuby-digitalocean'
9+
s.homepage = 'http://github.com/getkuby/kuby-digitalocean'
1010

1111
s.description = s.summary = 'DigitalOcean provider for Kuby.'
1212

1313
s.platform = Gem::Platform::RUBY
1414

15-
s.add_dependency 'kuby', '~> 1.0'
1615
s.add_dependency 'droplet_kit', '~> 3.5'
17-
s.add_dependency 'kube-dsl', '~> 1.0'
16+
s.add_dependency 'kube-dsl', '~> 0.1'
1817

1918
s.require_path = 'lib'
20-
s.files = Dir['{lib,spec}/**/*', 'Gemfile', 'CHANGELOG.md', 'README.md', 'Rakefile', 'kuby-digitalocean.gemspec']
19+
s.files = Dir['{lib,spec}/**/*', 'Gemfile', 'LICENSE', 'CHANGELOG.md', 'README.md', 'Rakefile', 'kuby-digitalocean.gemspec']
2120
end

lib/kuby/digitalocean.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'kuby'
21
require 'kuby/digitalocean/provider'
32

43
module Kuby

lib/kuby/digitalocean/provider.rb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
require 'colorized_string'
1+
require 'kuby'
22
require 'droplet_kit'
33
require 'fileutils'
44

55
module Kuby
66
module DigitalOcean
77
class Provider < ::Kuby::Kubernetes::Provider
8-
KUBECONFIG_EXPIRATION = 7.days
8+
KUBECONFIG_EXPIRATION = 7 * 24 * 60 * 60 # 7 days
9+
STORAGE_CLASS_NAME = 'do-block-storage'.freeze
910

1011
attr_reader :config
1112

@@ -19,10 +20,15 @@ def kubeconfig_path
1920
).to_s
2021
end
2122

22-
def after_setup
23-
if definition.kubernetes.plugins.include?(:nginx_ingress)
24-
nginx_ingress = definition.kubernetes.plugin(:nginx_ingress)
23+
def after_initialize
24+
kubernetes_cli.before_execute do
25+
FileUtils.mkdir_p(kubeconfig_dir)
26+
refresh_kubeconfig
27+
end
28+
end
2529

30+
def after_setup
31+
if nginx_ingress = definition.kubernetes.plugin(:nginx_ingress)
2632
service = ::KubeDSL::Resource.new(
2733
kubernetes_cli.get_object(
2834
'service', nginx_ingress.namespace, nginx_ingress.service_name
@@ -49,15 +55,14 @@ def after_setup
4955
end
5056
end
5157

58+
def storage_class_name
59+
STORAGE_CLASS_NAME
60+
end
61+
5262
private
5363

5464
def after_initialize
5565
@config = Config.new
56-
57-
kubernetes_cli.before_execute do
58-
FileUtils.mkdir_p(kubeconfig_dir)
59-
refresh_kubeconfig
60-
end
6166
end
6267

6368
def client
@@ -68,10 +73,10 @@ def client
6873

6974
def refresh_kubeconfig
7075
return unless should_refresh_kubeconfig?
71-
Kuby.logger.info(ColorizedString['Refreshing kubeconfig...'].yellow)
76+
Kuby.logger.info('Refreshing kubeconfig...')
7277
kubeconfig = client.kubernetes_clusters.kubeconfig(id: config.cluster_id)
7378
File.write(kubeconfig_path, kubeconfig)
74-
Kuby.logger.info(ColorizedString['Successfully refreshed kubeconfig!'].yellow)
79+
Kuby.logger.info('Successfully refreshed kubeconfig!')
7580
end
7681

7782
def should_refresh_kubeconfig?

lib/kuby/digitalocean/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Kuby
22
module DigitalOcean
3-
VERSION = '1.0.0'.freeze
3+
VERSION = '0.1.0'.freeze
44
end
55
end

0 commit comments

Comments
 (0)