dtk-client 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/command_helpers/git_repo.rb +66 -5
- data/lib/commands/common/thor/assembly_workspace.rb +23 -7
- data/lib/commands/common/thor/clone.rb +4 -2
- data/lib/commands/common/thor/edit.rb +16 -15
- data/lib/commands/common/thor/list_diffs.rb +38 -12
- data/lib/commands/common/thor/module/import.rb +249 -0
- data/lib/commands/common/thor/module.rb +198 -60
- data/lib/commands/common/thor/pull_from_remote.rb +1 -1
- data/lib/commands/common/thor/puppet_forge.rb +51 -0
- data/lib/commands/common/thor/push_clone_changes.rb +52 -14
- data/lib/commands/common/thor/reparse.rb +4 -18
- data/lib/commands/common/thor/task_status.rb +8 -4
- data/lib/commands/thor/component_module.rb +12 -17
- data/lib/commands/thor/service.rb +5 -0
- data/lib/commands/thor/service_module.rb +7 -1
- data/lib/commands/thor/test_module.rb +3 -2
- data/lib/config/client.conf.header +1 -0
- data/lib/config/default.conf +1 -0
- data/lib/configurator.rb +1 -0
- data/lib/domain/git_adapter.rb +30 -13
- data/lib/dtk-client/version.rb +1 -1
- data/lib/util/module_util.rb +4 -0
- data/lib/util/os_util.rb +6 -0
- metadata +4 -2
@@ -108,28 +108,20 @@ module DTK::Client
|
|
108
108
|
def import(context_params)
|
109
109
|
response = import_module_aux(context_params)
|
110
110
|
@@invalidate_map << :component_module
|
111
|
-
|
112
111
|
response
|
113
112
|
end
|
114
113
|
|
115
|
-
|
116
|
-
desc "import-puppet-forge PUPPET-MODULE-NAME [NAMESPACE:]COMPONENT-MODULE-NAME", "Install puppet module from puppet forge"
|
114
|
+
desc "import-puppet-forge PUPPET-MODULE-NAME [[NAMESPACE:]COMPONENT-MODULE-NAME]", "Install puppet module from puppet forge"
|
117
115
|
def import_puppet_forge(context_params)
|
118
|
-
pf_module_name, full_module_name = context_params.retrieve_arguments([:option_1!, :option_2
|
116
|
+
pf_module_name, full_module_name = context_params.retrieve_arguments([:option_1!, :option_2],method_argument_names)
|
119
117
|
namespace, module_name = get_namespace_and_name(full_module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
118
|
+
module_type = get_module_type(context_params)
|
120
119
|
|
121
|
-
response =
|
122
|
-
:puppetf_module_name => pf_module_name,
|
123
|
-
:module_name => module_name,
|
124
|
-
:module_namespace => namespace
|
125
|
-
}
|
126
|
-
|
127
|
-
return response unless response.ok?
|
120
|
+
response = puppet_forge_install_aux(context_params, pf_module_name, module_name, namespace, nil, module_type)
|
128
121
|
|
129
122
|
@@invalidate_map << :component_module
|
130
123
|
response
|
131
124
|
end
|
132
|
-
=end
|
133
125
|
|
134
126
|
#
|
135
127
|
# Creates component module from input git repo, removing .git dir to rid of pointing to user github, and creates component module
|
@@ -137,7 +129,9 @@ module DTK::Client
|
|
137
129
|
method_option :branch, :aliases => '-b'
|
138
130
|
desc "import-git GIT-SSH-REPO-URL [-b BRANCH/TAG] [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new local component module by importing from provided git repo URL"
|
139
131
|
def import_git(context_params)
|
140
|
-
import_git_module_aux(context_params)
|
132
|
+
response = import_git_module_aux(context_params)
|
133
|
+
@@invalidate_map << :component_module
|
134
|
+
response
|
141
135
|
end
|
142
136
|
|
143
137
|
=begin
|
@@ -180,7 +174,7 @@ module DTK::Client
|
|
180
174
|
|
181
175
|
|
182
176
|
=begin
|
183
|
-
=> DUE TO DEPENDENCY TO PUPPET GEM WE
|
177
|
+
=> DUE TO DEPENDENCY TO PUPPET GEM WE OMIT THIS <=
|
184
178
|
desc "import-puppet-forge PUPPET-FORGE-MODULE-NAME", "Imports puppet module from puppet forge via puppet gem"
|
185
179
|
def import_puppet_forge(context_params)
|
186
180
|
module_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
@@ -211,7 +205,7 @@ module DTK::Client
|
|
211
205
|
return response unless response.ok?
|
212
206
|
module_name,repo_url,branch,version = response.data(:module_name,:repo_url,:workspace_branch,:version)
|
213
207
|
|
214
|
-
if error = response.data(:
|
208
|
+
if error = response.data(:dsl_parse_error)
|
215
209
|
dsl_parsed_message = ServiceImporter.error_message(module_name, error)
|
216
210
|
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
217
211
|
end
|
@@ -414,10 +408,11 @@ module DTK::Client
|
|
414
408
|
|
415
409
|
# desc "COMPONENT-MODULE-NAME/ID list-diffs [-v VERSION] [--remote]", "List diffs"
|
416
410
|
# version_method_option
|
417
|
-
desc "COMPONENT-MODULE-NAME/ID list-diffs
|
411
|
+
desc "COMPONENT-MODULE-NAME/ID list-diffs", "List diffs between module on server and remote repo"
|
418
412
|
method_option :remote, :type => :boolean, :default => false
|
419
413
|
def list_diffs(context_params)
|
420
|
-
|
414
|
+
list_remote_module_diffs(context_params)
|
415
|
+
# list_diffs_module_aux(context_params)
|
421
416
|
end
|
422
417
|
|
423
418
|
#
|
@@ -434,6 +434,11 @@ TODO: will put in dot release and will rename to 'extend'
|
|
434
434
|
return response
|
435
435
|
end
|
436
436
|
|
437
|
+
desc "SERVICE-NAME/ID list-diffs COMPONENT-MODULE-NAME", "List diffs between module in service instance and base module."
|
438
|
+
def list_diffs(context_params)
|
439
|
+
list_remote_module_diffs(context_params)
|
440
|
+
end
|
441
|
+
|
437
442
|
# desc "ASSEMBLY-NAME/ID list-attribute-mappings SERVICE-LINK-NAME/ID", "List attribute mappings associated with service link"
|
438
443
|
# def list_attribute_mappings(context_params)
|
439
444
|
# post_body = Helper(:service_link).post_body_with_id_keys(context_params,method_argument_names)
|
@@ -214,7 +214,7 @@ module DTK::Client
|
|
214
214
|
# return response unless response.ok?
|
215
215
|
# module_name,repo_url,branch,version = response.data(:module_name,:repo_url,:workspace_branch,:version)
|
216
216
|
|
217
|
-
# if error = response.data(:
|
217
|
+
# if error = response.data(:dsl_parse_error)
|
218
218
|
# dsl_parsed_message = ServiceImporter.error_message("#{module_name}-#{version}", error)
|
219
219
|
# DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
220
220
|
# end
|
@@ -533,6 +533,12 @@ module DTK::Client
|
|
533
533
|
push_dtkn_module_aux(context_params, internal_trigger)
|
534
534
|
end
|
535
535
|
|
536
|
+
desc "SERVICE-MODULE-NAME/ID list-diffs", "List diffs between module on server and remote repo"
|
537
|
+
method_option :remote, :type => :boolean, :default => false
|
538
|
+
def list_diffs(context_params)
|
539
|
+
list_remote_module_diffs(context_params)
|
540
|
+
# list_diffs_module_aux(context_params)
|
541
|
+
end
|
536
542
|
|
537
543
|
# desc "delete SERVICE-MODULE-NAME [-v VERSION] [-y] [-p]", "Delete service module or service module version and all items contained in it. Optional parameter [-p] is to delete local directory."
|
538
544
|
# version_method_option
|
@@ -218,10 +218,11 @@ module DTK::Client
|
|
218
218
|
end
|
219
219
|
PushCatalogs = ["origin", "dtkn"]
|
220
220
|
|
221
|
-
desc "TEST-MODULE-NAME/ID list-diffs
|
221
|
+
desc "TEST-MODULE-NAME/ID list-diffs", "List diffs between module on server and remote repo"
|
222
222
|
method_option :remote, :type => :boolean, :default => false
|
223
223
|
def list_diffs(context_params)
|
224
|
-
|
224
|
+
list_remote_module_diffs(context_params)
|
225
|
+
# list_diffs_module_aux(context_params)
|
225
226
|
end
|
226
227
|
|
227
228
|
|
data/lib/config/default.conf
CHANGED
data/lib/configurator.rb
CHANGED
@@ -83,6 +83,7 @@ module DTK
|
|
83
83
|
FileUtils.mkdir(OsUtil.component_clone_location) unless File.directory?(OsUtil.component_clone_location)
|
84
84
|
FileUtils.mkdir(OsUtil.service_clone_location) unless File.directory?(OsUtil.service_clone_location)
|
85
85
|
FileUtils.mkdir(OsUtil.test_clone_location) unless File.directory?(OsUtil.test_clone_location)
|
86
|
+
FileUtils.mkdir(OsUtil.backups_location) unless File.directory?(OsUtil.backups_location)
|
86
87
|
end
|
87
88
|
|
88
89
|
|
data/lib/domain/git_adapter.rb
CHANGED
@@ -7,7 +7,9 @@ module DTK
|
|
7
7
|
|
8
8
|
def initialize(repo_dir, local_branch_name = nil)
|
9
9
|
@git_repo = Git.init(repo_dir)
|
10
|
-
|
10
|
+
# If we want to log GIT interaction
|
11
|
+
# @git_repo = Git.init(repo_dir, :log => Logger.new(STDOUT))
|
12
|
+
@local_branch_name = local_branch_name
|
11
13
|
end
|
12
14
|
|
13
15
|
def changed?
|
@@ -25,7 +27,7 @@ module DTK
|
|
25
27
|
@git_repo.remove(file)
|
26
28
|
rescue
|
27
29
|
# ignore this error means file has already been staged
|
28
|
-
# we cannot support status of file, in 1.8.7 so this is
|
30
|
+
# we cannot support status of file, in 1.8.7 so this is
|
29
31
|
# solution for that
|
30
32
|
end
|
31
33
|
end
|
@@ -59,6 +61,21 @@ module DTK
|
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
64
|
+
def diff_remote_summary(local_branch, remote_reference)
|
65
|
+
branch_local_obj = @git_repo.branches.local.find { |b| b.name == local_branch }
|
66
|
+
branch_remote_obj = @git_repo.branches.remote.find{|r| "#{r.remote}/#{r.name}" == remote_reference }
|
67
|
+
|
68
|
+
if branch_local_obj && branch_remote_obj
|
69
|
+
difference = @git_repo.lib.diff_full(branch_remote_obj, branch_local_obj)
|
70
|
+
# difference = @git_repo.diff(branch_remote_obj, branch_local_obj)
|
71
|
+
{
|
72
|
+
:diffs => difference
|
73
|
+
}
|
74
|
+
else
|
75
|
+
raise Error.new("Error finding branches: local branch '#{local_branch}' (found: #{!branch_local_obj.nil?}), remote branch '#{remote_reference}' (found: #{!branch_remote_obj.nil?})")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
62
79
|
def local_summary()
|
63
80
|
{
|
64
81
|
:files_added => (untracked() + added()).collect { |file| { :path => file }},
|
@@ -117,24 +134,24 @@ module DTK
|
|
117
134
|
ref_remote, ref_branch = ref.split('/')
|
118
135
|
# fetch remote branch
|
119
136
|
fetch(ref_remote) if opts[:fetch_if_needed]
|
120
|
-
|
137
|
+
|
121
138
|
|
122
139
|
git_reference = case type
|
123
140
|
when :remote_branch
|
124
|
-
@git_repo.branches.remote.find { |r| "#{r.remote}/#{r.name}" == ref }
|
141
|
+
@git_repo.branches.remote.find { |r| "#{r.remote}/#{r.name}" == ref }
|
125
142
|
when :local_branch
|
126
143
|
# DEBUG SNIPPET >>>> REMOVE <<<<
|
127
144
|
# TODO: HARIS LOOK INTO THIS
|
128
145
|
# raise "Invalid ref #{ref}"
|
129
146
|
@git_repo.branches.find { |b| b.name == ref }
|
130
|
-
else
|
131
|
-
raise Error.new("Illegal type parameter (#{type}) passed to merge_relationship")
|
147
|
+
else
|
148
|
+
raise Error.new("Illegal type parameter (#{type}) passed to merge_relationship")
|
132
149
|
end
|
133
150
|
|
134
151
|
local_sha = ret_local_branch.gcommit.sha
|
135
152
|
|
136
153
|
opts[:ret_commit_shas][:local_sha] = local_sha if opts[:ret_commit_shas]
|
137
|
-
|
154
|
+
|
138
155
|
unless git_reference
|
139
156
|
return :no_remote_ref if type.eql?(:remote_branch)
|
140
157
|
|
@@ -162,7 +179,7 @@ module DTK
|
|
162
179
|
remote, remote_branch = remote_branch_ref.split('/')
|
163
180
|
push_with_remote(remote, remote_branch)
|
164
181
|
end
|
165
|
-
|
182
|
+
|
166
183
|
def push_with_remote(remote, remote_branch)
|
167
184
|
branch_for_push = "#{local_branch_name}:refs/heads/#{remote_branch||local_branch_name}"
|
168
185
|
@git_repo.push(remote, branch_for_push)
|
@@ -197,16 +214,16 @@ module DTK
|
|
197
214
|
unless branch.nil?
|
198
215
|
if opts[:track_remote_branch]
|
199
216
|
# This just tracks remote branch
|
200
|
-
begin
|
217
|
+
begin
|
201
218
|
git_base.checkout(branch)
|
202
219
|
rescue => e
|
203
220
|
# TODO: see if any other kind of error
|
204
221
|
raise DtkError.new("The branch or tag '#{branch}' does not exist on repo '#{repo_url}'")
|
205
222
|
end
|
206
223
|
else
|
207
|
-
# This wil first create a remote branch;
|
224
|
+
# This wil first create a remote branch;
|
208
225
|
# TODO: this might be wrong and should be deprecated
|
209
|
-
git_base.branch(branch).checkout
|
226
|
+
git_base.branch(branch).checkout
|
210
227
|
end
|
211
228
|
end
|
212
229
|
git_base
|
@@ -268,7 +285,7 @@ module DTK
|
|
268
285
|
ret = yield
|
269
286
|
rescue => e
|
270
287
|
unless e.respond_to?(:message)
|
271
|
-
raise e
|
288
|
+
raise e
|
272
289
|
else
|
273
290
|
err_msg = e.message
|
274
291
|
lines = err_msg.split("\n")
|
@@ -276,7 +293,7 @@ module DTK
|
|
276
293
|
err_msg = error_msg_when_git_error(lines)
|
277
294
|
end
|
278
295
|
raise DtkError.new(err_msg)
|
279
|
-
end
|
296
|
+
end
|
280
297
|
end
|
281
298
|
ret
|
282
299
|
end
|
data/lib/dtk-client/version.rb
CHANGED
data/lib/util/module_util.rb
CHANGED
@@ -36,6 +36,10 @@ module DTK
|
|
36
36
|
DtkLogger.instance.debug(caller)
|
37
37
|
raise DtkError, "Module name should be in following format NAMESPACE#{NAMESPACE_SEPERATOR}MODULE_NAME" unless module_identifier.match(Regexp.new("^.+#{NAMESPACE_SEPERATOR}.+$"))
|
38
38
|
end
|
39
|
+
|
40
|
+
def self.type_to_sym(module_type_s)
|
41
|
+
module_type_s.to_s.gsub!(/\_/,'-').to_sym
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
end
|
data/lib/util/os_util.rb
CHANGED
@@ -161,6 +161,12 @@ module DTK
|
|
161
161
|
clone_base_path(:assembly_module)
|
162
162
|
end
|
163
163
|
|
164
|
+
def backups_location()
|
165
|
+
path = Config[:backups_location]
|
166
|
+
final_path = path && path.start_with?('/') ? path : "#{dtk_local_folder}#{path}"
|
167
|
+
final_path.gsub(/\/$/,'')
|
168
|
+
end
|
169
|
+
|
164
170
|
def clone_base_path(module_type)
|
165
171
|
|
166
172
|
path =
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtk-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich PELAVIN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -218,8 +218,10 @@ files:
|
|
218
218
|
- lib/commands/common/thor/inventory_parser.rb
|
219
219
|
- lib/commands/common/thor/list_diffs.rb
|
220
220
|
- lib/commands/common/thor/module.rb
|
221
|
+
- lib/commands/common/thor/module/import.rb
|
221
222
|
- lib/commands/common/thor/pull_clone_changes.rb
|
222
223
|
- lib/commands/common/thor/pull_from_remote.rb
|
224
|
+
- lib/commands/common/thor/puppet_forge.rb
|
223
225
|
- lib/commands/common/thor/purge_clone.rb
|
224
226
|
- lib/commands/common/thor/push_clone_changes.rb
|
225
227
|
- lib/commands/common/thor/push_to_remote.rb
|