ike-artifactory 0.0.1pre2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cleaner.rb +12 -4
- data/lib/ike_artifactory/client.rb +7 -1
- data/lib/ike_artifactory/docker_cleaner.rb +12 -2
- data/lib/ike_artifactory/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a820f721d21028a9d6e4d848c616a57688933f42278c3627ae8235feaacebe9a
|
4
|
+
data.tar.gz: 14e3cc59825373d278aeec0a3abbd9d531128c69c3ec437e3a5f279e4f2b7a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7be6653e88945813562d1e4245738f49adafc1e8db2a379fffafea1cc3bab0398f7d25b227084409762b1fae6c6755c460a831847b1dd459db2b1fa8f4ee41b6
|
7
|
+
data.tar.gz: 257097d4b827de943bb3acaf4a29c6a08aaf19b1084a03f3036754bfdceeebd5c3f4e4bacf4cb310a7b9e8451388dedc6a80abcbb982a8512ded45fdd0a615b7
|
data/bin/cleaner.rb
CHANGED
@@ -5,13 +5,20 @@ $:.unshift(File.expand_path('../../lib', __FILE__))
|
|
5
5
|
require 'ike_artifactory'
|
6
6
|
|
7
7
|
actually_delete = false
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
delete_empty_path = false
|
9
|
+
while ARGV[0] =~ /^--/ do
|
10
|
+
arg = ARGV.shift
|
11
|
+
if arg == '--actually-delete'
|
12
|
+
actually_delete = true
|
13
|
+
end
|
14
|
+
|
15
|
+
if arg == '--delete-empty-path'
|
16
|
+
delete_empty_path = true
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
20
|
unless [7,8].include?(ARGV.count)
|
14
|
-
STDERR.puts "Usage: $0 [--actually-delete] artifactory_url repo_key username password application_list image_exclude_list days_to_keep [most_recent_images_to_keep]"
|
21
|
+
STDERR.puts "Usage: $0 [--actually-delete] [--delete-empty-path] artifactory_url repo_key username password application_list image_exclude_list days_to_keep [most_recent_images_to_keep]"
|
15
22
|
exit 1
|
16
23
|
end
|
17
24
|
|
@@ -52,6 +59,7 @@ apps.each do |app|
|
|
52
59
|
puts "Cleaning #{app}"
|
53
60
|
cleaner = IKE::Artifactory::DockerCleaner.new(
|
54
61
|
actually_delete: actually_delete,
|
62
|
+
delete_empty_path: delete_empty_path,
|
55
63
|
repo_host: artifactory_url,
|
56
64
|
repo_key: repo_key,
|
57
65
|
folder: app,
|
@@ -79,7 +79,13 @@ module IKE
|
|
79
79
|
def fetch(path, method: :get, prefix: nil)
|
80
80
|
retval = nil # Work around Object#stub stomping on return values
|
81
81
|
|
82
|
-
prefix ||=
|
82
|
+
prefix ||=
|
83
|
+
case method
|
84
|
+
when :delete
|
85
|
+
"#{server}/artifactory/#{repo_key}"
|
86
|
+
else
|
87
|
+
"#{server}/artifactory/api/storage/#{repo_key}"
|
88
|
+
end
|
83
89
|
|
84
90
|
RestClient::Request.execute(
|
85
91
|
:method => method,
|
@@ -15,10 +15,11 @@ module IKE
|
|
15
15
|
attr_reader :most_recent_images # is not tested
|
16
16
|
attr_reader :logger # is not tested. Used for testing
|
17
17
|
attr_reader :actually_delete
|
18
|
+
attr_reader :delete_empty_path
|
18
19
|
|
19
20
|
def initialize(repo_host:, repo_key:, folder:, days_old:,
|
20
21
|
tags_to_exclude:, user:, password:, most_recent_images:,
|
21
|
-
log_level: ::Logger::INFO, actually_delete: false)
|
22
|
+
log_level: ::Logger::INFO, actually_delete: false, delete_empty_path: false)
|
22
23
|
|
23
24
|
@repo_host = repo_host
|
24
25
|
@repo_key = repo_key
|
@@ -27,7 +28,8 @@ module IKE
|
|
27
28
|
@tags_to_exclude = tags_to_exclude || []
|
28
29
|
@most_recent_images = most_recent_images
|
29
30
|
|
30
|
-
@actually_delete
|
31
|
+
@actually_delete = actually_delete
|
32
|
+
@delete_empty_path = delete_empty_path
|
31
33
|
|
32
34
|
@client = IKE::Artifactory::Client.new(
|
33
35
|
:server => repo_host,
|
@@ -75,6 +77,14 @@ module IKE
|
|
75
77
|
end
|
76
78
|
deleted_images.append(tag)
|
77
79
|
end
|
80
|
+
if delete_empty_path && deleted_images.length() == tags.length()
|
81
|
+
logger.info "#{logger_prefix}: removing empty path #{folder}"
|
82
|
+
if actually_delete
|
83
|
+
client.delete_object "#{folder}"
|
84
|
+
else
|
85
|
+
logger.info("#{logger_prefix}: Not actually deleting #{folder} because actually_delete is falsy")
|
86
|
+
end
|
87
|
+
end
|
78
88
|
deleted_images
|
79
89
|
end
|
80
90
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ike-artifactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Marden
|
8
8
|
- Jack Newton
|
9
9
|
- Vicente Ramos Garcia
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-03-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -91,7 +91,7 @@ licenses:
|
|
91
91
|
- MIT
|
92
92
|
metadata:
|
93
93
|
allowed_push_host: https://rubygems.org
|
94
|
-
post_install_message:
|
94
|
+
post_install_message:
|
95
95
|
rdoc_options: []
|
96
96
|
require_paths:
|
97
97
|
- lib
|
@@ -102,12 +102,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- - "
|
105
|
+
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
107
|
+
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubygems_version: 3.1.6
|
110
|
-
signing_key:
|
110
|
+
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Provides an object-oriented interface to Artifactory API.
|
113
113
|
test_files: []
|