artifactory 3.0.0 → 3.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99eec5403c1597dcef5319f77ce0e7cee82fde160004f01057cac828be15f4a0
4
- data.tar.gz: 870155468f372f9db56ad829a37bd5e5dfde0df844d4a7867a43f571cd9a3f58
3
+ metadata.gz: 6b7b1a0145b81545ac79eb8ee9a46168c9c1cc754bb173684de8c0ecf33f3687
4
+ data.tar.gz: 10e223e64e4c9e35dc8df1858c76732f8c430b5684f604f3a64f943d10534429
5
5
  SHA512:
6
- metadata.gz: a6e566148878151b91e7e008d4e7c534c577e6b2de49377f6b5c1949aaf283e30cd22cb9ff1c7ef75d648ee2ea3437df39dc26b790074b80de505aebec3bfcd1
7
- data.tar.gz: dd8470bf9d56565ace72545d5773ae167081ca60df7c2f3969960bd03ddb551cccf3ef50d770b15cbd44216cb4b7262ceaa9d09da1889ae32b1f17468e49ecd5
6
+ metadata.gz: 4ca390ee594e732b753cc2d42af359b92d7e1917d897b600fdb6692aa7b1919dd54e6dedb9711bf519c643b0fe51ae5dd51c45cb1058078f6783dc3717629242
7
+ data.tar.gz: 1b0673c2f1f863bc446c09db795f62f951e857436ec63ae64c7f5ce252244a18a5b026005afb4e2a32a1a9fe690508b1d84306f6724ea6a504a9883f9ea67f9f
@@ -36,6 +36,7 @@ module Artifactory
36
36
  autoload :Base, "artifactory/resources/base"
37
37
  autoload :Build, "artifactory/resources/build"
38
38
  autoload :BuildComponent, "artifactory/resources/build_component"
39
+ autoload :Certificate, "artifactory/resources/certificate"
39
40
  autoload :Group, "artifactory/resources/group"
40
41
  autoload :Layout, "artifactory/resources/layout"
41
42
  autoload :LDAPSetting, "artifactory/resources/ldap_setting"
@@ -50,6 +50,7 @@ module Artifactory
50
50
 
51
51
  proxy Resource::Artifact
52
52
  proxy Resource::Backup
53
+ proxy Resource::Certificate
53
54
  proxy Resource::Layout
54
55
  proxy Resource::LDAPSetting
55
56
  proxy Resource::MailServer
@@ -266,7 +267,7 @@ module Artifactory
266
267
 
267
268
  case response
268
269
  when Net::HTTPRedirection
269
- redirect = URI.parse(response["location"])
270
+ redirect = response["location"]
270
271
  request(verb, redirect, data, headers)
271
272
  when Net::HTTPSuccess
272
273
  success(response)
@@ -371,7 +372,7 @@ module Artifactory
371
372
  if (response.content_type || "").include?("json")
372
373
  JSON.parse(response.body || "{}")
373
374
  else
374
- response.body
375
+ response.body || ""
375
376
  end
376
377
  end
377
378
 
@@ -0,0 +1,89 @@
1
+ module Artifactory
2
+ class Resource::Certificate < Resource::Base
3
+ class << self
4
+ #
5
+ # Get a list of all certificates in the system.
6
+ #
7
+ # @param [Hash] options
8
+ # the list of options
9
+ #
10
+ # @option options [Artifactory::Client] :client
11
+ # the client object to make the request with
12
+ #
13
+ # @return [Array<Resource::Certificate>]
14
+ # the list of builds
15
+ #
16
+ def all(options = {})
17
+ client = extract_client!(options)
18
+ client.get("/api/system/security/certificates").map do |cert|
19
+ from_hash(cert, client: client)
20
+ end.compact
21
+ end
22
+
23
+ #
24
+ # @see Artifactory::Resource::Base.from_hash
25
+ #
26
+ def from_hash(hash, options = {})
27
+ super.tap do |instance|
28
+ instance.issued_on = Time.parse(instance.issued_on) rescue nil
29
+ instance.valid_until = Time.parse(instance.valid_until) rescue nil
30
+ end
31
+ end
32
+ end
33
+
34
+ attribute :certificate_alias, -> { raise "Certificate alias missing!" }
35
+ attribute :fingerprint
36
+ attribute :issued_by
37
+ attribute :issued_on
38
+ attribute :issued_to
39
+ attribute :local_path, -> { raise "Local destination missing!" }
40
+ attribute :valid_until
41
+
42
+ #
43
+ # Delete this certificate from artifactory, suppressing any +ResourceNotFound+
44
+ # exceptions might occur.
45
+ #
46
+ # @return [Boolean]
47
+ # true if the object was deleted successfully, false otherwise
48
+ #
49
+ def delete
50
+ client.delete(api_path)
51
+ true
52
+ rescue Error::HTTPError => e
53
+ false
54
+ end
55
+
56
+ #
57
+ # Upload a certificate. If the first parameter is a File object, that file
58
+ # descriptor is passed to the uploader. If the first parameter is a string,
59
+ # it is assumed to be a path to a local file on disk. This method will
60
+ # automatically construct the File object from the given path.
61
+ #
62
+ # @example Upload a certificate from a File instance
63
+ # certificate = Certificate.new(local_path: '/path/to/cert.pem', certificate_alias: 'test')
64
+ # certificate.upload
65
+ #
66
+ # @return [Resource::Certificate]
67
+ #
68
+ def upload
69
+ file = File.new(File.expand_path(local_path))
70
+ headers = { "Content-Type" => "application/text" }
71
+
72
+ response = client.post(api_path, file, headers)
73
+
74
+ return unless response.is_a?(Hash)
75
+ self.class.all.select { |x| x.certificate_alias.eql?(certificate_alias) }.first
76
+ end
77
+
78
+ private
79
+
80
+ #
81
+ # The path to this certificate on the server.
82
+ #
83
+ # @return [String]
84
+ #
85
+ def api_path
86
+ "/api/system/security/certificates/#{url_safe(certificate_alias)}"
87
+ end
88
+ end
89
+ end
@@ -84,6 +84,9 @@ module Artifactory
84
84
  attribute :url, ""
85
85
  attribute :yum_root_depth, 0
86
86
  attribute :calculate_yum_metadata, false
87
+ attribute :repositories, []
88
+ attribute :external_dependencies_enabled, false
89
+ attribute :client_tls_certificate, ""
87
90
 
88
91
  #
89
92
  # Creates or updates a repository configuration depending on if the
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module Artifactory
18
- VERSION = "3.0.0".freeze
18
+ VERSION = "3.0.5".freeze
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artifactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Release Engineering Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2019-07-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby client for Artifactory
14
14
  email: releng@chef.io
@@ -30,6 +30,7 @@ files:
30
30
  - lib/artifactory/resources/base.rb
31
31
  - lib/artifactory/resources/build.rb
32
32
  - lib/artifactory/resources/build_component.rb
33
+ - lib/artifactory/resources/certificate.rb
33
34
  - lib/artifactory/resources/group.rb
34
35
  - lib/artifactory/resources/layout.rb
35
36
  - lib/artifactory/resources/ldap_setting.rb
@@ -61,8 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  - !ruby/object:Gem::Version
62
63
  version: '0'
63
64
  requirements: []
64
- rubyforge_project:
65
- rubygems_version: 2.7.6
65
+ rubygems_version: 3.0.3
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Artifactory is a simple, lightweight Ruby client for interacting with the