nexus_cli 0.8.1 → 0.8.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.8.2
@@ -124,7 +124,7 @@ Feature: Use the Nexus CLI
124
124
  And I call the nexus "get_repository_info Artifacts" command
125
125
  Then the output should contain:
126
126
  """
127
- The repository you requested information could not be found. Please ensure the repository exists.
127
+ The repository you provided could not be found. Please ensure the repository exists.
128
128
  """
129
129
  And the exit status should be 114
130
130
 
@@ -187,4 +187,46 @@ Feature: Use the Nexus CLI
187
187
  """
188
188
  The logging level of Nexus has been set to INFO
189
189
  """
190
- And the exit status should be 0
190
+ And the exit status should be 0
191
+
192
+ Scenario: Create a Nexus Group Repository
193
+ When I call the nexus "create_group_repository cucumber_group" command
194
+ Then the output should contain:
195
+ """
196
+ A new group repository named cucumber_group has been created.
197
+ """
198
+ And the exit status should be 0
199
+
200
+ Scenario: Get information about a Nexus Group Repository
201
+ When I call the nexus "get_group_repository cucumber_group" command
202
+ Then the output should contain:
203
+ """
204
+ \"id\":\"cucumber_group\"
205
+ """
206
+ And the exit status should be 0
207
+
208
+ Scenario: Add a repository to the Nexus Group Repository
209
+ When I call the nexus "add_to_group_repository cucumber_group releases" command
210
+ Then the output should contain:
211
+ """
212
+ The repository releases has been added to the repository group cucumber_group
213
+ """
214
+ And the exit status should be 0
215
+
216
+ Scenario: Remove a repository from a Nexus Group Repository
217
+ When I call the nexus "remove_from_group_repository cucumber_group releases" command
218
+ And I call the nexus "get_group_repository cucumber_group" command
219
+ Then the output should not contain:
220
+ """
221
+ \"id\"=>\"releases\"
222
+ """
223
+ And the exit status should be 0
224
+
225
+ Scenario: Delete a Nexus Group Repository
226
+ When I call the nexus "delete_group_repository cucumber_group" command
227
+ And I call the nexus "get_group_repository cucumber_group" command
228
+ Then the output should not contain:
229
+ """
230
+ \"id\":\"cucumber_group\"
231
+ """
232
+ And the exit status should be 114
@@ -70,14 +70,14 @@ P5KVneepzhtEt9G/uO4MU89cdUR0IMyUwdhq2dg=
70
70
  -----END CERTIFICATE-----
71
71
  ")
72
72
  end
73
- step "I run `nexus-cli add_trusted_key --certificate=#{File.join(temp_dir, "cert.txt")} --description=cucumber`"
73
+ step "I run `nexus-cli add_trusted_key --certificate=#{File.join(temp_dir, "cert.txt")} --description=cucumber --overrides=#{get_overrides_string}`"
74
74
  end
75
75
  end
76
76
 
77
77
  When /^I delete a trusted key in nexus$/ do
78
78
  json = JSON.parse(nexus_remote.get_trusted_keys)
79
79
  key_id = json["data"].first["id"]
80
- step "I run `nexus-cli delete_trusted_key #{key_id}`"
80
+ step "I run `nexus-cli delete_trusted_key #{key_id} --overrides=#{get_overrides_string}`"
81
81
  end
82
82
 
83
83
  Then /^a file named "(.*?)" should exist in my nexus folder$/ do |file|
@@ -127,7 +127,7 @@ The output from the server was:
127
127
 
128
128
  class RepositoryNotFoundException < NexusCliError
129
129
  def message
130
- "The repository you requested information could not be found. Please ensure the repository exists."
130
+ "The repository you provided could not be found. Please ensure the repository exists."
131
131
  end
132
132
  status_code(114)
133
133
  end
@@ -330,6 +330,62 @@ module NexusCli
330
330
  end
331
331
  end
332
332
 
333
+ def create_group_repository(name)
334
+ response = nexus.post(nexus_url("service/local/repo_groups"), :body => create_group_repository_json(name), :header => DEFAULT_CONTENT_TYPE_HEADER)
335
+ case response.status
336
+ when 201
337
+ return true
338
+ else
339
+ raise UnexpectedStatusCodeException.new(response.status)
340
+ end
341
+ end
342
+
343
+ def get_group_repository(group_id)
344
+ response = nexus.get(nexus_url("service/local/repo_groups/#{group_id}"), :header => DEFAULT_ACCEPT_HEADER)
345
+ case response.status
346
+ when 200
347
+ return response.content
348
+ when 404
349
+ raise RepositoryNotFoundException
350
+ else
351
+ raise UnexpectedStatusCodeException.new(response.status)
352
+ end
353
+ end
354
+
355
+ def add_to_group_repository(group_id, repository_to_add_id)
356
+ response = nexus.put(nexus_url("service/local/repo_groups/#{group_id}"), :body => create_add_to_group_repository_json(group_id, repository_to_add_id), :header => DEFAULT_CONTENT_TYPE_HEADER)
357
+ case response.status
358
+ when 200
359
+ return true
360
+ when 400
361
+ raise RepositoryNotFoundException
362
+ else
363
+ raise UnexpectedStatusCodeException.new(response.status)
364
+ end
365
+ end
366
+
367
+ def remove_from_group_repository(group_id, repository_to_remove_id)
368
+ response = nexus.put(nexus_url("service/local/repo_groups/#{group_id}"), :body => create_remove_from_group_repository_json(group_id, repository_to_remove_id), :header => DEFAULT_CONTENT_TYPE_HEADER)
369
+ case response.status
370
+ when 200
371
+ return true
372
+ else
373
+ raise UnexpectedStatusCodeException.new(response.status)
374
+ end
375
+ end
376
+
377
+ def delete_group_repository(group_id)
378
+ response = nexus.delete(nexus_url("service/local/repo_groups/#{group_id}"))
379
+ case response.status
380
+ when 204
381
+ return true
382
+ when 404
383
+ raise RepositoryNotFoundException
384
+ else
385
+ raise UnexpectedStatusCodeException.new(response.status)
386
+ end
387
+ end
388
+
333
389
  private
