artifactory 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -1
- data/lib/artifactory/resources/artifact.rb +54 -4
- data/lib/artifactory/version.rb +1 -1
- data/spec/integration/resources/artifact_spec.rb +14 -0
- data/spec/support/api_server/artifact_endpoints.rb +24 -0
- data/spec/unit/resources/artifact_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25479b749ea49c38799479ba12df5373efdf77a0
|
4
|
+
data.tar.gz: 52732e8ba49c9b1e29ad2180aa1e4ff8175d1798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e111db3109a4598677fd2ba3b1cbe7d5cb26c087e43690c06ca97cc3ced0b0fc776e1736dfadf87ee5d8683ba1d6a369dbd0c416ae27055d41dfa0ca69d58c6f
|
7
|
+
data.tar.gz: c76f8078e1829439fb4673a284842c954d8aa859b9ac16cad3535f508f568309c196e587df1d43946bcc1725e97211c5460d0797bd27717054124687ff4449f2
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ Artifactory Client CHANGELOG
|
|
3
3
|
This file is used to document the changes between releases of the Artifactory
|
4
4
|
Ruby client.
|
5
5
|
|
6
|
+
v2.8.0 (03-17-2017)
|
7
|
+
-------------------
|
8
|
+
- Include statuses in Build resource
|
9
|
+
|
6
10
|
v2.7.0 (02-21-2017)
|
7
11
|
-------------------
|
8
12
|
- Include statuses in Build resource
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Artifactory Client
|
2
2
|
==================
|
3
|
-
[![Gem Version](http://img.shields.io/gem/v/artifactory.svg)][gem] [![Travis Build Status](http://img.shields.io/travis/chef/artifactory-client.svg?label=Travis
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/artifactory.svg)][gem] [![Travis Build Status](http://img.shields.io/travis/chef/artifactory-client.svg?label=Travis%20CI)][travis] [![AppVeyor Build Status](http://img.shields.io/appveyor/ci/chef/artifactory-client.svg?label=AppVeyor)][appveyor]
|
4
4
|
|
5
5
|
A Ruby client and interface to the Artifactory API. **The majority of API endpoints are only exposed for Artifactory Pro customers!** As such, many of the resources and actions exposed by this gem also require Artifactory Pro.
|
6
6
|
|
@@ -115,6 +115,8 @@ artifact #=> "#<Artifactory::Resource::Artifact md5: 'ABCD1234'>"
|
|
115
115
|
# Get the properties of an artifact
|
116
116
|
artifact.md5 #=> "ABCD1234"
|
117
117
|
artifact.properties #=> { ... }
|
118
|
+
# Set the properties of an artifact
|
119
|
+
artifact.properties({prop1: 'value1', 'prop2': 'value2'}) #=> { ... }
|
118
120
|
|
119
121
|
# Download the artifact to disk
|
120
122
|
artifact.download #=> /tmp/folders-a38b0decf038201/package.deb
|
@@ -430,16 +430,27 @@ module Artifactory
|
|
430
430
|
end
|
431
431
|
|
432
432
|
#
|
433
|
-
#
|
433
|
+
# Set properties for this object. If no properties are given it lists the properties for this object.
|
434
434
|
#
|
435
435
|
# @example List all properties for an artifact
|
436
|
-
# artifact.properties #=> { '
|
436
|
+
# artifact.properties #=> { 'licenses'=>['Apache-2.0'] }
|
437
|
+
#
|
438
|
+
# @example Set new properties for an artifact
|
439
|
+
# artifact.properties(maintainer: 'SuperStartup01') #=> { 'licenses'=>['Apache-2.0'], 'maintainer'=>'SuperStartup01' }
|
440
|
+
#
|
441
|
+
# @param [Hash<String, Object>] props (default: +nil+)
|
442
|
+
# A hash of properties and corresponding values to set for the artifact
|
437
443
|
#
|
438
444
|
# @return [Hash<String, Object>]
|
439
445
|
# the list of properties
|
440
446
|
#
|
441
|
-
def properties
|
442
|
-
|
447
|
+
def properties(props = nil)
|
448
|
+
if props.nil? || props.empty?
|
449
|
+
get_properties
|
450
|
+
else
|
451
|
+
set_properties(props)
|
452
|
+
get_properties(true)
|
453
|
+
end
|
443
454
|
end
|
444
455
|
|
445
456
|
#
|
@@ -619,6 +630,45 @@ module Artifactory
|
|
619
630
|
|
620
631
|
private
|
621
632
|
|
633
|
+
#
|
634
|
+
# Helper method for reading artifact properties
|
635
|
+
#
|
636
|
+
# @example List all properties for an artifact
|
637
|
+
# artifact.get_properties #=> { 'artifactory.licenses'=>['Apache-2.0'] }
|
638
|
+
#
|
639
|
+
# @param [TrueClass, FalseClass] refresh_cache (default: +false+)
|
640
|
+
# wether or not to use the locally cached value if it exists and is not nil
|
641
|
+
#
|
642
|
+
# @return [Hash<String, Object>]
|
643
|
+
# the list of properties
|
644
|
+
#
|
645
|
+
def get_properties(refresh_cache = false)
|
646
|
+
if refresh_cache || @properties.nil?
|
647
|
+
@properties = client.get(File.join("/api/storage", relative_path), properties: nil)["properties"]
|
648
|
+
end
|
649
|
+
|
650
|
+
@properties
|
651
|
+
end
|
652
|
+
|
653
|
+
#
|
654
|
+
# Helper method for setting artifact properties
|
655
|
+
#
|
656
|
+
# @example Set properties for an artifact
|
657
|
+
# artifact.set_properties({ prop1: 'value1', 'prop2' => 'value2' })
|
658
|
+
#
|
659
|
+
# @param [Hash<String, Object>] properties
|
660
|
+
# A hash of properties and corresponding values to set for the artifact
|
661
|
+
#
|
662
|
+
# @return [Hash]
|
663
|
+
# the parsed JSON response from the server
|
664
|
+
#
|
665
|
+
def set_properties(properties)
|
666
|
+
matrix = to_matrix_properties(properties)
|
667
|
+
endpoint = File.join("/api/storage", relative_path) + "?properties=#{matrix}"
|
668
|
+
|
669
|
+
client.put(endpoint, nil)
|
670
|
+
end
|
671
|
+
|
622
672
|
#
|
623
673
|
# Helper method for extracting the relative (repo) path, since it's not
|
624
674
|
# returned as part of the API.
|
data/lib/artifactory/version.rb
CHANGED
@@ -32,6 +32,20 @@ module Artifactory
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe ".properties" do
|
36
|
+
let(:artifact) do
|
37
|
+
artifact = described_class.send(:search, repos: "libs-properties-local", name: "artifact.deb").first
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns artifact properties when reading" do
|
41
|
+
expect(artifact.properties).to include({ "licenses" => [ "Apache 2" ] })
|
42
|
+
end
|
43
|
+
|
44
|
+
it "writes artifact properties" do
|
45
|
+
expect(artifact.properties({ author: "Jörg", "status" => "public" })).to eq({ "licenses" => [ "Apache 2" ], "author" => "Jörg", "status" => "public" })
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
35
49
|
describe ".search" do
|
36
50
|
it_behaves_like "an artifact search endpoint", :search, name: "artifact.deb"
|
37
51
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Artifactory
|
2
2
|
module APIServer::ArtifactEndpoints
|
3
3
|
def self.registered(app)
|
4
|
+
artifact_properties = { "licenses" => [ "Apache 2" ] }
|
5
|
+
|
4
6
|
app.get("/api/search/artifact") do
|
5
7
|
content_type "application/vnd.org.jfrog.artifactory.search.ArtifactSearchResult+json"
|
6
8
|
artifacts_for_conditions do
|
@@ -86,6 +88,22 @@ module Artifactory
|
|
86
88
|
)
|
87
89
|
end
|
88
90
|
|
91
|
+
app.get("/api/storage/libs-properties-local/org/acme/artifact.deb") do
|
92
|
+
content_type "application/vnd.org.jfrog.artifactory.storage.ItemProperties+json"
|
93
|
+
JSON.fast_generate(
|
94
|
+
"properties" => artifact_properties,
|
95
|
+
"uri" => server_url.join("/api/storage/libs-properties-local/org/acme/artifact.deb")
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
app.put("/api/storage/libs-properties-local/org/acme/artifact.deb") do
|
100
|
+
props = params["properties"].split(";").reject(&:empty?).map { |e| e.split("=") }.to_h
|
101
|
+
artifact_properties.merge!(props)
|
102
|
+
|
103
|
+
status 204
|
104
|
+
body ""
|
105
|
+
end
|
106
|
+
|
89
107
|
app.get("/api/storage/ext-release-local/org/acme/artifact.deb") do
|
90
108
|
content_type "application/vnd.org.jfrog.artifactory.storage.FileInfo+json"
|
91
109
|
JSON.fast_generate(
|
@@ -145,6 +163,12 @@ module Artifactory
|
|
145
163
|
{ "uri" => server_url.join("/api/storage/libs-release-local/org/acme/artifact.deb") },
|
146
164
|
]
|
147
165
|
)
|
166
|
+
elsif params["repos"] == "libs-properties-local"
|
167
|
+
JSON.fast_generate(
|
168
|
+
"results" => [
|
169
|
+
{ "uri" => server_url.join("/api/storage/libs-properties-local/org/acme/artifact.deb") },
|
170
|
+
]
|
171
|
+
)
|
148
172
|
else
|
149
173
|
JSON.fast_generate(
|
150
174
|
"results" => [
|
@@ -482,10 +482,15 @@ module Artifactory
|
|
482
482
|
let(:response) do
|
483
483
|
{ "properties" => properties }
|
484
484
|
end
|
485
|
+
|
485
486
|
let(:client) { double(get: response) }
|
486
487
|
let(:relative_path) { "/api/storage/some-repo/path/artifact.deb" }
|
487
488
|
let(:artifact_uri) { File.join("http://33.33.33.11", relative_path) }
|
488
489
|
|
490
|
+
let(:property_set_path) { "#{relative_path}?properties=;author=J%C3%B6rg;status=public" }
|
491
|
+
let(:new_properties) { { author: "Jörg", "status" => "public" } }
|
492
|
+
let(:client) { double(put: nil ) }
|
493
|
+
|
489
494
|
before do
|
490
495
|
subject.client = client
|
491
496
|
subject.uri = artifact_uri
|
@@ -500,6 +505,16 @@ module Artifactory
|
|
500
505
|
subject.properties
|
501
506
|
expect(subject.instance_variable_get(:@properties)).to eq(properties)
|
502
507
|
end
|
508
|
+
|
509
|
+
it "sets the properties on the server" do
|
510
|
+
expect(client).to receive(:put).with(property_set_path, nil).once
|
511
|
+
subject.properties(new_properties)
|
512
|
+
end
|
513
|
+
|
514
|
+
it "updates the chache" do
|
515
|
+
expect(subject).to receive(:get_properties).with(true).once
|
516
|
+
subject.properties(new_properties)
|
517
|
+
end
|
503
518
|
end
|
504
519
|
|
505
520
|
describe "#compliance" do
|
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: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|