dtk-client 0.5.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +5 -0
- data/Gemfile_dev +12 -0
- data/README.md +78 -0
- data/bin/dtk +54 -0
- data/bin/dtk-shell +15 -0
- data/dtk-client.gemspec +49 -0
- data/lib/auxiliary.rb +13 -0
- data/lib/bundler_monkey_patch.rb +9 -0
- data/lib/client.rb +48 -0
- data/lib/command_helper.rb +16 -0
- data/lib/command_helpers/git_repo.rb +391 -0
- data/lib/command_helpers/jenkins_client/config_xml.rb +271 -0
- data/lib/command_helpers/jenkins_client.rb +91 -0
- data/lib/command_helpers/service_importer.rb +99 -0
- data/lib/command_helpers/service_link.rb +18 -0
- data/lib/command_helpers/ssh_processing.rb +43 -0
- data/lib/commands/common/thor/assembly_workspace.rb +1089 -0
- data/lib/commands/common/thor/clone.rb +39 -0
- data/lib/commands/common/thor/common.rb +34 -0
- data/lib/commands/common/thor/edit.rb +168 -0
- data/lib/commands/common/thor/list_diffs.rb +84 -0
- data/lib/commands/common/thor/pull_clone_changes.rb +11 -0
- data/lib/commands/common/thor/pull_from_remote.rb +99 -0
- data/lib/commands/common/thor/purge_clone.rb +26 -0
- data/lib/commands/common/thor/push_clone_changes.rb +45 -0
- data/lib/commands/common/thor/push_to_remote.rb +45 -0
- data/lib/commands/common/thor/reparse.rb +36 -0
- data/lib/commands/common/thor/set_required_params.rb +29 -0
- data/lib/commands/common/thor/task_status.rb +81 -0
- data/lib/commands/thor/account.rb +213 -0
- data/lib/commands/thor/assembly.rb +329 -0
- data/lib/commands/thor/attribute.rb +62 -0
- data/lib/commands/thor/component.rb +52 -0
- data/lib/commands/thor/component_module.rb +829 -0
- data/lib/commands/thor/component_template.rb +153 -0
- data/lib/commands/thor/dependency.rb +18 -0
- data/lib/commands/thor/developer.rb +105 -0
- data/lib/commands/thor/dtk.rb +117 -0
- data/lib/commands/thor/library.rb +107 -0
- data/lib/commands/thor/node.rb +411 -0
- data/lib/commands/thor/node_group.rb +211 -0
- data/lib/commands/thor/node_template.rb +88 -0
- data/lib/commands/thor/project.rb +17 -0
- data/lib/commands/thor/provider.rb +155 -0
- data/lib/commands/thor/repo.rb +35 -0
- data/lib/commands/thor/service.rb +656 -0
- data/lib/commands/thor/service_module.rb +806 -0
- data/lib/commands/thor/state_change.rb +10 -0
- data/lib/commands/thor/target.rb +94 -0
- data/lib/commands/thor/task.rb +100 -0
- data/lib/commands/thor/utils.rb +4 -0
- data/lib/commands/thor/workspace.rb +437 -0
- data/lib/commands.rb +40 -0
- data/lib/config/cacert.pem +3785 -0
- data/lib/config/client.conf.header +18 -0
- data/lib/config/configuration.rb +82 -0
- data/lib/config/default.conf +14 -0
- data/lib/config/disk_cacher.rb +60 -0
- data/lib/configurator.rb +92 -0
- data/lib/context_router.rb +23 -0
- data/lib/core.rb +460 -0
- data/lib/domain/git_adapter.rb +221 -0
- data/lib/domain/response.rb +234 -0
- data/lib/dtk-client/version.rb +3 -0
- data/lib/dtk_constants.rb +23 -0
- data/lib/dtk_logger.rb +96 -0
- data/lib/error.rb +74 -0
- data/lib/git-logs/git.log +0 -0
- data/lib/parser/adapters/option_parser.rb +53 -0
- data/lib/parser/adapters/thor/common_option_defs.rb +12 -0
- data/lib/parser/adapters/thor.rb +509 -0
- data/lib/require_first.rb +87 -0
- data/lib/search_hash.rb +27 -0
- data/lib/shell/context.rb +975 -0
- data/lib/shell/context_aux.rb +29 -0
- data/lib/shell/domain.rb +447 -0
- data/lib/shell/header_shell.rb +27 -0
- data/lib/shell/help_monkey_patch.rb +221 -0
- data/lib/shell/interactive_wizard.rb +233 -0
- data/lib/shell/parse_monkey_patch.rb +22 -0
- data/lib/shell/status_monitor.rb +105 -0
- data/lib/shell.rb +219 -0
- data/lib/util/console.rb +143 -0
- data/lib/util/dtk_puppet.rb +46 -0
- data/lib/util/os_util.rb +265 -0
- data/lib/view_processor/augmented_simple_list.rb +27 -0
- data/lib/view_processor/hash_pretty_print.rb +106 -0
- data/lib/view_processor/simple_list.rb +139 -0
- data/lib/view_processor/table_print.rb +277 -0
- data/lib/view_processor.rb +112 -0
- data/puppet/manifests/init.pp +72 -0
- data/puppet/manifests/params.pp +16 -0
- data/puppet/r8meta.puppet.yml +18 -0
- data/puppet/templates/bash_profile.erb +2 -0
- data/puppet/templates/client.conf.erb +1 -0
- data/puppet/templates/dtkclient.erb +2 -0
- data/spec/assembly_spec.rb +50 -0
- data/spec/assembly_template_spec.rb +51 -0
- data/spec/component_template_spec.rb +40 -0
- data/spec/dependency_spec.rb +6 -0
- data/spec/dtk_shell_spec.rb +13 -0
- data/spec/dtk_spec.rb +33 -0
- data/spec/lib/spec_helper.rb +10 -0
- data/spec/lib/spec_thor.rb +105 -0
- data/spec/module_spec.rb +35 -0
- data/spec/node_spec.rb +43 -0
- data/spec/node_template_spec.rb +25 -0
- data/spec/project_spec.rb +6 -0
- data/spec/repo_spec.rb +7 -0
- data/spec/response_spec.rb +52 -0
- data/spec/service_spec.rb +41 -0
- data/spec/state_change_spec.rb +7 -0
- data/spec/table_print_spec.rb +48 -0
- data/spec/target_spec.rb +57 -0
- data/spec/task_spec.rb +28 -0
- data/views/assembly/augmented_simple_list.rb +12 -0
- data/views/assembly_template/augmented_simple_list.rb +12 -0
- data/views/list_task/augmented_simple_list.rb +12 -0
- metadata +351 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NmMzODFiMDI1NjJjZTJlNGEwM2U1Yzc1MTgyNDRkMjZkMWU5NjZkZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MmNmNmQxMDlmNTIxMTYxZjZmM2Y1NjU5ZjI5MTNjZWZiY2I1MjA5ZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Nzg5NWQ5NTkxOWNlYTdhNmJiNmU4MzYxMDBlMjM4MmE2MTYxYTdlZmZhNjQy
|
10
|
+
M2EwZGJjZmM1M2U0ZjdkYWU2N2Q3NjhlZGFjNTRiZGU4ZmE3NDRjMmMxODQ1
|
11
|
+
ZDM3NTU1OThkZmM4YmExNWJjN2Y3NWM4YzBiOWVmYTYzMDEyYzI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjI0M2MzMmRiY2ZiNzI0ZjMxOGVmZGUxZjE3NWUyNzlkYzIwMTE0MWI2NGFi
|
14
|
+
OTZlMzIyNWE0NmY1ODQyODIyZTFkN2Y4YjQ0MzljNjAyZjU3MjRiNjYzYzgx
|
15
|
+
YjdhN2Y5Nzg2NGI2NDllMjU0MTc1OGRiMGVhOTkxNDEwNzY4NjE=
|
data/Gemfile
ADDED
data/Gemfile_dev
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
# dependcies are defined in gemspec file since to avoid duplication
|
4
|
+
# gemspec :name => 'dtk-client'
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
# development gems which are not included in production Gemfile
|
8
|
+
gem 'rspec','~> 2.12.0'
|
9
|
+
gem 'awesome_print','~> 1.1.0'
|
10
|
+
|
11
|
+
gem 'ruby-debug','0.10.4' if RUBY_VERSION == '1.8.7'
|
12
|
+
gem 'debugger','>= 1.6.5' if RUBY_VERSION == '1.9.3'
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
DTK Client installation
|
2
|
+
==============================
|
3
|
+
|
4
|
+
To install DTK Client, follow these steps
|
5
|
+
|
6
|
+
- Ruby installation is required (verions 1.8.7 and newer are supported)
|
7
|
+
- Git is required for all features to work ([install instructions](http://git-scm.com/book/en/Getting-Started-Installing-Git))
|
8
|
+
- Install the dtk-client gem:
|
9
|
+
`gem install dtk-client`
|
10
|
+
|
11
|
+
- Type <tt>dtk</tt> or <tt>dtk-shell</tt> to start using the client
|
12
|
+
On the first run, Client will present you with a wizard to enter your server and authentication info.
|
13
|
+
|
14
|
+
DEVELOPMENT SETUP - DTK Client
|
15
|
+
==============================
|
16
|
+
|
17
|
+
Pre-requisites
|
18
|
+
----------------------
|
19
|
+
|
20
|
+
- Make sure you are using Ruby 1.8.7 , use following command to check ruby version <tt>ruby -v</tt>
|
21
|
+
|
22
|
+
Git setup
|
23
|
+
----------------------
|
24
|
+
|
25
|
+
- Make sure that you have clone dtk-common in same folder, use:
|
26
|
+
|
27
|
+
```
|
28
|
+
git clone git@github.com:rich-reactor8/dtk-common.git dtk-common
|
29
|
+
```
|
30
|
+
|
31
|
+
Make sure that in same folder you have cloned dtk-common project. Also that project is under the same name.
|
32
|
+
|
33
|
+
Gem Setup
|
34
|
+
----------------------
|
35
|
+
|
36
|
+
- Make sure that you have bundler gem, check with <tt>gem list bundler</tt>
|
37
|
+
- If you don't have it install bundler gem <tt>gem install bundler</tt>
|
38
|
+
- Run bundle from dtk-client folder <tt>bundle install</tt>
|
39
|
+
|
40
|
+
Path Setup
|
41
|
+
----------------------
|
42
|
+
|
43
|
+
- Add dtk-client to PATH e.g.
|
44
|
+
|
45
|
+
```
|
46
|
+
export PATH=$PATH:/home/user/dtk-client/bin
|
47
|
+
```
|
48
|
+
|
49
|
+
Development configuration setup
|
50
|
+
----------------------
|
51
|
+
|
52
|
+
- Copy `default.conf` from `lib/config`
|
53
|
+
- Rename copied file to `local.conf` and place it in `lib/config`
|
54
|
+
- Set configuration at will, local configuration is git ignored
|
55
|
+
|
56
|
+
NOTE: There is client configuration which can be found in `~/dtk/client.conf`. Local configuration takes presedence over any other configuration.
|
57
|
+
|
58
|
+
Configuration Setup
|
59
|
+
----------------------
|
60
|
+
|
61
|
+
- Create file <tt>~dtkconfig</tt> in you dtk dir (~/dtk) e.g. home/foo-user/dtk/connection.conf
|
62
|
+
there you will define user credentials e.g.
|
63
|
+
|
64
|
+
```
|
65
|
+
username=abh
|
66
|
+
password=r8server
|
67
|
+
server_host=ec2-54-247-191-95.eu-west-1.compute.amazonaws.com
|
68
|
+
secure_connection=true
|
69
|
+
```
|
70
|
+
Run Tests
|
71
|
+
----------------------
|
72
|
+
|
73
|
+
- From dtk-client project root run <tt>rspec</tt>, this will run all unit tests
|
74
|
+
|
75
|
+
|
76
|
+
License
|
77
|
+
----------------------
|
78
|
+
DTK Client is released under the GPLv3 license. Please see LICENSE for more details.
|
data/bin/dtk
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# GLOBAL IDENTIFIER
|
4
|
+
$shell_mode = false
|
5
|
+
|
6
|
+
require File.expand_path('../lib/client', File.dirname(__FILE__))
|
7
|
+
require File.expand_path('../lib/configurator', File.dirname(__FILE__))
|
8
|
+
require File.expand_path('../lib/parser/adapters/thor', File.dirname(__FILE__))
|
9
|
+
require File.expand_path('../lib/shell/context', File.dirname(__FILE__))
|
10
|
+
require File.expand_path('../lib/shell/domain', File.dirname(__FILE__))
|
11
|
+
require File.expand_path('../lib/commands/thor/account', File.dirname(__FILE__))
|
12
|
+
require File.expand_path('../lib/command_helpers/ssh_processing', File.dirname(__FILE__))
|
13
|
+
require File.expand_path('../lib/shell/parse_monkey_patch', File.dirname(__FILE__))
|
14
|
+
require File.expand_path('../lib/shell/help_monkey_patch', File.dirname(__FILE__))
|
15
|
+
|
16
|
+
|
17
|
+
require 'shellwords'
|
18
|
+
|
19
|
+
$: << "/usr/lib/ruby/1.8/" #TODO: put in to get around path problem in rvm 1.9.2 environment
|
20
|
+
|
21
|
+
::DTK::Client::Configurator.check_config_exists
|
22
|
+
::DTK::Client::Configurator.check_git
|
23
|
+
::DTK::Client::Configurator.create_missing_clone_dirs
|
24
|
+
|
25
|
+
|
26
|
+
# check if .add_direct_access file exists, if not then add direct access and create .add_direct_access file
|
27
|
+
check_direct_access(::DTK::Client::Configurator.check_direct_access)
|
28
|
+
entries = []
|
29
|
+
|
30
|
+
if ARGV.size > 0
|
31
|
+
entries = ARGV
|
32
|
+
entries = DTK::Shell::Context.check_for_sym_link(entries)
|
33
|
+
entity_name = entries.shift
|
34
|
+
end
|
35
|
+
|
36
|
+
# special case for when no params are provided use help method
|
37
|
+
if (entity_name == 'help' || entity_name.nil?)
|
38
|
+
entity_name = 'dtk'
|
39
|
+
args = ['help']
|
40
|
+
else
|
41
|
+
args = entries
|
42
|
+
end
|
43
|
+
|
44
|
+
context = DTK::Shell::Context.new(true)
|
45
|
+
|
46
|
+
begin
|
47
|
+
entity_name, method_name, context_params, thor_options = context.get_dtk_command_parameters(entity_name, args)
|
48
|
+
|
49
|
+
top_level_execute(entity_name, method_name, context_params, thor_options, false)
|
50
|
+
rescue DTK::Client::DtkError => e
|
51
|
+
DtkLogger.instance.error(e.message, true)
|
52
|
+
rescue Exception => e
|
53
|
+
DtkLogger.instance.error_pp(e.message, e.backtrace)
|
54
|
+
end
|
data/bin/dtk-shell
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.expand_path('../lib/shell', File.dirname(__FILE__))
|
3
|
+
require File.expand_path('../lib/commands/thor/account', File.dirname(__FILE__))
|
4
|
+
require File.expand_path('../lib/command_helpers/ssh_processing', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
trap("INT", "SIG_IGN")
|
7
|
+
|
8
|
+
::DTK::Client::Configurator.check_config_exists
|
9
|
+
::DTK::Client::Configurator.check_git
|
10
|
+
::DTK::Client::Configurator.create_missing_clone_dirs
|
11
|
+
|
12
|
+
# check if .add_direct_access file exists, if not then add direct access and create .add_direct_access file
|
13
|
+
check_direct_access(::DTK::Client::Configurator.check_direct_access)
|
14
|
+
|
15
|
+
run_shell_command()
|
data/dtk-client.gemspec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dtk-client/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Rich PELAVIN"]
|
6
|
+
gem.email = ["rich@reactor8.com"]
|
7
|
+
gem.description = %q{Dtk client is CLI tool used for communication with Reactor8.}
|
8
|
+
gem.summary = %q{DTK CLI client for DTK server interaction.}
|
9
|
+
gem.homepage = "https://github.com/rich-reactor8/dtk-client"
|
10
|
+
gem.licenses = ["GPL-3.0"]
|
11
|
+
|
12
|
+
gem.files = %w(README.md Gemfile Gemfile_dev dtk-client.gemspec)
|
13
|
+
gem.files += Dir.glob("bin/**/*")
|
14
|
+
gem.files += Dir.glob("lib/**/*")
|
15
|
+
gem.files += Dir.glob("puppet/**/*")
|
16
|
+
gem.files += Dir.glob("spec/**/*")
|
17
|
+
gem.files += Dir.glob("views/**/*")
|
18
|
+
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.name = "dtk-client"
|
22
|
+
gem.require_paths = ["lib"]
|
23
|
+
gem.version = "#{DtkClient::VERSION}.#{ARGV[3]}".chomp(".")
|
24
|
+
|
25
|
+
gem.add_dependency 'bundler','>= 1.2.4'
|
26
|
+
gem.add_dependency 'json_pure' ,'1.7.4'
|
27
|
+
gem.add_dependency 'diff-lcs','1.1.3'
|
28
|
+
gem.add_dependency 'mime-types','~> 1.25'
|
29
|
+
gem.add_dependency 'hirb','~> 0.7.0'
|
30
|
+
gem.add_dependency 'thor','~> 0.15.4'
|
31
|
+
gem.add_dependency 'erubis','~> 2.7.0'
|
32
|
+
gem.add_dependency 'dtk-common-core','~> 0.5.4'
|
33
|
+
gem.add_dependency 'git','~> 1.2.6'
|
34
|
+
gem.add_dependency 'colorize','~> 0.5.8'
|
35
|
+
gem.add_dependency 'highline', '1.6.16'
|
36
|
+
gem.add_dependency 'awesome_print', '1.1.0'
|
37
|
+
|
38
|
+
# gem.add_dependency 'rb-readline', '0.5.0'
|
39
|
+
# gem.add_dependency 'activesupport','~> 3.2.12'
|
40
|
+
# gem.add_dependency 'i18n','0.6.1'
|
41
|
+
# gem.add_dependency 'puppet','~> 3.1.0'
|
42
|
+
# gem.add_dependency 'jenkins-client','~> 0.0.1'
|
43
|
+
# gem.add_dependency 'rspec','~> 2.12.0'
|
44
|
+
# gem.add_dependency 'awesome_print','~> 1.1.0'
|
45
|
+
# gem.add_dependency 'rdoc','= 3.12.1'l
|
46
|
+
# gem.add_development_dependency 'ruby-debug','>= 0.10.4'
|
47
|
+
# gem.add_development_dependency 'awesome_print','>= 1.1.0'
|
48
|
+
# gem.add_development_dependency 'rspec','~> 2.12.0'
|
49
|
+
end
|
data/lib/auxiliary.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module DTK
|
2
|
+
module Client
|
3
|
+
module Auxiliary
|
4
|
+
def cap_form(x)
|
5
|
+
x.gsub('-','_').to_s.split("_").map{|t|t.capitalize}.join("")
|
6
|
+
end
|
7
|
+
|
8
|
+
def snake_form(command_class,seperator="_")
|
9
|
+
command_class.to_s.gsub(/^.*::/, '').gsub(/Command$/,'').scan(/[A-Z][a-z]+/).map{|w|w.downcase}.join(seperator)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/client.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require File.expand_path("require_first", File.dirname(__FILE__))
|
5
|
+
|
6
|
+
if gem_only_available?
|
7
|
+
# loads it only if there is no common folder, and gem is installed
|
8
|
+
require 'dtk_common_core'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Load DTK Common
|
12
|
+
dtk_require_dtk_common_core("dtk_common_core")
|
13
|
+
|
14
|
+
# Monkey Patching bundler to support loading specific Gemfile from dtk-client project's root - Ticket: DTK-585
|
15
|
+
dtk_require("config/configuration")
|
16
|
+
|
17
|
+
|
18
|
+
if DTK::Configuration.get(:debug_grit)
|
19
|
+
# INSERT NEW CODE HERE
|
20
|
+
end
|
21
|
+
|
22
|
+
# we don't need Bundler.setup but will leave it commented just in case
|
23
|
+
# TODO: This is temp solution which will not use bundler.setup when in dev mode
|
24
|
+
# thus allowing us to use system gems and not just the ones specified in Gemfile
|
25
|
+
unless DTK::Configuration.get(:development_mode)
|
26
|
+
require 'bundler'
|
27
|
+
#TODO: rich temp hack becaus eof problem with gem dependencies; changed this because it was not working in 0.19.0
|
28
|
+
if Bundler.respond_to?(:start)
|
29
|
+
Bundler.start
|
30
|
+
end
|
31
|
+
dtk_require("bundler_monkey_patch")
|
32
|
+
end
|
33
|
+
|
34
|
+
########
|
35
|
+
dtk_require("auxiliary")
|
36
|
+
dtk_require("core")
|
37
|
+
dtk_require("error")
|
38
|
+
dtk_require("dtk_constants")
|
39
|
+
dtk_require("commands")
|
40
|
+
dtk_require("view_processor")
|
41
|
+
dtk_require("search_hash")
|
42
|
+
dtk_require("dtk_logger")
|
43
|
+
rescue SystemExit, Interrupt
|
44
|
+
#puts "DTK Client action canceled."
|
45
|
+
exit(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DTK; module Client
|
2
|
+
module CommandHelperMixin
|
3
|
+
def Helper(helper_class_name)
|
4
|
+
unless Loaded[helper_class_name]
|
5
|
+
dtk_nested_require('command_helpers',helper_class_name)
|
6
|
+
Loaded[helper_class_name] = true
|
7
|
+
end
|
8
|
+
CommandHelper.const_get Common::Aux.snake_to_camel_case(helper_class_name.to_s)
|
9
|
+
end
|
10
|
+
Loaded = Hash.new
|
11
|
+
end
|
12
|
+
|
13
|
+
#TODO: make all commands helpers a subclass of this
|
14
|
+
class CommandHelper
|
15
|
+
end
|
16
|
+
end; end
|