conjur-debify 0.0.1.pre.47 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -4
  3. data/LICENSE.txt +1 -1
  4. data/README.md +15 -210
  5. data/Rakefile +7 -14
  6. data/debify.gemspec +9 -18
  7. data/example/Gemfile +0 -8
  8. data/example/Gemfile.lock +0 -24
  9. data/example/test.sh +0 -1
  10. data/features/debify.feature +15 -0
  11. data/features/step_definitions/debify_steps.rb +0 -23
  12. data/features/support/env.rb +12 -5
  13. data/jenkins.sh +6 -0
  14. data/lib/conjur/debify/Dockerfile.fpm +4 -0
  15. data/lib/conjur/debify/version.rb +2 -2
  16. data/lib/conjur/debify.rb +154 -681
  17. data/lib/conjur/fpm/Dockerfile +5 -19
  18. data/lib/conjur/fpm/debify_utils.sh +8 -28
  19. data/lib/conjur/fpm/package.sh +23 -79
  20. metadata +36 -152
  21. data/.dockerignore +0 -1
  22. data/.rvmrc +0 -60
  23. data/CHANGELOG.md +0 -246
  24. data/CONTRIBUTING.md +0 -16
  25. data/Dockerfile +0 -33
  26. data/Jenkinsfile +0 -116
  27. data/VERSION +0 -1
  28. data/build.sh +0 -4
  29. data/ci/test.sh +0 -8
  30. data/distrib/conjur_creds.rb +0 -7
  31. data/distrib/docker-debify +0 -50
  32. data/distrib/entrypoint.sh +0 -19
  33. data/distrib/script +0 -1
  34. data/distrib/secrets +0 -1
  35. data/distrib/secrets.yml +0 -2
  36. data/example/docker-compose.yml +0 -11
  37. data/example/net-test.sh +0 -7
  38. data/features/detect_version.feature +0 -7
  39. data/features/package.feature +0 -23
  40. data/features/sandbox.feature +0 -23
  41. data/features/support/hooks.rb +0 -29
  42. data/features/support/world.rb +0 -10
  43. data/features/test.feature +0 -24
  44. data/image-tags +0 -23
  45. data/lib/conjur/debify/action/publish.rb +0 -136
  46. data/lib/conjur/debify/utils.rb +0 -16
  47. data/lib/conjur/publish/Dockerfile +0 -5
  48. data/publish-rubygem.sh +0 -10
  49. data/push-image.sh +0 -6
  50. data/secrets.yml +0 -3
  51. data/spec/action/publish_spec.rb +0 -54
  52. data/spec/data/Makefile +0 -5
  53. data/spec/data/test.tar +0 -0
  54. data/spec/debify_utils_spec.rb +0 -55
  55. data/spec/spec_helper.rb +0 -1
  56. data/spec/utils_spec.rb +0 -22
  57. data/tag-image.sh +0 -6
  58. data/test.sh +0 -6
