dokku_client 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +0 -0
- data/Rakefile +3 -0
- data/bin/dokku +8 -0
- data/dokku_client.gemspec +23 -0
- data/lib/dokku_client.rb +12 -0
- data/lib/dokku_client/base.rb +92 -0
- data/lib/dokku_client/cli.rb +109 -0
- data/lib/dokku_client/client.rb +17 -0
- data/lib/dokku_client/core_extensions.rb +7 -0
- data/lib/dokku_client/errors.rb +11 -0
- data/lib/dokku_client/version.rb +3 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 610b5c208df2d84c7fd15b99fbefd8dd2581bec2
|
4
|
+
data.tar.gz: f1eac7007426caff8b017c3ea687fe703bf59dc8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c55277cfa55964e6d99c2e128f10217b024722e329b33fb0fcb4e9ed79ebe93c1b6d01c467a8aa1cfeb51203d6e98c40824f6ae6e4792bb3e4e18babf01ece2
|
7
|
+
data.tar.gz: 67eca77a80a09a11eaff231ab376c3298f046cf58a311aa5055572157dfb127944321b07c99a8c279971d6af25059705ed29976db2b33c419c6e13fbd7b32b12
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kuba Łasecki
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
File without changes
|
data/Rakefile
ADDED
data/bin/dokku
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dokku_client/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Kuba Łasecki"]
|
6
|
+
gem.email = ["kubalasecki@gmail.com"]
|
7
|
+
gem.description = %q{Dokku Client for rails project with preinstalled dokku plugins}
|
8
|
+
gem.summary = %q{Dokku Client}
|
9
|
+
gem.homepage = "https://github.com/kubalasecki/dokku_client"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.name = "dokku_client"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = DokkuClient::VERSION
|
16
|
+
|
17
|
+
gem.add_runtime_dependency "grit"
|
18
|
+
gem.add_runtime_dependency "highline"
|
19
|
+
gem.add_runtime_dependency "colorize"
|
20
|
+
|
21
|
+
gem.add_development_dependency "rake"
|
22
|
+
|
23
|
+
end
|
data/lib/dokku_client.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'grit'
|
3
|
+
require 'optparse'
|
4
|
+
require 'highline'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
require 'dokku_client/core_extensions'
|
8
|
+
require 'dokku_client/errors'
|
9
|
+
require 'dokku_client/version'
|
10
|
+
require 'dokku_client/base'
|
11
|
+
require 'dokku_client/cli'
|
12
|
+
require 'dokku_client/client'
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module DokkuClient
|
2
|
+
|
3
|
+
class Base
|
4
|
+
attr_reader :options
|
5
|
+
|
6
|
+
GIT_DIR = '.git'
|
7
|
+
|
8
|
+
KEYS_AND_QUESTIONS = {
|
9
|
+
"dokku-client.project-name" => "Enter project name",
|
10
|
+
"dokku-client.project-host" => "Eneter dokku host"
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
options = {}
|
15
|
+
@options = options
|
16
|
+
@current_dir = Dir.pwd
|
17
|
+
|
18
|
+
raise DokkuClient::Errors::NoGitRepoFound, "No git repository found" unless git_directory_present?
|
19
|
+
|
20
|
+
@git_dir = File.join(@current_dir, GIT_DIR)
|
21
|
+
@options[:repository] = Grit::Repo.new(@git_dir)
|
22
|
+
|
23
|
+
git_config_ok? ? parse_git_config : add_git_config
|
24
|
+
run
|
25
|
+
end
|
26
|
+
|
27
|
+
def git_directory_present?
|
28
|
+
File.directory?(File.join(@current_dir, GIT_DIR))
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
end
|
33
|
+
|
34
|
+
def reconfig
|
35
|
+
KEYS_AND_QUESTIONS.each do |key, question|
|
36
|
+
ask_question_and_force_update_config(question, key)
|
37
|
+
end
|
38
|
+
config_update_success
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def config_update_success
|
44
|
+
puts "[SUCCESS] Dokku Client configuration has been updated."
|
45
|
+
end
|
46
|
+
|
47
|
+
def git_config_ok?
|
48
|
+
!KEYS_AND_QUESTIONS.keys.any? { |key| @options[:repository].config[key].nil? }
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_git_config
|
52
|
+
KEYS_AND_QUESTIONS.each do |key, question|
|
53
|
+
ask_question_and_update_config(question, key)
|
54
|
+
end
|
55
|
+
parse_git_config
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse_git_config
|
59
|
+
KEYS_AND_QUESTIONS.each do |key, value|
|
60
|
+
new_key = key.split(".").last
|
61
|
+
@options[new_key] = @options[:repository].config[key]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def ask_question_and_update_config question, variable
|
66
|
+
@options[:repository].config[variable] ||= ask_question(question)
|
67
|
+
end
|
68
|
+
|
69
|
+
def ask_question_and_force_update_config question, variable
|
70
|
+
@options[:repository].config[variable] = ask_question(question)
|
71
|
+
end
|
72
|
+
|
73
|
+
def update_config_from_options
|
74
|
+
KEYS_AND_QUESTIONS.keys.each do |key|
|
75
|
+
@options[:repository].config[key] = @options[key.gsub(/-/, "_")]
|
76
|
+
end
|
77
|
+
config_update_success
|
78
|
+
end
|
79
|
+
|
80
|
+
def ask_question question, first_answer = nil
|
81
|
+
h = HighLine.new
|
82
|
+
h.ask("#{question}\t") do |q|
|
83
|
+
q.responses[:ask_on_error] = :question
|
84
|
+
q.responses[:not_valid] = "It can't be empty, sorry"
|
85
|
+
q.validate = ->(id) { !id.empty? }
|
86
|
+
q.first_answer = first_answer
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
module DokkuClient
|
2
|
+
class Cli
|
3
|
+
|
4
|
+
def initialize *args
|
5
|
+
@args = args
|
6
|
+
end
|
7
|
+
|
8
|
+
def go!
|
9
|
+
Signal.trap(2) {
|
10
|
+
puts "\nkkthxbye!"
|
11
|
+
return 0
|
12
|
+
}
|
13
|
+
begin
|
14
|
+
return parse_argv(@args)
|
15
|
+
rescue *DokkuClient::Errors.exceptions => e
|
16
|
+
puts "[ERROR] #{e}"
|
17
|
+
return 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# available commands
|
24
|
+
|
25
|
+
def logs
|
26
|
+
dokku_object.logs
|
27
|
+
end
|
28
|
+
|
29
|
+
def reconfig
|
30
|
+
DokkuClient::Base.new.reconfig
|
31
|
+
end
|
32
|
+
|
33
|
+
def version
|
34
|
+
puts DokkuClient::VERSION
|
35
|
+
end
|
36
|
+
|
37
|
+
# additional methods
|
38
|
+
|
39
|
+
def dokku_object
|
40
|
+
@dokku_objectu ||= DokkuClient::Client.new(@options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def no_argument_error
|
44
|
+
puts "You forgot argument - look into help"
|
45
|
+
end
|
46
|
+
|
47
|
+
def no_method_error
|
48
|
+
puts "You forgot a method name"
|
49
|
+
end
|
50
|
+
|
51
|
+
def invalid_method_error
|
52
|
+
puts "Ups, no such method..."
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_argv(args)
|
56
|
+
@options = {}
|
57
|
+
|
58
|
+
opt_parser = OptionParser.new do |opts|
|
59
|
+
opts.banner = "\nDokkuClient ver. #{DokkuClient::VERSION}\nUsage: dokku <COMMAND> [OPTIONS]\n"
|
60
|
+
opts.separator "Commands"
|
61
|
+
opts.separator " logs show app logs"
|
62
|
+
opts.separator " version show gem version"
|
63
|
+
opts.separator ""
|
64
|
+
opts.separator "Options"
|
65
|
+
|
66
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
67
|
+
puts opts
|
68
|
+
return 1
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on_tail("-v", "--version", "Show version") do
|
72
|
+
puts DokkuClient::VERSION
|
73
|
+
return 1
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.on("-n <PROJECT_NAME>", "--name <PROJECT_NAME>", "Set dokku PROJECT NAME") do |project_name|
|
77
|
+
@options["project-name"] = project_name
|
78
|
+
end
|
79
|
+
|
80
|
+
opts.on("-H <PROJECT_HOST>", "--host <PROJECT_HOST>", Numeric, "Set dokku PROJECT HOST") do |project_host|
|
81
|
+
@options["project-host"] = project_host
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
opt_parser.parse!(args)
|
87
|
+
|
88
|
+
case args[0]
|
89
|
+
when "blabla"
|
90
|
+
self.send(args[0].to_sym, args[1])
|
91
|
+
when "help"
|
92
|
+
puts opt_parser
|
93
|
+
when "logs", "reconfig"
|
94
|
+
self.send(args[0].to_sym)
|
95
|
+
when nil
|
96
|
+
no_method_error
|
97
|
+
puts opt_parser
|
98
|
+
return 1
|
99
|
+
else
|
100
|
+
invalid_method_error
|
101
|
+
return 1
|
102
|
+
end
|
103
|
+
return 0
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module DokkuClient
|
2
|
+
class Client < Base
|
3
|
+
|
4
|
+
def run
|
5
|
+
end
|
6
|
+
|
7
|
+
def logs
|
8
|
+
dokku "logs #{@options["project-name"]}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def dokku arg
|
12
|
+
no_argument_error if arg.nil?
|
13
|
+
exec "ssh", "-t", "dokku@#{@options["project-host"]}", arg
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dokku_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kuba Łasecki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: grit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Dokku Client for rails project with preinstalled dokku plugins
|
70
|
+
email:
|
71
|
+
- kubalasecki@gmail.com
|
72
|
+
executables:
|
73
|
+
- dokku
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/dokku
|
83
|
+
- dokku_client.gemspec
|
84
|
+
- lib/dokku_client.rb
|
85
|
+
- lib/dokku_client/base.rb
|
86
|
+
- lib/dokku_client/cli.rb
|
87
|
+
- lib/dokku_client/client.rb
|
88
|
+
- lib/dokku_client/core_extensions.rb
|
89
|
+
- lib/dokku_client/errors.rb
|
90
|
+
- lib/dokku_client/version.rb
|
91
|
+
homepage: https://github.com/kubalasecki/dokku_client
|
92
|
+
licenses: []
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.2.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Dokku Client
|
114
|
+
test_files: []
|