334
390
 
335
391
  def format_search_results(doc, group_id, artifact_id)
@@ -392,5 +448,37 @@ module NexusCli
392
448
  params = {:rootLoggerLevel => level.upcase}
393
449
  JSON.dump(:data => params)
394
450
  end
451
+
452
+ def create_group_repository_json(name)
453
+ params = {:id => name.gsub(" ", "_").downcase}
454
+ params[:name] = name
455
+ params[:provider] = "maven2"
456
+ params[:exposed] = true
457
+ JSON.dump(:data => params)
458
+ end
459
+
460
+ def create_add_to_group_repository_json(group_id, repository_to_add_id)
461
+ group_repository_json = get_group_repository(group_id)
462
+ repositories = JSON.parse(group_repository_json)["data"]["repositories"]
463
+ repositories << {:id => repository_to_add_id}
464
+ params = {:repositories => repositories}
465
+ params[:id] = group_id
466
+ JSON.dump(:data => params)
467
+ end
468
+
469
+ def create_remove_from_group_repository_json(group_id, repository_to_remove_id)
470
+ group_repository_json = get_group_repository(group_id)
471
+ repositories = JSON.parse(group_repository_json)["data"]["repositories"]
472
+
473
+ entry_to_remove = repositories.find{|repository| repository["id"] == repository_to_remove_id}
474
+ if entry_to_remove.nil?
475
+ raise RepositoryNotFoundException
476
+ else
477
+ repositories.delete(entry_to_remove)
478
+ end
479
+ params = {:repositories => repositories}
480
+ params[:id] = group_id
481
+ JSON.dump(:data => params)
482
+ end
395
483
  end
396
- end
484
+ end
@@ -5,7 +5,7 @@ require 'yaml'
5
5
  module NexusCli
6
6
  class Factory
7
7
  class << self
8
- def create(overrides, ssl_verify)
8
+ def create(overrides, ssl_verify=false)
9
9
  @configuration = Configuration::parse(overrides)
10
10
  @ssl_verify = ssl_verify
11
11
  running_nexus_pro? ? ProRemote.new(overrides, ssl_verify) : OSSRemote.new(overrides, ssl_verify)
@@ -383,6 +383,39 @@ module NexusCli
383
383
  end
384
384
  end
385
385
 
386
+ desc "create_group_repository name", "Creates a new repository group with the given name."
387
+ def create_group_repository(name)
388
+ if @nexus_remote.create_group_repository(name)
389
+ say "A new group repository named #{name} has been created.", :blue
390
+ end
391
+ end
392
+
393
+ desc "get_group_repository group_id", "Gets information about the given group repository."
394
+ def get_group_repository(group_id)
395
+ say @nexus_remote.get_group_repository(group_id), :green
396
+ end
397
+
398
+ desc "add_to_group_repository group_id repository_to_add_id", "Adds a repository with the given id into the group repository."
399
+ def add_to_group_repository(group_id, repository_to_add_id)
400
+ if @nexus_remote.add_to_group_repository(group_id, repository_to_add_id)
401
+ say "The repository #{repository_to_add_id} has been added to the repository group #{group_id}", :blue
402
+ end
403
+ end
404
+
405
+ desc "remove_from_group_repository group_id repository_to_remove_id", "Remove a repository with the given id from the group repository."
406
+ def remove_from_group_repository(group_id, repository_to_remove_id)
407
+ if @nexus_remote.remove_from_group_repository(group_id, repository_to_remove_id)
408
+ say "The repository with an id of #{repository_to_remove_id} has been removed from the group repository, #{group_id}.", :blue
409
+ end
410
+ end
411
+
412
+ desc "delete_group_repository group_id","Deletes a group repository based on the given id."
413
+ def delete_group_repository(group_id)
414
+ if @nexus_remote.delete_group_repository(group_id)
415
+ say "The group repository, #{group_id} has been deleted.", :blue
416
+ end
417
+ end
418
+
386
419
  private
387
420
 
388
421
  def ask_user(params, ask_username=true, ask_password=true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-24 00:00:00.000000000 Z
12
+ date: 2012-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -253,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
253
253
  version: '0'
254
254
  segments:
255
255
  - 0
256
- hash: 4549159005215379437
256
+ hash: 3888319830353730279
257
257
  required_rubygems_version: !ruby/object:Gem::Requirement
258
258
  none: false
259
259
  requirements:
@@ -262,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  version: '0'
263
263
  segments:
264
264
  - 0
265
- hash: 4549159005215379437
265
+ hash: 3888319830353730279
266
266
  requirements: []
267
267
  rubyforge_project:
268
268
  rubygems_version: 1.8.21