data/image-tags DELETED
@@ -1,23 +0,0 @@
1
- #!/bin/bash -e
2
-
3
- : ${BRANCH_NAME:=$(git symbolic-ref --short HEAD)}
4
-
5
- show_master_tags() {
6
- IFS=. read MAJOR MINOR PATCH <<< "$(<VERSION)"
7
- TAG="$MAJOR.$MINOR.$PATCH"
8
- echo "latest $TAG $MAJOR.$MINOR"
9
- }
10
-
11
- show_branch_tags() {
12
- # tail and tr, to remove the grottiness from the detect-version
13
- # output
14
- local version="$(DEBIFY_IMAGE=debify:$(<VERSION) ./docker-debify detect-version | tail -1 | tr -d '\r')"
15
-
16
- echo "$BRANCH_NAME $version"
17
- }
18
-
19
- if [[ "$BRANCH_NAME" == "master" ]]; then
20
- show_master_tags
21
- else
22
- show_branch_tags
23
- fi
@@ -1,136 +0,0 @@
1
- module Conjur::Debify
2
- module Action
3
- class Publish
4
-
5
- def detect_component
6
- branch = ENV['GIT_BRANCH'] || ENV['BRANCH_NAME'] || `git rev-parse --abbrev-ref HEAD`.strip
7
- if %w(master origin/master).include?(branch)
8
- 'stable'
9
- else
10
- branch.gsub('/', '.')
11
- end
12
- end
13
-
14
- attr_reader :distribution, :project_name, :cmd_options
15
- def initialize(distribution, project_name, cmd_options)
16
- @distribution = distribution
17
- @project_name = project_name
18
- @cmd_options = cmd_options
19
- end
20
-
21
- def run
22
- dir = cmd_options[:dir] || '.'
23
- dir = File.expand_path(dir)
24
- raise "Directory #{dir} does not exist or is not a directory" unless File.directory?(dir)
25
-
26
- Dir.chdir dir do
27
- version = cmd_options[:version] || detect_version
28
-
29
- publish_image = create_image
30
- DebugMixin.debug_write "Built base publish image '#{publish_image.id}'\n"
31
-
32
- art_url = cmd_options[:url]
33
- deb_art_repo = cmd_options[:repo]
34
-
35
- art_user = ENV['ARTIFACTORY_USER']
36
- art_password = ENV['ARTIFACTORY_PASSWORD']
37
- unless art_user && art_password
38
- art_user, art_password = fetch_art_creds
39
- end
40
-
41
- # Publish deb package
42
- component = cmd_options[:component] || detect_component
43
- deb_info = "#{distribution}/#{component}/amd64"
44
- package_name = "conjur-#{project_name}_#{version}_amd64.deb"
45
- publish_package(
46
- publish_image: publish_image,
47
- art_url: art_url,
48
- art_user: art_user,
49
- art_password: art_password,
50
- art_repo: deb_art_repo,
51
- package_name: package_name,
52
- dir: dir,
53
- deb_info: deb_info
54
- )
55
-
56
- # Publish RPM package
57
- # The rpm builder replaces dashes with underscores in the version
58
- rpm_version = version.tr('-', '_')
59
- package_name = "conjur-#{project_name}-#{rpm_version}-1.x86_64.rpm"
60
- rpm_art_repo = cmd_options['rpm-repo']
61
- publish_package(
62
- publish_image: publish_image,
63
- art_url: art_url,
64
- art_user: art_user,
65
- art_password: art_password,
66
- art_repo: rpm_art_repo,
67
- package_name: package_name,
68
- dir: dir
69
- )
70
- end
71
- end
72
-
73
- def create_image
74
- Docker::Image.build_from_dir File.expand_path('../../publish', File.dirname(__FILE__)), tag: "debify-publish", &DebugMixin::DOCKER
75
- end
76
-
77
- def fetch_art_creds
78
- require 'conjur/cli'
79
- require 'conjur/authn'
80
- Conjur::Config.load
81
- Conjur::Config.apply
82
- conjur = Conjur::Authn.connect nil, noask: true
83
-
84
- account = Conjur.configuration.account
85
- username_var = [account, "variable", "ci/artifactory/users/jenkins/username"].join(':')
86
- password_var = [account, "variable", 'ci/artifactory/users/jenkins/password'].join(':')
87
- [conjur.resource(username_var).value, conjur.resource(password_var).value]
88
- end
89
-
90
- def publish_package(
91
- publish_image:,
92
- art_url:,
93
- art_user:,
94
- art_password:,
95
- art_repo:,
96
- package_name:,
97
- dir:,
98
- deb_info: nil
99
- )
100
-
101
- cmd_args = [
102
- "jfrog", "rt", "upload",
103
- "--url", art_url,
104
- "--user", art_user,
105
- "--password", art_password,
106
- ]
107
-
108
- cmd_args += ["--deb", deb_info] if deb_info
109
- cmd_args += [package_name, "#{art_repo}/"]
110
-
111
- options = {
112
- 'Image' => publish_image.id,
113
- 'Cmd' => cmd_args,
114
- 'Binds' => [
115
- [ dir, "/src" ].join(':')
116
- ]
117
- }
118
- options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
119
-
120
- publish(options)
121
- end
122
-
123
- def publish(options)
124
- container = Docker::Container.create(options)
125
- begin
126
- container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true) { |stream, chunk| puts "#{chunk}" }
127
- status = container.wait
128
- raise "Failed to publish package" unless status['StatusCode'] == 0
129
- ensure
130
- container.delete(force: true)
131
- end
132
- end
133
-
134
- end
135
- end
136
- end
@@ -1,16 +0,0 @@
1
- require 'rubygems/package'
2
-
3
- module Conjur::Debify::Utils
4
- module_function
5
-
6
- # copy a file from container to the current working directory
7
- def copy_from_container container, path
8
- tar = StringIO.new
9
- container.archive_out(path) { |chunk| tar.write chunk }
10
- tar.rewind
11
- Gem::Package::TarReader.new(tar).each do |entry|
12
- File.write entry.full_name, entry.read
13
- end
14
- end
15
- end
16
-
@@ -1,5 +0,0 @@
1
- FROM releases-docker.jfrog.io/jfrog/jfrog-cli:latest
2
-
3
- ENV JFROG_CLI_OFFER_CONFIG=false
4
-
5
- WORKDIR /src
data/publish-rubygem.sh DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
-
4
- docker run -i --rm -v $PWD:/src -w /src alpine/git clean -fxd \
5
- -e VERSION \
6
- -e bom-assets/ \
7
- -e release-assets/
8
-
9
- summon --yaml "RUBYGEMS_API_KEY: !var rubygems/api-key" \
10
- publish-rubygem debify
data/push-image.sh DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/bash -ex
2
-
3
- for t in $(./image-tags); do
4
- docker push registry.tld/conjurinc/debify:$t
5
- done
6
-
data/secrets.yml DELETED
@@ -1,3 +0,0 @@
1
- # Example of secrets.yml file needed for debify publish
2
- ARTIFACTORY_USERNAME: !var artifactory/users/jenkins/username
3
- ARTIFACTORY_PASSWORD: !var artifactory/users/jenkins/password
@@ -1,54 +0,0 @@
1
- require 'spec_helper'
2
- require 'conjur/debify/action/publish'
3
-
4
- describe Conjur::Debify::Action::Publish do
5
-
6
- let (:cmd_options) {
7
- {
8
- :version => '1.0.0',
9
- :component => 'stable'
10
- }
11
- }
12
-
13
- let (:action) { Conjur::Debify::Action::Publish.new('dist', 'proj', cmd_options) }
14
-
15
- before do
16
- allow(DebugMixin).to receive(:debug_write)
17
-
18
- allow(action).to receive(:create_image).and_return(double('publish_image', :id => 'a1b2c3d4'))
19
- end
20
-
21
- context 'with artifactory creds in the environment' do
22
-
23
- before do
24
- ENV['ARTIFACTORY_USER'] = 'art_user'
25
- ENV['ARTIFACTORY_PASSWORD'] = 'art_password'
26
- end
27
-
28
- after do
29
- ENV.delete('ARTIFACTORY_USER')
30
- ENV.delete('ARTIFACTORY_PASSWORD')
31
- end
32
-
33
- it 'runs' do
34
- expect(action).to receive(:publish).twice
35
-
36
- action.run
37
- end
38
-
39
- end
40
-
41
- context 'without artifactory creds in the environment' do
42
-
43
- it 'runs' do
44
- expect(action).to receive(:fetch_art_creds)
45
- expect(action).to receive(:publish).twice
46
-
47
- action.run
48
- end
49
- end
50
-
51
- end
52
-
53
-
54
-
data/spec/data/Makefile DELETED
@@ -1,5 +0,0 @@
1
- test.tar:
2
- echo "this is a test" > test.txt
3
- tar cf test.tar test.txt
4
- rm test.txt
5
-
data/spec/data/test.tar DELETED
Binary file
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
- require 'aruba/rspec'
3
-
4
- Aruba.configure do |c|
5
- c.activate_announcer_on_command_failure = %i(stderr stdout)
6
- end
7
-
8
- describe "remove_matching()", type: :aruba do
9
- it "removes matching files" do
10
- here %w(foo bar/baz bar/xyzzy zork)
11
- there %w(foo bar/baz not)
12
- remove_matching
13
- expect(contents_of herepath).to match_array %w(zork bar bar/xyzzy)
14
- end
15
-
16
- it "also handles files with spaces in names" do
17
- here ['foo', 'bar/baz', 'with space', 'with', 'bar/another space']
18
- there ['with space', 'bar/another space here']
19
- remove_matching
20
- expect(contents_of herepath).to match_array ['foo', 'bar', 'bar/baz', 'with', 'bar/another space']
21
- end
22
-
23
- # auxiliary methods and setup
24
- let(:herepath) { Pathname.new Dir.mktmpdir }
25
- let(:therepath) { Pathname.new Dir.mktmpdir }
26
- after { [herepath, therepath].each &FileUtils.method(:remove_entry) }
27
-
28
- def contents_of dir
29
- Dir.chdir(dir) { Dir['**/*'] }
30
- end
31
-
32
- def remove_matching
33
- run_command_and_stop "bash -c 'source #{DEBIFY_UTILS_PATH}; cd #{herepath}; remove_matching #{therepath}'"
34
- end
35
-
36
- def here files
37
- mkfiles herepath, files
38
- end
39
-
40
- def there files
41
- mkfiles therepath, files
42
- end
43
-
44
- def mkfiles dir, files
45
- return dir if files.empty?
46
- files.each do |path|
47
- fullpath = dir + path
48
- FileUtils.makedirs fullpath.dirname
49
- FileUtils.touch fullpath
50
- end
51
- end
52
-
53
- DEBIFY_UTILS_PATH = File.expand_path '../../lib/conjur/fpm/debify_utils.sh', __FILE__
54
- end
55
-
data/spec/spec_helper.rb DELETED
@@ -1 +0,0 @@
1
- require 'conjur/debify'
data/spec/utils_spec.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'fakefs/safe'
2
-
3
- require 'conjur/debify/utils'
4
-
5
- describe 'Conjur::Debify::Utils.copy_from_container' do
6
- it "copies a file from the container to the current directory" do
7
- tar = File.read "#{__dir__}/data/test.tar"
8
- container = instance_double Docker::Container
9
- allow(container).to receive(:archive_out).with "/tmp/test.tar" do |&b|
10
- StringIO.new(tar).each(nil, 512) do |c|
11
- # docker api sends three arguments, so emulate that
12
- b[c, nil, nil]
13
- end
14
- end
15
-
16
- FakeFS do
17
- Conjur::Debify::Utils.copy_from_container container, "/tmp/test.tar"
18
- expect(File.read 'test.txt').to eq "this is a test\n"
19
- end
20
- end
21
- end
22
-
data/tag-image.sh DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/bash -ex
2
-
3
- TAG=$(< VERSION)
4
- for t in $(./image-tags); do
5
- docker tag debify:$TAG registry.tld/conjurinc/debify:$t
6
- done
data/test.sh DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/bash -ex
2
-
3
- VERSION=$(< VERSION)
4
- docker run --rm debify:$VERSION config script > docker-debify
5
- chmod +x docker-debify
6
- DEBIFY_IMAGE=debify:$VERSION DEBIFY_ENTRYPOINT=ci/test.sh ./docker-debify