conjur-debify 3.0.3.pre.10 → 3.0.3.pre.145
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 +4 -4
- data/Dockerfile +1 -1
- data/VERSION +1 -1
- data/lib/conjur/debify/action/publish.rb +42 -39
- data/lib/conjur/debify.rb +254 -248
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 749d66a8a64cbc22abc88af81e4f1851ee888d178c875d8c384da86e9c84a472
|
|
4
|
+
data.tar.gz: 7d0713e5b38339ce6ac39d4c6714593d00ace8f6515e8c8d3f5b0914a2a14d48
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '07198fe9a64df0947c30bf59ec95af4c63ca81abbfc7dff9d46188b480f21e373bbcccdd84ff3be97b0c37d41db7dd4f05f34ed82376de62f28206c23423c2b0'
|
|
7
|
+
data.tar.gz: 2ac3dc9e0bbda1d32a046fcd376f5b8aabf24df4b1a09695a3300e935e3d4ed8ab301e0cf6ae8a1af12c8de84554375b9971d92deec45011fc1e67f357e41314
|
data/Dockerfile
CHANGED
|
@@ -10,7 +10,7 @@ RUN apt-get update -qq && \
|
|
|
10
10
|
rm -rf /var/lib/apt/lists/*
|
|
11
11
|
|
|
12
12
|
# Install Docker client tools
|
|
13
|
-
ENV DOCKERVERSION=
|
|
13
|
+
ENV DOCKERVERSION=27.0.3
|
|
14
14
|
RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \
|
|
15
15
|
&& tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \
|
|
16
16
|
-C /usr/local/bin docker/docker \
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.0.3-
|
|
1
|
+
3.0.3-145
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
module Conjur::Debify
|
|
2
2
|
module Action
|
|
3
3
|
class Publish
|
|
4
|
-
|
|
5
4
|
def detect_component
|
|
6
5
|
branch = ENV['GIT_BRANCH'] || ENV['BRANCH_NAME'] || `git rev-parse --abbrev-ref HEAD`.strip
|
|
7
|
-
if %w
|
|
6
|
+
if %w[master origin/master].include?(branch)
|
|
8
7
|
'stable'
|
|
9
8
|
else
|
|
10
9
|
branch.gsub('/', '.')
|
|
@@ -12,6 +11,7 @@ module Conjur::Debify
|
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
attr_reader :distribution, :project_name, :cmd_options
|
|
14
|
+
|
|
15
15
|
def initialize(distribution, project_name, cmd_options)
|
|
16
16
|
@distribution = distribution
|
|
17
17
|
@project_name = project_name
|
|
@@ -34,23 +34,21 @@ module Conjur::Debify
|
|
|
34
34
|
|
|
35
35
|
art_user = ENV['ARTIFACTORY_USER']
|
|
36
36
|
art_password = ENV['ARTIFACTORY_PASSWORD']
|
|
37
|
-
unless art_user && art_password
|
|
38
|
-
art_user, art_password = fetch_art_creds
|
|
39
|
-
end
|
|
37
|
+
art_user, art_password = fetch_art_creds unless art_user && art_password
|
|
40
38
|
|
|
41
39
|
# Publish AMD64 deb package
|
|
42
40
|
component = cmd_options[:component] || detect_component
|
|
43
41
|
deb_info = "#{distribution}/#{component}/amd64"
|
|
44
42
|
package_name = "conjur-#{project_name}_#{version}_amd64.deb"
|
|
45
43
|
publish_package(
|
|
46
|
-
publish_image
|
|
47
|
-
art_url
|
|
48
|
-
art_user
|
|
49
|
-
art_password
|
|
44
|
+
publish_image:,
|
|
45
|
+
art_url:,
|
|
46
|
+
art_user:,
|
|
47
|
+
art_password:,
|
|
50
48
|
art_repo: deb_art_repo,
|
|
51
|
-
package_name
|
|
52
|
-
dir
|
|
53
|
-
deb_info:
|
|
49
|
+
package_name:,
|
|
50
|
+
dir:,
|
|
51
|
+
deb_info:
|
|
54
52
|
)
|
|
55
53
|
|
|
56
54
|
# (Optional) Publish ARM64 deb package
|
|
@@ -58,14 +56,14 @@ module Conjur::Debify
|
|
|
58
56
|
deb_info = "#{distribution}/#{component}/arm64"
|
|
59
57
|
package_name = "conjur-#{project_name}_#{version}_arm64.deb"
|
|
60
58
|
publish_package(
|
|
61
|
-
publish_image
|
|
62
|
-
art_url
|
|
63
|
-
art_user
|
|
64
|
-
art_password
|
|
59
|
+
publish_image:,
|
|
60
|
+
art_url:,
|
|
61
|
+
art_user:,
|
|
62
|
+
art_password:,
|
|
65
63
|
art_repo: deb_art_repo,
|
|
66
|
-
package_name
|
|
67
|
-
dir
|
|
68
|
-
deb_info:
|
|
64
|
+
package_name:,
|
|
65
|
+
dir:,
|
|
66
|
+
deb_info:
|
|
69
67
|
)
|
|
70
68
|
end
|
|
71
69
|
|
|
@@ -75,19 +73,20 @@ module Conjur::Debify
|
|
|
75
73
|
package_name = "conjur-#{project_name}-#{rpm_version}-1.*.rpm"
|
|
76
74
|
rpm_art_repo = cmd_options['rpm-repo']
|
|
77
75
|
publish_package(
|
|
78
|
-
publish_image
|
|
79
|
-
art_url
|
|
80
|
-
art_user
|
|
81
|
-
art_password
|
|
76
|
+
publish_image:,
|
|
77
|
+
art_url:,
|
|
78
|
+
art_user:,
|
|
79
|
+
art_password:,
|
|
82
80
|
art_repo: rpm_art_repo,
|
|
83
|
-
package_name
|
|
84
|
-
dir:
|
|
81
|
+
package_name:,
|
|
82
|
+
dir:
|
|
85
83
|
)
|
|
86
84
|
end
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
def create_image
|
|
90
|
-
Docker::Image.build_from_dir File.expand_path('../../publish', File.dirname(__FILE__)), tag:
|
|
88
|
+
Docker::Image.build_from_dir File.expand_path('../../publish', File.dirname(__FILE__)), tag: 'debify-publish',
|
|
89
|
+
&DebugMixin::DOCKER
|
|
91
90
|
end
|
|
92
91
|
|
|
93
92
|
def fetch_art_creds
|
|
@@ -98,8 +97,8 @@ module Conjur::Debify
|
|
|
98
97
|
conjur = Conjur::Authn.connect nil, noask: true
|
|
99
98
|
|
|
100
99
|
account = Conjur.configuration.account
|
|
101
|
-
username_var = [account,
|
|
102
|
-
password_var = [account,
|
|
100
|
+
username_var = [account, 'variable', 'ci/artifactory/users/jenkins/username'].join(':')
|
|
101
|
+
password_var = [account, 'variable', 'ci/artifactory/users/jenkins/password'].join(':')
|
|
103
102
|
[conjur.resource(username_var).value, conjur.resource(password_var).value]
|
|
104
103
|
end
|
|
105
104
|
|
|
@@ -115,21 +114,24 @@ module Conjur::Debify
|
|
|
115
114
|
)
|
|
116
115
|
|
|
117
116
|
cmd_args = [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
'jfrog', 'rt', 'upload',
|
|
118
|
+
'--url', art_url,
|
|
119
|
+
'--user', art_user,
|
|
120
|
+
'--password', art_password
|
|
122
121
|
]
|
|
123
122
|
|
|
124
|
-
cmd_args += [
|
|
123
|
+
cmd_args += ['--deb', deb_info] if deb_info
|
|
125
124
|
cmd_args += [package_name, "#{art_repo}/"]
|
|
126
125
|
|
|
127
126
|
options = {
|
|
128
127
|
'Image' => publish_image.id,
|
|
129
128
|
'Cmd' => cmd_args,
|
|
130
|
-
'
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
'HostConfig' => {
|
|
130
|
+
'Binds' => [
|
|
131
|
+
[dir, '/src'].join(':')
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
'WorkingDir' => '/src'
|
|
133
135
|
}
|
|
134
136
|
options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
|
|
135
137
|
|
|
@@ -139,14 +141,15 @@ module Conjur::Debify
|
|
|
139
141
|
def publish(options)
|
|
140
142
|
container = Docker::Container.create(options)
|
|
141
143
|
begin
|
|
142
|
-
container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true)
|
|
144
|
+
container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true) do |_stream, chunk|
|
|
145
|
+
puts "#{chunk}"
|
|
146
|
+
end
|
|
143
147
|
status = container.wait
|
|
144
|
-
raise
|
|
148
|
+
raise 'Failed to publish package' unless status['StatusCode'] == 0
|
|
145
149
|
ensure
|
|
146
150
|
container.delete(force: true)
|
|
147
151
|
end
|
|
148
152
|
end
|
|
149
|
-
|
|
150
153
|
end
|
|
151
154
|
end
|
|
152
155
|
end
|
data/lib/conjur/debify.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'conjur/debify/version'
|
|
2
2
|
require 'docker'
|
|
3
3
|
require 'fileutils'
|
|
4
4
|
require 'gli'
|
|
@@ -14,18 +14,17 @@ require 'active_support/core_ext'
|
|
|
14
14
|
|
|
15
15
|
include GLI::App
|
|
16
16
|
|
|
17
|
-
DEFAULT_FILE_TYPE =
|
|
17
|
+
DEFAULT_FILE_TYPE = 'deb'
|
|
18
18
|
|
|
19
19
|
config_file '.debifyrc'
|
|
20
20
|
|
|
21
21
|
desc 'Set an environment variable (e.g. TERM=xterm) when starting a container'
|
|
22
|
-
flag [:env], :
|
|
22
|
+
flag [:env], multiple: true
|
|
23
23
|
|
|
24
24
|
desc 'Mount local bundle to reuse gems from previous installation'
|
|
25
25
|
default_value true
|
|
26
26
|
switch [:'local-bundle']
|
|
27
27
|
|
|
28
|
-
|
|
29
28
|
Docker.options[:read_timeout] = 300
|
|
30
29
|
|
|
31
30
|
# This is used to turn on DEBUG notices.
|
|
@@ -33,19 +32,19 @@ module DebugMixin
|
|
|
33
32
|
DEBUG = ENV['DEBUG'].nil? ? true : ENV['DEBUG'].downcase == 'true'
|
|
34
33
|
|
|
35
34
|
def debug(* a)
|
|
36
|
-
DebugMixin.debug
|
|
35
|
+
DebugMixin.debug(*a)
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
def self.debug(* a)
|
|
40
|
-
|
|
39
|
+
warn(*a) if DEBUG
|
|
41
40
|
end
|
|
42
41
|
|
|
43
42
|
def debug_write(* a)
|
|
44
|
-
DebugMixin.debug_write
|
|
43
|
+
DebugMixin.debug_write(*a)
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
def self.debug_write(* a)
|
|
48
|
-
$stderr.write
|
|
47
|
+
$stderr.write(*a) if DEBUG
|
|
49
48
|
end
|
|
50
49
|
|
|
51
50
|
# you can give this to various docker methods to print output if debug is on
|
|
@@ -54,16 +53,14 @@ module DebugMixin
|
|
|
54
53
|
debug a.last
|
|
55
54
|
else
|
|
56
55
|
a.each do |line|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
line
|
|
60
|
-
debug line[k]
|
|
61
|
-
end
|
|
62
|
-
rescue JSON::ParserError
|
|
63
|
-
# Docker For Mac is spitting out invalid JSON, so just print
|
|
64
|
-
# out the line if parsing fails.
|
|
65
|
-
debug line
|
|
56
|
+
line = JSON.parse(line)
|
|
57
|
+
line.keys.each do |k|
|
|
58
|
+
debug line[k]
|
|
66
59
|
end
|
|
60
|
+
rescue JSON::ParserError
|
|
61
|
+
# Docker For Mac is spitting out invalid JSON, so just print
|
|
62
|
+
# out the line if parsing fails.
|
|
63
|
+
debug line
|
|
67
64
|
end
|
|
68
65
|
end
|
|
69
66
|
end
|
|
@@ -79,14 +76,14 @@ subcommand_option_handling :normal
|
|
|
79
76
|
arguments :strict
|
|
80
77
|
|
|
81
78
|
def detect_version
|
|
82
|
-
if File.exist?(
|
|
83
|
-
base_version = File.read(
|
|
79
|
+
if File.exist?('VERSION') && !(base_commit = `git log --pretty='%h' VERSION | head -n 1`.strip).empty?
|
|
80
|
+
base_version = File.read('VERSION').strip
|
|
84
81
|
commits_since = `git log #{base_commit}..HEAD --pretty='%h'`.split("\n").size
|
|
85
82
|
hash = `git rev-parse --short HEAD`.strip
|
|
86
|
-
[[base_version, commits_since].join('.'), hash].join(
|
|
83
|
+
[[base_version, commits_since].join('.'), hash].join('-')
|
|
87
84
|
else
|
|
88
85
|
`git describe --long --tags --abbrev=7 --match 'v*.*.*' | sed -e 's/^v//'`.strip.tap do |version|
|
|
89
|
-
raise
|
|
86
|
+
raise 'No Git version (tag) for project' if version.empty?
|
|
90
87
|
end
|
|
91
88
|
end
|
|
92
89
|
end
|
|
@@ -121,41 +118,41 @@ end
|
|
|
121
118
|
|
|
122
119
|
def login_to_registry(appliance_image_id)
|
|
123
120
|
config_file = File.expand_path('~/.docker/config.json')
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
121
|
+
return unless File.exist? config_file
|
|
122
|
+
|
|
123
|
+
json_config = JSON.parse(File.read(config_file))
|
|
124
|
+
registry = appliance_image_id.split('/')[0]
|
|
125
|
+
|
|
126
|
+
json_auth = json_config['auths'][registry]['auth']
|
|
127
|
+
return unless json_auth
|
|
128
|
+
|
|
129
|
+
username, password = Base64.decode64(json_auth).split(':')
|
|
130
|
+
Docker.authenticate! username:, password:, serveraddress: registry
|
|
134
131
|
end
|
|
135
132
|
|
|
136
|
-
desc
|
|
137
|
-
long_desc
|
|
138
|
-
Reliable builds depend on having a clean working directory.
|
|
133
|
+
desc 'Clean current working directory of non-Git-managed files'
|
|
134
|
+
long_desc <<~DESC
|
|
135
|
+
Reliable builds depend on having a clean working directory.
|
|
139
136
|
|
|
140
|
-
Because debify runs some commands in volume-mounted Docker containers,
|
|
141
|
-
it is capable of creating root-owned files.
|
|
137
|
+
Because debify runs some commands in volume-mounted Docker containers,
|
|
138
|
+
it is capable of creating root-owned files.
|
|
142
139
|
|
|
143
|
-
This command will delete all files in the working directory that are not
|
|
144
|
-
git-managed. The command is designed to run in Jenkins. Therefore, it will
|
|
145
|
-
only perform file deletion if:
|
|
140
|
+
This command will delete all files in the working directory that are not
|
|
141
|
+
git-managed. The command is designed to run in Jenkins. Therefore, it will
|
|
142
|
+
only perform file deletion if:
|
|
146
143
|
|
|
147
|
-
* The current user, as provided by Etc.getlogin, is 'jenkins'
|
|
148
|
-
* The BUILD_NUMBER environment variable is set
|
|
144
|
+
* The current user, as provided by Etc.getlogin, is 'jenkins'
|
|
145
|
+
* The BUILD_NUMBER environment variable is set
|
|
149
146
|
|
|
150
|
-
File deletion can be compelled using the "force" option.
|
|
147
|
+
File deletion can be compelled using the "force" option.
|
|
151
148
|
DESC
|
|
152
|
-
arg_name
|
|
153
|
-
command
|
|
154
|
-
c.desc
|
|
155
|
-
c.flag [:d,
|
|
149
|
+
arg_name 'project-name -- <fpm-arguments>'
|
|
150
|
+
command 'clean' do |c|
|
|
151
|
+
c.desc 'Set the current working directory'
|
|
152
|
+
c.flag [:d, 'dir']
|
|
156
153
|
|
|
157
154
|
c.desc "Ignore (don't delete) a file or directory"
|
|
158
|
-
c.flag [
|
|
155
|
+
c.flag %i[i ignore]
|
|
159
156
|
|
|
160
157
|
c.desc "Force file deletion even if if this doesn't look like a Jenkins environment"
|
|
161
158
|
c.switch [:force]
|
|
@@ -168,9 +165,7 @@ command "clean" do |c|
|
|
|
168
165
|
|
|
169
166
|
require 'set'
|
|
170
167
|
perform_deletion = cmd_options[:force] || looks_like_jenkins?
|
|
171
|
-
unless perform_deletion
|
|
172
|
-
$stderr.puts "No --force, and this doesn't look like Jenkins. I won't actually delete anything"
|
|
173
|
-
end
|
|
168
|
+
warn "No --force, and this doesn't look like Jenkins. I won't actually delete anything" unless perform_deletion
|
|
174
169
|
@ignore_list = Array(cmd_options[:ignore]) + %w[. .. .git]
|
|
175
170
|
|
|
176
171
|
def ignore_file?(f)
|
|
@@ -187,16 +182,16 @@ command "clean" do |c|
|
|
|
187
182
|
end
|
|
188
183
|
find_files.compact!
|
|
189
184
|
delete_files = (find_files - git_files)
|
|
190
|
-
delete_files.delete_if
|
|
185
|
+
delete_files.delete_if do |file|
|
|
191
186
|
File.directory?(file) || ignore_file?(file)
|
|
192
|
-
|
|
187
|
+
end
|
|
193
188
|
if perform_deletion
|
|
194
|
-
image = Docker::Image.create 'fromImage' =>
|
|
189
|
+
image = Docker::Image.create 'fromImage' => 'alpine:3.19.0'
|
|
195
190
|
options = {
|
|
196
|
-
'Cmd' => [
|
|
191
|
+
'Cmd' => ['sh', '-c', 'while true; do sleep 1; done'],
|
|
197
192
|
'Image' => image.id,
|
|
198
193
|
'Binds' => [
|
|
199
|
-
[dir,
|
|
194
|
+
[dir, '/src'].join(':')
|
|
200
195
|
]
|
|
201
196
|
}
|
|
202
197
|
options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
|
|
@@ -207,10 +202,10 @@ command "clean" do |c|
|
|
|
207
202
|
puts file
|
|
208
203
|
|
|
209
204
|
file = "/src/#{file}"
|
|
210
|
-
cmd = [
|
|
205
|
+
cmd = ['rm', '-f', file]
|
|
211
206
|
|
|
212
207
|
_, _, status = container.exec cmd, &DebugMixin::DOCKER
|
|
213
|
-
|
|
208
|
+
warn "Failed to delete #{file}" unless status == 0
|
|
214
209
|
end
|
|
215
210
|
ensure
|
|
216
211
|
container.delete force: true
|
|
@@ -235,80 +230,77 @@ def copy_packages_from_container(container, package_name, dev_package_name)
|
|
|
235
230
|
end
|
|
236
231
|
end
|
|
237
232
|
|
|
238
|
-
desc
|
|
239
|
-
long_desc
|
|
240
|
-
The package is built using fpm (https://github.com/jordansissel/fpm).
|
|
233
|
+
desc 'Build a debian package for a project'
|
|
234
|
+
long_desc <<~DESC
|
|
235
|
+
The package is built using fpm (https://github.com/jordansissel/fpm).
|
|
241
236
|
|
|
242
|
-
The project directory is required to contain:
|
|
237
|
+
The project directory is required to contain:
|
|
243
238
|
|
|
244
|
-
* A Gemfile and Gemfile.lock
|
|
245
|
-
* A shell script called debify.sh
|
|
239
|
+
* A Gemfile and Gemfile.lock
|
|
240
|
+
* A shell script called debify.sh
|
|
246
241
|
|
|
247
|
-
debify.sh is invoked by the package build process to create any custom
|
|
248
|
-
files, other than the project source tree. For example, config files can be
|
|
249
|
-
created in /opt/conjur/etc.
|
|
242
|
+
debify.sh is invoked by the package build process to create any custom
|
|
243
|
+
files, other than the project source tree. For example, config files can be
|
|
244
|
+
created in /opt/conjur/etc.
|
|
250
245
|
|
|
251
|
-
The distrib folder in the project source tree is intended to create scripts
|
|
252
|
-
for package pre-install, post-install etc. The distrib folder is not included
|
|
253
|
-
in the deb package, so its contents should be copied to the file system or
|
|
254
|
-
packaged using fpm arguments.
|
|
246
|
+
The distrib folder in the project source tree is intended to create scripts
|
|
247
|
+
for package pre-install, post-install etc. The distrib folder is not included
|
|
248
|
+
in the deb package, so its contents should be copied to the file system or
|
|
249
|
+
packaged using fpm arguments.
|
|
255
250
|
|
|
256
|
-
All arguments to this command which follow the double-dash are propagated to
|
|
257
|
-
the fpm command.
|
|
251
|
+
All arguments to this command which follow the double-dash are propagated to
|
|
252
|
+
the fpm command.
|
|
258
253
|
DESC
|
|
259
|
-
arg_name
|
|
260
|
-
command
|
|
261
|
-
c.desc
|
|
262
|
-
c.flag [:d,
|
|
254
|
+
arg_name 'project-name -- <fpm-arguments>'
|
|
255
|
+
command 'package' do |c|
|
|
256
|
+
c.desc 'Set the current working directory'
|
|
257
|
+
c.flag [:d, 'dir']
|
|
263
258
|
|
|
264
|
-
c.desc
|
|
265
|
-
c.flag [
|
|
259
|
+
c.desc 'Set the output file type of the fpm command (e.g rpm)'
|
|
260
|
+
c.flag %i[o output]
|
|
266
261
|
|
|
267
262
|
c.desc "Specify the deb version; by default, it's read from the VERSION file"
|
|
268
|
-
c.flag [
|
|
263
|
+
c.flag %i[v version]
|
|
269
264
|
|
|
270
|
-
c.desc
|
|
265
|
+
c.desc 'Specify a custom Dockerfile.fpm'
|
|
271
266
|
c.flag [:dockerfile]
|
|
272
267
|
|
|
273
|
-
c.desc
|
|
268
|
+
c.desc 'Specify files to add to the FPM image that are not included from the git repo'
|
|
274
269
|
c.flag [:'additional-files']
|
|
275
270
|
|
|
276
|
-
c.desc
|
|
277
|
-
c.default_value
|
|
278
|
-
c.flag [
|
|
271
|
+
c.desc 'Image name'
|
|
272
|
+
c.default_value 'cyberark/ubuntu-ruby-builder'
|
|
273
|
+
c.flag %i[i image]
|
|
279
274
|
|
|
280
|
-
c.desc
|
|
281
|
-
c.default_value
|
|
282
|
-
c.flag [
|
|
275
|
+
c.desc 'Image tag, e.g. 4.5-stable, 4.6-stable'
|
|
276
|
+
c.default_value 'latest'
|
|
277
|
+
c.flag %i[t image-tag]
|
|
283
278
|
|
|
284
279
|
c.action do |_, cmd_options, args|
|
|
285
|
-
raise
|
|
280
|
+
raise 'project-name is required' unless (project_name = args.shift)
|
|
286
281
|
|
|
287
282
|
fpm_args = []
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
raise "Unexpected argument '#{delimeter}'"
|
|
292
|
-
end
|
|
283
|
+
raise "Unexpected argument '#{delimeter}'" unless (delimeter = args.shift) == '--'
|
|
284
|
+
|
|
285
|
+
fpm_args = args.dup
|
|
293
286
|
|
|
294
287
|
dir = cmd_options[:dir] || '.'
|
|
295
288
|
pwd = File.dirname(__FILE__)
|
|
296
289
|
|
|
297
290
|
additional_files = []
|
|
298
|
-
if cmd_options[:'additional-files']
|
|
299
|
-
additional_files = cmd_options[:'additional-files'].split(',').map(&:strip)
|
|
300
|
-
end
|
|
291
|
+
additional_files = cmd_options[:'additional-files'].split(',').map(&:strip) if cmd_options[:'additional-files']
|
|
301
292
|
|
|
302
293
|
dockerfile = File.read(File.expand_path('fpm/Dockerfile.template', File.dirname(__FILE__)))
|
|
303
|
-
replace_image = dockerfile.gsub(
|
|
304
|
-
File.open(File.expand_path('fpm/Dockerfile', File.dirname(__FILE__)),
|
|
294
|
+
replace_image = dockerfile.gsub('@@image@@', cmd_options[:image] + ':' + cmd_options[:'image-tag'])
|
|
295
|
+
File.open(File.expand_path('fpm/Dockerfile', File.dirname(__FILE__)), 'w') { |file| file.puts replace_image }
|
|
305
296
|
|
|
306
297
|
begin
|
|
307
298
|
tries ||= 2
|
|
308
|
-
fpm_image = Docker::Image.build_from_dir File.expand_path('fpm', File.dirname(__FILE__)),
|
|
309
|
-
|
|
299
|
+
fpm_image = Docker::Image.build_from_dir File.expand_path('fpm', File.dirname(__FILE__)),
|
|
300
|
+
architecture: 'x86_64', tag: 'debify-fpm', &DebugMixin::DOCKER
|
|
301
|
+
rescue StandardError
|
|
310
302
|
image_id = File.readlines(File.expand_path('fpm/Dockerfile', File.dirname(__FILE__)))
|
|
311
|
-
.find { |
|
|
303
|
+
.find { |line| line =~ /^FROM/ }
|
|
312
304
|
.split(' ')
|
|
313
305
|
.last
|
|
314
306
|
login_to_registry image_id
|
|
@@ -333,13 +325,13 @@ command "package" do |c|
|
|
|
333
325
|
end
|
|
334
326
|
|
|
335
327
|
# rename specified dockerfile to 'Dockerfile' during copy, incase name is different
|
|
336
|
-
dockerfile_path = cmd_options[:dockerfile] || File.expand_path(
|
|
337
|
-
temp_dockerfile = File.join(temp_dir,
|
|
328
|
+
dockerfile_path = cmd_options[:dockerfile] || File.expand_path('debify/Dockerfile.fpm', pwd)
|
|
329
|
+
temp_dockerfile = File.join(temp_dir, 'Dockerfile')
|
|
338
330
|
|
|
339
331
|
# change image variable in specified Dockerfile
|
|
340
332
|
dockerfile = File.read(dockerfile_path)
|
|
341
|
-
replace_image = dockerfile.gsub(
|
|
342
|
-
File.open(temp_dockerfile,
|
|
333
|
+
replace_image = dockerfile.gsub('@@image@@', fpm_image.id)
|
|
334
|
+
File.open(temp_dockerfile, 'w') { |file| file.puts replace_image }
|
|
343
335
|
|
|
344
336
|
# build image from project being debified dir
|
|
345
337
|
image = Docker::Image.build_from_dir temp_dir, &DebugMixin::DOCKER
|
|
@@ -363,7 +355,9 @@ command "package" do |c|
|
|
|
363
355
|
container = Docker::Container.create options
|
|
364
356
|
begin
|
|
365
357
|
DebugMixin.debug_write "Packaging #{project_name} in container #{container.id}\n"
|
|
366
|
-
container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true)
|
|
358
|
+
container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true) do |_, chunk|
|
|
359
|
+
warn "#{chunk}"
|
|
360
|
+
end
|
|
367
361
|
status = container.wait
|
|
368
362
|
raise "Failed to package #{project_name}" unless status['StatusCode'] == 0
|
|
369
363
|
|
|
@@ -380,11 +374,11 @@ command "package" do |c|
|
|
|
380
374
|
end
|
|
381
375
|
|
|
382
376
|
def determine_file_path(file_type, architecture_map, project_name, version)
|
|
383
|
-
if file_type ==
|
|
377
|
+
if file_type == 'deb'
|
|
384
378
|
architecture = architecture_map[file_type]
|
|
385
379
|
file_path = "conjur-#{project_name}_#{version}_#{architecture}.#{file_type}"
|
|
386
380
|
dev_file_path = "conjur-#{project_name}-dev_#{version}_#{architecture}.#{file_type}"
|
|
387
|
-
elsif file_type ==
|
|
381
|
+
elsif file_type == 'rpm'
|
|
388
382
|
architecture = architecture_map[file_type]
|
|
389
383
|
|
|
390
384
|
# The rpm builder replaces dashes with underscores in the version
|
|
@@ -407,22 +401,22 @@ end
|
|
|
407
401
|
|
|
408
402
|
def wait_for_conjur(container)
|
|
409
403
|
container_command container, '/opt/conjur/evoke/bin/wait_for_conjur'
|
|
410
|
-
rescue
|
|
411
|
-
|
|
404
|
+
rescue StandardError
|
|
405
|
+
warn container.logs(stdout: true, stderr: true)
|
|
412
406
|
raise
|
|
413
407
|
end
|
|
414
408
|
|
|
415
409
|
def network_options(cmd)
|
|
416
|
-
cmd.desc
|
|
417
|
-
cmd.flag [
|
|
410
|
+
cmd.desc 'Specify link for test container'
|
|
411
|
+
cmd.flag %i[l link], multiple: true
|
|
418
412
|
|
|
419
413
|
cmd.desc 'Attach to the specified network'
|
|
420
|
-
cmd.flag [
|
|
414
|
+
cmd.flag %i[n net]
|
|
421
415
|
end
|
|
422
416
|
|
|
423
417
|
def short_id(id)
|
|
424
418
|
if id =~ /\A[0-9a-f]{64}\z/ # 64 hex digits, docker only allows lower case letters in ids
|
|
425
|
-
|
|
419
|
+
warn "Warning: found full container id, using short id instead (#{id[0..11]} for #{id})"
|
|
426
420
|
id[0..11]
|
|
427
421
|
else
|
|
428
422
|
id
|
|
@@ -459,59 +453,59 @@ def add_network_config(container_config, cmd_options)
|
|
|
459
453
|
end
|
|
460
454
|
end
|
|
461
455
|
|
|
462
|
-
desc
|
|
463
|
-
long_desc
|
|
464
|
-
First, a Conjur appliance container is created and started. By default, the
|
|
465
|
-
container image is registry.tld/conjur-appliance-cuke-master. An image tag
|
|
466
|
-
MUST be supplied. This image is configured with all the CONJUR_ environment
|
|
467
|
-
variables setup for the local environment (appliance URL, cert path, admin username and
|
|
468
|
-
password, etc). The project source tree is also mounted into the container, at
|
|
469
|
-
/src/<project-name>.
|
|
456
|
+
desc 'Test a Conjur debian package in a Conjur appliance container'
|
|
457
|
+
long_desc <<~DESC
|
|
458
|
+
First, a Conjur appliance container is created and started. By default, the
|
|
459
|
+
container image is registry.tld/conjur-appliance-cuke-master. An image tag
|
|
460
|
+
MUST be supplied. This image is configured with all the CONJUR_ environment
|
|
461
|
+
variables setup for the local environment (appliance URL, cert path, admin username and
|
|
462
|
+
password, etc). The project source tree is also mounted into the container, at
|
|
463
|
+
/src/<project-name>.
|
|
470
464
|
|
|
471
|
-
This command then waits for Conjur to initialize and be healthy. It proceeds by
|
|
472
|
-
installing the conjur-<project-name>_<version>_amd64.deb from the project working directory.
|
|
465
|
+
This command then waits for Conjur to initialize and be healthy. It proceeds by
|
|
466
|
+
installing the conjur-<project-name>_<version>_amd64.deb from the project working directory.
|
|
473
467
|
|
|
474
|
-
Then the evoke "test-install" command is used to install the test code in the
|
|
475
|
-
/src/<project-name>. Basically, the development bundle is installed and the database
|
|
476
|
-
configuration (if any) is setup.
|
|
468
|
+
Then the evoke "test-install" command is used to install the test code in the
|
|
469
|
+
/src/<project-name>. Basically, the development bundle is installed and the database
|
|
470
|
+
configuration (if any) is setup.
|
|
477
471
|
|
|
478
|
-
Finally, a test script from the project source tree is run, again with the container
|
|
479
|
-
id as the program argument.
|
|
472
|
+
Finally, a test script from the project source tree is run, again with the container
|
|
473
|
+
id as the program argument.
|
|
480
474
|
|
|
481
|
-
Then the Conjur container is deleted (use --keep to leave it running).
|
|
475
|
+
Then the Conjur container is deleted (use --keep to leave it running).
|
|
482
476
|
DESC
|
|
483
|
-
arg_name
|
|
484
|
-
command
|
|
485
|
-
c.desc
|
|
486
|
-
c.flag [
|
|
477
|
+
arg_name 'project-name test-script'
|
|
478
|
+
command 'test' do |c|
|
|
479
|
+
c.desc 'Set the current working directory'
|
|
480
|
+
c.flag %i[d dir]
|
|
487
481
|
|
|
488
|
-
c.desc
|
|
482
|
+
c.desc 'Keep the Conjur appliance container after the command finishes'
|
|
489
483
|
c.default_value false
|
|
490
|
-
c.switch [
|
|
484
|
+
c.switch %i[k keep]
|
|
491
485
|
|
|
492
|
-
c.desc
|
|
493
|
-
c.default_value
|
|
494
|
-
c.flag [
|
|
486
|
+
c.desc 'Image name'
|
|
487
|
+
c.default_value 'registry.tld/conjur-appliance-cuke-master'
|
|
488
|
+
c.flag %i[i image]
|
|
495
489
|
|
|
496
|
-
c.desc
|
|
497
|
-
c.flag [:t,
|
|
490
|
+
c.desc 'Image tag, e.g. 4.5-stable, 4.6-stable'
|
|
491
|
+
c.flag [:t, 'image-tag']
|
|
498
492
|
|
|
499
493
|
c.desc "'docker pull' the Conjur container image"
|
|
500
494
|
c.default_value true
|
|
501
495
|
c.switch [:pull]
|
|
502
496
|
|
|
503
497
|
c.desc "Specify the deb version; by default, it's read from the VERSION file"
|
|
504
|
-
c.flag [
|
|
498
|
+
c.flag %i[v version]
|
|
505
499
|
|
|
506
|
-
c.desc
|
|
507
|
-
c.flag [:'volumes-from'], :
|
|
500
|
+
c.desc 'Specify volume for test container'
|
|
501
|
+
c.flag [:'volumes-from'], multiple: true
|
|
508
502
|
|
|
509
503
|
network_options(c)
|
|
510
504
|
|
|
511
505
|
c.action do |global_options, cmd_options, args|
|
|
512
|
-
raise
|
|
513
|
-
raise
|
|
514
|
-
raise
|
|
506
|
+
raise 'project-name is required' unless (project_name = args.shift)
|
|
507
|
+
raise 'test-script is required' unless (test_script = args.shift)
|
|
508
|
+
raise 'Received extra command-line arguments' if args.shift
|
|
515
509
|
|
|
516
510
|
dir = cmd_options[:dir] || '.'
|
|
517
511
|
dir = File.expand_path(dir)
|
|
@@ -520,8 +514,8 @@ command "test" do |c|
|
|
|
520
514
|
raise "Directory #{dir} does not contain a .deb file" unless Dir["#{dir}/*.deb"].length >= 1
|
|
521
515
|
|
|
522
516
|
Dir.chdir dir do
|
|
523
|
-
image_tag = cmd_options[
|
|
524
|
-
appliance_image_id = [cmd_options[:image], image_tag].join(
|
|
517
|
+
image_tag = cmd_options['image-tag'] or raise 'image-tag is required'
|
|
518
|
+
appliance_image_id = [cmd_options[:image], image_tag].join(':')
|
|
525
519
|
version = cmd_options[:version] || detect_version
|
|
526
520
|
package_name = "conjur-#{project_name}_#{version}_amd64.deb"
|
|
527
521
|
dev_package_name = "conjur-#{project_name}-dev_#{version}_amd64.deb"
|
|
@@ -531,24 +525,23 @@ command "test" do |c|
|
|
|
531
525
|
begin
|
|
532
526
|
tries ||= 2
|
|
533
527
|
Docker::Image.create 'fromImage' => appliance_image_id, &DebugMixin::DOCKER if cmd_options[:pull]
|
|
534
|
-
rescue
|
|
528
|
+
rescue StandardError
|
|
535
529
|
login_to_registry appliance_image_id
|
|
536
530
|
retry unless (tries -= 1).zero?
|
|
537
531
|
end
|
|
538
532
|
|
|
539
|
-
|
|
540
533
|
def build_test_image(appliance_image_id, project_name, packages)
|
|
541
|
-
packages = packages.join
|
|
542
|
-
dockerfile =
|
|
543
|
-
FROM #{appliance_image_id}
|
|
534
|
+
packages = packages.join ' '
|
|
535
|
+
dockerfile = <<~DOCKERFILE
|
|
536
|
+
FROM #{appliance_image_id}
|
|
544
537
|
|
|
545
|
-
COPY #{packages} /tmp/
|
|
538
|
+
COPY #{packages} /tmp/
|
|
546
539
|
|
|
547
|
-
RUN if dpkg --list | grep conjur-#{project_name}; then dpkg --force all --purge conjur-#{project_name}; fi
|
|
548
|
-
RUN if [ -f /opt/conjur/etc/#{project_name}.conf ]; then rm /opt/conjur/etc/#{project_name}.conf; fi
|
|
549
|
-
RUN cd /tmp; dpkg --install #{packages}
|
|
540
|
+
RUN if dpkg --list | grep conjur-#{project_name}; then dpkg --force all --purge conjur-#{project_name}; fi
|
|
541
|
+
RUN if [ -f /opt/conjur/etc/#{project_name}.conf ]; then rm /opt/conjur/etc/#{project_name}.conf; fi
|
|
542
|
+
RUN cd /tmp; dpkg --install #{packages}
|
|
550
543
|
|
|
551
|
-
RUN touch /etc/service/conjur/down
|
|
544
|
+
RUN touch /etc/service/conjur/down
|
|
552
545
|
DOCKERFILE
|
|
553
546
|
Dir.mktmpdir do |tmpdir|
|
|
554
547
|
tmpfile = Tempfile.new('Dockerfile', tmpdir)
|
|
@@ -557,7 +550,7 @@ RUN touch /etc/service/conjur/down
|
|
|
557
550
|
tar_cmd = "tar -cvzh -C #{tmpdir} #{dockerfile_name} -C #{Dir.pwd} #{packages}"
|
|
558
551
|
tar = open("| #{tar_cmd}")
|
|
559
552
|
begin
|
|
560
|
-
Docker::Image.build_from_tar(tar, :
|
|
553
|
+
Docker::Image.build_from_tar(tar, dockerfile: dockerfile_name, &DebugMixin::DOCKER)
|
|
561
554
|
ensure
|
|
562
555
|
tar.close
|
|
563
556
|
end
|
|
@@ -570,7 +563,7 @@ RUN touch /etc/service/conjur/down
|
|
|
570
563
|
begin
|
|
571
564
|
tries ||= 2
|
|
572
565
|
appliance_image = build_test_image(appliance_image_id, project_name, packages)
|
|
573
|
-
rescue
|
|
566
|
+
rescue StandardError
|
|
574
567
|
login_to_registry appliance_image_id
|
|
575
568
|
retry unless (tries -= 1).zero?
|
|
576
569
|
end
|
|
@@ -597,7 +590,10 @@ RUN touch /etc/service/conjur/down
|
|
|
597
590
|
host_config = options['HostConfig']
|
|
598
591
|
|
|
599
592
|
host_config['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
|
|
600
|
-
|
|
593
|
+
if cmd_options[:'volumes-from'] && !cmd_options[:'volumes-from'].empty?
|
|
594
|
+
host_config['VolumesFrom'] =
|
|
595
|
+
cmd_options[:'volumes-from']
|
|
596
|
+
end
|
|
601
597
|
|
|
602
598
|
add_network_config(options, cmd_options)
|
|
603
599
|
|
|
@@ -607,21 +603,24 @@ RUN touch /etc/service/conjur/down
|
|
|
607
603
|
.push([dot_bundle_dir, "/src/#{project_name}/.bundle"].join(':'))
|
|
608
604
|
end
|
|
609
605
|
|
|
610
|
-
container = Docker::Container.create(options.tap
|
|
606
|
+
container = Docker::Container.create(options.tap do |o|
|
|
607
|
+
DebugMixin.debug_write "creating container with options #{o.inspect}"
|
|
608
|
+
end)
|
|
611
609
|
|
|
612
610
|
begin
|
|
613
611
|
DebugMixin.debug_write "Testing #{project_name} in container #{container.id}\n"
|
|
614
612
|
|
|
615
|
-
spawn("docker logs -f #{container.id}", [
|
|
613
|
+
spawn("docker logs -f #{container.id}", %i[out err] => $stderr).tap do |pid|
|
|
616
614
|
Process.detach pid
|
|
617
615
|
end
|
|
618
616
|
container.start!
|
|
619
617
|
|
|
620
618
|
# Wait for pg/main so that migrations can run
|
|
621
619
|
30.times do
|
|
622
|
-
stdout, _, exitcode = container.exec %w
|
|
620
|
+
stdout, _, exitcode = container.exec %w[sv status pg/main], &DebugMixin::DOCKER
|
|
623
621
|
status = stdout.join
|
|
624
622
|
break if exitcode == 0 && status =~ /^run/
|
|
623
|
+
|
|
625
624
|
sleep 1
|
|
626
625
|
end
|
|
627
626
|
|
|
@@ -634,15 +633,15 @@ RUN touch /etc/service/conjur/down
|
|
|
634
633
|
|
|
635
634
|
DebugMixin.debug_write "Starting conjur\n"
|
|
636
635
|
|
|
637
|
-
container_command container,
|
|
638
|
-
container_command container,
|
|
636
|
+
container_command container, 'rm', '/etc/service/conjur/down'
|
|
637
|
+
container_command container, 'sv', 'start', 'conjur'
|
|
639
638
|
wait_for_conjur container
|
|
640
639
|
|
|
641
640
|
system "./#{test_script} #{container.id}"
|
|
642
641
|
exit_now! "#{test_script} failed with exit code #{$?.exitstatus}", $?.exitstatus unless $?.exitstatus == 0
|
|
643
642
|
ensure
|
|
644
643
|
unless cmd_options[:keep] || ENV['KEEP_CONTAINERS']
|
|
645
|
-
DebugMixin.debug_write
|
|
644
|
+
DebugMixin.debug_write 'deleting container'
|
|
646
645
|
container.delete(force: true)
|
|
647
646
|
end
|
|
648
647
|
end
|
|
@@ -650,30 +649,30 @@ RUN touch /etc/service/conjur/down
|
|
|
650
649
|
end
|
|
651
650
|
end
|
|
652
651
|
|
|
653
|
-
desc
|
|
654
|
-
long_desc
|
|
655
|
-
First, a Conjur appliance container is created and started. By default, the
|
|
656
|
-
container image is registry.tld/conjur-appliance-cuke-master. An image tag
|
|
657
|
-
MUST be supplied. This image is configured with all the CONJUR_ environment
|
|
658
|
-
variables setup for the local environment (appliance URL, cert path, admin username and
|
|
659
|
-
password, etc). The project source tree is also mounted into the container, at
|
|
660
|
-
/src/<project-name>, where <project-name> is taken from the name of the current working directory.
|
|
652
|
+
desc 'Setup a development sandbox for a Conjur debian package in a Conjur appliance container'
|
|
653
|
+
long_desc <<~DESC
|
|
654
|
+
First, a Conjur appliance container is created and started. By default, the
|
|
655
|
+
container image is registry.tld/conjur-appliance-cuke-master. An image tag
|
|
656
|
+
MUST be supplied. This image is configured with all the CONJUR_ environment
|
|
657
|
+
variables setup for the local environment (appliance URL, cert path, admin username and
|
|
658
|
+
password, etc). The project source tree is also mounted into the container, at
|
|
659
|
+
/src/<project-name>, where <project-name> is taken from the name of the current working directory.
|
|
661
660
|
|
|
662
|
-
Once in the container, use "/opt/conjur/evoke/bin/dev-install" to install the development bundle of your project.
|
|
661
|
+
Once in the container, use "/opt/conjur/evoke/bin/dev-install" to install the development bundle of your project.
|
|
663
662
|
DESC
|
|
664
|
-
command
|
|
665
|
-
c.desc
|
|
666
|
-
c.flag [
|
|
663
|
+
command 'sandbox' do |c|
|
|
664
|
+
c.desc 'Set the current working directory'
|
|
665
|
+
c.flag %i[d dir]
|
|
667
666
|
|
|
668
|
-
c.desc
|
|
669
|
-
c.default_value
|
|
670
|
-
c.flag [
|
|
667
|
+
c.desc 'Image name'
|
|
668
|
+
c.default_value 'registry.tld/conjur-appliance-cuke-master'
|
|
669
|
+
c.flag %i[i image]
|
|
671
670
|
|
|
672
|
-
c.desc
|
|
673
|
-
c.flag [:t,
|
|
671
|
+
c.desc 'Image tag, e.g. 4.5-stable, 4.6-stable'
|
|
672
|
+
c.flag [:t, 'image-tag']
|
|
674
673
|
|
|
675
|
-
c.desc
|
|
676
|
-
c.flag [:
|
|
674
|
+
c.desc 'Bind another source directory into the container. Use <src>:<dest>, where both are full paths.'
|
|
675
|
+
c.flag [:bind], multiple: true
|
|
677
676
|
|
|
678
677
|
c.desc "'docker pull' the Conjur container image"
|
|
679
678
|
c.default_value false
|
|
@@ -681,11 +680,11 @@ command "sandbox" do |c|
|
|
|
681
680
|
|
|
682
681
|
network_options(c)
|
|
683
682
|
|
|
684
|
-
c.desc
|
|
685
|
-
c.flag [:'volumes-from'], :
|
|
683
|
+
c.desc 'Specify volume for container'
|
|
684
|
+
c.flag [:'volumes-from'], multiple: true
|
|
686
685
|
|
|
687
|
-
c.desc
|
|
688
|
-
c.flag [
|
|
686
|
+
c.desc 'Expose a port from the container to host. Use <host>:<container>.'
|
|
687
|
+
c.flag %i[p port], multiple: true
|
|
689
688
|
|
|
690
689
|
c.desc 'Run dev-install in /src/<project-name>'
|
|
691
690
|
c.default_value false
|
|
@@ -696,10 +695,10 @@ command "sandbox" do |c|
|
|
|
696
695
|
c.switch [:kill]
|
|
697
696
|
|
|
698
697
|
c.desc 'A command to run in the sandbox'
|
|
699
|
-
c.flag [
|
|
698
|
+
c.flag %i[c command]
|
|
700
699
|
|
|
701
700
|
c.action do |global_options, cmd_options, args|
|
|
702
|
-
raise
|
|
701
|
+
raise 'Received extra command-line arguments' if args.shift
|
|
703
702
|
|
|
704
703
|
dir = cmd_options[:dir] || '.'
|
|
705
704
|
dir = File.expand_path(dir)
|
|
@@ -707,20 +706,23 @@ command "sandbox" do |c|
|
|
|
707
706
|
raise "Directory #{dir} does not exist or is not a directory" unless File.directory?(dir)
|
|
708
707
|
|
|
709
708
|
Dir.chdir dir do
|
|
710
|
-
image_tag = cmd_options[
|
|
711
|
-
appliance_image_id = [cmd_options[:image], image_tag].join(
|
|
709
|
+
image_tag = cmd_options['image-tag'] or raise 'image-tag is required'
|
|
710
|
+
appliance_image_id = [cmd_options[:image], image_tag].join(':')
|
|
712
711
|
|
|
713
712
|
appliance_image = if cmd_options[:pull]
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
713
|
+
begin
|
|
714
|
+
tries ||= 2
|
|
715
|
+
if cmd_options[:pull]
|
|
716
|
+
Docker::Image.create 'fromImage' => appliance_image_id,
|
|
717
|
+
&DebugMixin::DOCKER
|
|
718
|
+
end
|
|
719
|
+
rescue StandardError
|
|
720
|
+
login_to_registry appliance_image_id
|
|
721
|
+
retry unless (tries -= 1).zero?
|
|
722
|
+
end
|
|
723
|
+
else
|
|
724
|
+
Docker::Image.get appliance_image_id
|
|
725
|
+
end
|
|
724
726
|
|
|
725
727
|
project_name = File.basename(Dir.getwd)
|
|
726
728
|
vendor_dir = File.expand_path("tmp/debify/#{project_name}/vendor", ENV['HOME'])
|
|
@@ -742,8 +744,8 @@ command "sandbox" do |c|
|
|
|
742
744
|
|
|
743
745
|
options['HostConfig'] = host_config = {}
|
|
744
746
|
host_config['Binds'] = [
|
|
745
|
-
[File.expand_path(
|
|
746
|
-
[dir, "/src/#{project_name}"].join(':')
|
|
747
|
+
[File.expand_path('.ssh/id_rsa', ENV['HOME']), '/root/.ssh/id_rsa', 'ro'].join(':'),
|
|
748
|
+
[dir, "/src/#{project_name}"].join(':')
|
|
747
749
|
] + Array(cmd_options[:bind])
|
|
748
750
|
|
|
749
751
|
if global_options[:'local-bundle']
|
|
@@ -761,88 +763,92 @@ command "sandbox" do |c|
|
|
|
761
763
|
port_bindings = Hash.new({})
|
|
762
764
|
cmd_options[:port].each do |mapping|
|
|
763
765
|
hport, cport = mapping.split(':')
|
|
764
|
-
port_bindings["#{cport}/tcp"] = [{'HostPort' => hport}]
|
|
766
|
+
port_bindings["#{cport}/tcp"] = [{ 'HostPort' => hport }]
|
|
765
767
|
end
|
|
766
768
|
host_config['PortBindings'] = port_bindings
|
|
767
769
|
end
|
|
768
770
|
|
|
769
771
|
if cmd_options[:kill]
|
|
770
|
-
previous =
|
|
771
|
-
|
|
772
|
+
previous = begin
|
|
773
|
+
Docker::Container.get(options['name'])
|
|
774
|
+
rescue StandardError
|
|
775
|
+
nil
|
|
776
|
+
end
|
|
777
|
+
previous.delete(force: true) if previous
|
|
772
778
|
end
|
|
773
779
|
|
|
774
|
-
container = Docker::Container.create(options.tap
|
|
780
|
+
container = Docker::Container.create(options.tap do |o|
|
|
781
|
+
DebugMixin.debug_write "creating container with options #{o.inspect}"
|
|
782
|
+
end)
|
|
775
783
|
$stdout.puts container.id
|
|
776
784
|
container.start!
|
|
777
785
|
|
|
778
786
|
wait_for_conjur container
|
|
779
787
|
|
|
780
788
|
if cmd_options[:'dev-install']
|
|
781
|
-
container_command(container,
|
|
789
|
+
container_command(container, '/opt/conjur/evoke/bin/dev-install', project_name)
|
|
782
790
|
container_command(container, 'sv', 'restart', "conjur/#{project_name}")
|
|
783
791
|
end
|
|
784
792
|
|
|
785
|
-
if cmd_options[:command]
|
|
786
|
-
container_command(container, '/bin/bash', '-c', cmd_options[:command])
|
|
787
|
-
end
|
|
793
|
+
container_command(container, '/bin/bash', '-c', cmd_options[:command]) if cmd_options[:command]
|
|
788
794
|
end
|
|
789
795
|
end
|
|
790
796
|
end
|
|
791
797
|
|
|
792
|
-
desc
|
|
793
|
-
long_desc
|
|
794
|
-
Publishes a deb created with `debify package` to our private apt repository.
|
|
798
|
+
desc 'Publish a debian package to apt repository'
|
|
799
|
+
long_desc <<~DESC
|
|
800
|
+
Publishes a deb created with `debify package` to our private apt repository.
|
|
795
801
|
|
|
796
|
-
"distribution" should match the major/minor version of the Conjur appliance you want to install to.
|
|
802
|
+
"distribution" should match the major/minor version of the Conjur appliance you want to install to.
|
|
797
803
|
|
|
798
|
-
The package name is a required option. The package version can be specified as a CLI option, or it will
|
|
799
|
-
be auto-detected from Git.
|
|
804
|
+
The package name is a required option. The package version can be specified as a CLI option, or it will
|
|
805
|
+
be auto-detected from Git.
|
|
800
806
|
|
|
801
|
-
--component should be 'stable' if run after package tests pass or 'testing' if the package is not yet ready for release.
|
|
802
|
-
If you don't specify the component, it will be set to 'testing' unless the current git branch is 'master' or 'origin/master'.
|
|
803
|
-
The git branch is first detected from the env var GIT_BRANCH or BRANCH_NAME, and then by checking `git rev-parse --abbrev-ref HEAD`
|
|
804
|
-
(which won't give you the answer you want when detached).
|
|
807
|
+
--component should be 'stable' if run after package tests pass or 'testing' if the package is not yet ready for release.
|
|
808
|
+
If you don't specify the component, it will be set to 'testing' unless the current git branch is 'master' or 'origin/master'.
|
|
809
|
+
The git branch is first detected from the env var GIT_BRANCH or BRANCH_NAME, and then by checking `git rev-parse --abbrev-ref HEAD`
|
|
810
|
+
(which won't give you the answer you want when detached).
|
|
805
811
|
|
|
806
812
|
DESC
|
|
807
|
-
arg_name
|
|
808
|
-
command
|
|
809
|
-
c.desc
|
|
810
|
-
c.flag [
|
|
813
|
+
arg_name 'distribution project-name'
|
|
814
|
+
command 'publish' do |c|
|
|
815
|
+
c.desc 'Set the current working directory'
|
|
816
|
+
c.flag %i[d dir]
|
|
811
817
|
|
|
812
818
|
c.desc "Specify the deb package version; by default, it's computed automatically"
|
|
813
|
-
c.flag [
|
|
819
|
+
c.flag %i[v version]
|
|
814
820
|
|
|
815
821
|
c.desc "Component to publish to, either 'stable' or the name of the git branch"
|
|
816
|
-
c.flag [
|
|
822
|
+
c.flag %i[c component]
|
|
817
823
|
|
|
818
|
-
c.desc
|
|
819
|
-
c.default_value
|
|
820
|
-
c.flag [
|
|
824
|
+
c.desc 'Artifactory URL to publish to'
|
|
825
|
+
c.default_value 'https://conjurinc.jfrog.io/conjurinc'
|
|
826
|
+
c.flag %i[u url]
|
|
821
827
|
|
|
822
|
-
c.desc
|
|
823
|
-
c.default_value
|
|
824
|
-
c.flag [
|
|
828
|
+
c.desc 'Artifactory Debian repo to publish package to'
|
|
829
|
+
c.default_value 'debian-private'
|
|
830
|
+
c.flag %i[r repo]
|
|
825
831
|
|
|
826
|
-
c.desc
|
|
827
|
-
c.default_value
|
|
832
|
+
c.desc 'Artifactory RPM repo to publish package to'
|
|
833
|
+
c.default_value 'redhat-private'
|
|
828
834
|
c.flag ['rpm-repo']
|
|
829
835
|
|
|
830
836
|
c.action do |_, cmd_options, args|
|
|
831
837
|
require 'conjur/debify/action/publish'
|
|
832
|
-
raise
|
|
833
|
-
raise
|
|
834
|
-
raise
|
|
838
|
+
raise 'distribution is required' unless (distribution = args.shift)
|
|
839
|
+
raise 'project-name is required' unless (project_name = args.shift)
|
|
840
|
+
raise 'Received extra command-line arguments' if args.shift
|
|
835
841
|
|
|
836
842
|
Conjur::Debify::Action::Publish.new(distribution, project_name, cmd_options).run
|
|
837
843
|
end
|
|
838
844
|
end
|
|
839
845
|
|
|
840
|
-
desc
|
|
841
|
-
command
|
|
842
|
-
c.desc
|
|
843
|
-
c.flag [
|
|
846
|
+
desc 'Auto-detect and print the repository version'
|
|
847
|
+
command 'detect-version' do |c|
|
|
848
|
+
c.desc 'Set the current working directory'
|
|
849
|
+
c.flag %i[d dir]
|
|
844
850
|
c.action do |_, cmd_options, args|
|
|
845
|
-
raise
|
|
851
|
+
raise 'Received extra command-line arguments' if args.shift
|
|
846
852
|
|
|
847
853
|
dir = cmd_options[:dir] || '.'
|
|
848
854
|
dir = File.expand_path(dir)
|
|
@@ -860,7 +866,7 @@ arg_name 'configuration'
|
|
|
860
866
|
command 'config' do |c|
|
|
861
867
|
c.action do |_, _, args|
|
|
862
868
|
raise 'no configuration provided' unless (config = args.shift)
|
|
863
|
-
raise
|
|
869
|
+
raise 'Received extra command-line arguments' if args.shift
|
|
864
870
|
|
|
865
871
|
File.open(File.join('distrib', config)).each do |line|
|
|
866
872
|
puts line.gsub(/@@DEBIFY_VERSION@@/, Conjur::Debify::VERSION)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: conjur-debify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.3.pre.
|
|
4
|
+
version: 3.0.3.pre.145
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- CyberArk Software, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gli
|