pipedawg 0.1.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +83 -10
- data/lib/pipedawg/job.rb +1 -1
- data/lib/pipedawg/kaniko_job.rb +90 -0
- data/lib/pipedawg/pipeline.rb +4 -3
- data/lib/pipedawg/version.rb +1 -1
- data/lib/pipedawg.rb +1 -0
- metadata +4 -12
- data/.bundle/config +0 -4
- data/.gitignore +0 -15
- data/.gitlab-ci.yml +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -14
- data/.travis.yml +0 -6
- data/Gemfile +0 -14
- data/Rakefile +0 -8
- data/pipedawg.gemspec +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1df968015369cc666fc521d546b3194e82f04ec28b9a2473dbc2452b5c37780
|
4
|
+
data.tar.gz: 5afe211e7fb69ac10808af059e02dc5706c882ad86d2309901d2f943e0ec6a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7348909008c56e40d693f388da3b6eb8210c380a357c87c5e1cf906932a9c66246af77a9328f0746d70b2213943c95f73256d835b5163ca17348a9068998a5ac
|
7
|
+
data.tar.gz: 9f3b4d44c1e2e5e2b955ecd135ccdcfd100d15fbcc137f40dca0af2797a0aa3637444e2e75ec910ac428a953147d883ecb24414c6e10bba17dfb0d40f3881b70
|
data/README.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# pipedawg
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/pipedawg.svg)](https://rubygems.org/gems/pipedawg)
|
2
4
|
|
3
5
|
Generate GitLab CI pipelines.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
|
9
|
+
Install `pipedawg` with:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem install pipedawg
|
13
|
+
```
|
14
|
+
|
15
|
+
Or add this line to your application's Gemfile:
|
8
16
|
|
9
17
|
```ruby
|
10
18
|
gem 'pipedawg'
|
@@ -12,25 +20,90 @@ gem 'pipedawg'
|
|
12
20
|
|
13
21
|
And then execute:
|
14
22
|
|
15
|
-
|
23
|
+
```sh
|
24
|
+
bundle install
|
25
|
+
```
|
16
26
|
|
17
|
-
|
27
|
+
## Ruby library
|
18
28
|
|
19
|
-
|
29
|
+
Example:
|
20
30
|
|
21
|
-
|
31
|
+
```ruby
|
32
|
+
#!/usr/bin/env ruby
|
33
|
+
# frozen_string_literal: true
|
34
|
+
|
35
|
+
# print_pipeline.rb
|
36
|
+
require 'pipedawg'
|
37
|
+
|
38
|
+
gem_job = Pipedawg::Job.new(
|
39
|
+
'build:gem',
|
40
|
+
artifacts: ['*.gem'],
|
41
|
+
image: 'ruby',
|
42
|
+
script: ['bundle install', 'gem build *.gemspec']
|
43
|
+
)
|
44
|
+
|
45
|
+
kaniko_job = Pipedawg::KanikoJob.new(
|
46
|
+
'build:kaniko',
|
47
|
+
{needs: ['build:gem'], retry: 2},
|
48
|
+
{context:'${CI_PROJECT_DIR}/docker',external_files: {'*.gem':'gems'}}
|
49
|
+
)
|
50
|
+
|
51
|
+
pipeline = Pipedawg::Pipeline.new 'build:image', jobs: [gem_job, kaniko_job]
|
52
|
+
puts pipeline.to_yaml
|
53
|
+
```
|
22
54
|
|
55
|
+
```console
|
56
|
+
$ chmod +x print_pipeline.rb
|
57
|
+
$ ./print_pipeline.rb
|
58
|
+
---
|
59
|
+
stages:
|
60
|
+
- '1'
|
61
|
+
- '2'
|
62
|
+
workflow: {}
|
63
|
+
build:gem:
|
64
|
+
artifacts:
|
65
|
+
- "*.gem"
|
66
|
+
cache: {}
|
67
|
+
image: ruby
|
68
|
+
needs: []
|
69
|
+
rules: []
|
70
|
+
script:
|
71
|
+
- bundle install
|
72
|
+
- gem build *.gemspec
|
73
|
+
stage: '1'
|
74
|
+
tags: []
|
75
|
+
build:kaniko:
|
76
|
+
artifacts: {}
|
77
|
+
cache: {}
|
78
|
+
needs:
|
79
|
+
- build:gem
|
80
|
+
retry: 2
|
81
|
+
rules: []
|
82
|
+
script:
|
83
|
+
- echo "{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}"
|
84
|
+
> "/kaniko/.docker/config.json"
|
85
|
+
- cp "*.gem" "${CI_PROJECT_DIR}/docker/gems"
|
86
|
+
- '"/kaniko/executor" --context "${CI_PROJECT_DIR}/docker" --dockerfile "Dockerfile"
|
87
|
+
--no-push'
|
88
|
+
stage: '2'
|
89
|
+
tags: []
|
90
|
+
```
|
23
91
|
|
24
92
|
## Development
|
25
93
|
|
26
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
94
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. Run `bundle exec rubocop` to run the linter. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
95
|
+
|
96
|
+
Note that by default, Bundler will attempt to install gems to the system, e.g. `/usr/bin`, `/usr/share`, which requires elevated access and can interfere with files that are managed by the system's package manager. This behaviour can be overridden by creating the file `.bundle/config` and adding the following line:
|
97
|
+
```
|
98
|
+
BUNDLE_PATH: "./.bundle"
|
99
|
+
```
|
100
|
+
When you run `bin/setup` or `bundle install`, all gems will be installed inside the .bundle directory of this project.
|
27
101
|
|
28
|
-
To
|
102
|
+
To make this behaviour a default for all gem projects, the above line can be added to the user's bundle config file in their home directory (`~/.bundle/config`)
|
29
103
|
|
30
104
|
## Contributing
|
31
105
|
|
32
|
-
Bug reports and pull requests are welcome on GitHub
|
33
|
-
|
106
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/liger1978/pipedawg).
|
34
107
|
|
35
108
|
## License
|
36
109
|
|
data/lib/pipedawg/job.rb
CHANGED
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pipedawg
|
4
|
+
# kaniko_job class
|
5
|
+
class KanikoJob < Job
|
6
|
+
attr_accessor :kaniko_opts
|
7
|
+
|
8
|
+
def initialize(name = 'build', opts = {}, kaniko_opts = {}) # rubocop:disable Metrics/MethodLength
|
9
|
+
@kaniko_opts = {
|
10
|
+
build_args: {},
|
11
|
+
config: {
|
12
|
+
'$CI_REGISTRY': {
|
13
|
+
username: '$CI_REGISTRY_USER',
|
14
|
+
password: '$CI_REGISTRY_PASSWORD'
|
15
|
+
}
|
16
|
+
},
|
17
|
+
config_file: '/kaniko/.docker/config.json',
|
18
|
+
context: '${CI_PROJECT_DIR}',
|
19
|
+
destinations: [],
|
20
|
+
dockerfile: 'Dockerfile',
|
21
|
+
executor: '/kaniko/executor',
|
22
|
+
external_files: {},
|
23
|
+
flags: [],
|
24
|
+
ignore_paths: [],
|
25
|
+
insecure_registries: [],
|
26
|
+
kaniko_image: {
|
27
|
+
entrypoint: [''],
|
28
|
+
name: 'gcr.io/kaniko-project/executor:debug'
|
29
|
+
},
|
30
|
+
options: {},
|
31
|
+
registry_certificates: {},
|
32
|
+
registry_mirrors: [],
|
33
|
+
skip_tls_verify_registry: [],
|
34
|
+
trusted_ca_cert_source_files: [],
|
35
|
+
trusted_ca_cert_target_file: '/kaniko/ssl/certs/ca-certificates.crt'
|
36
|
+
}.merge(kaniko_opts)
|
37
|
+
super name, opts
|
38
|
+
update
|
39
|
+
end
|
40
|
+
|
41
|
+
def update # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
42
|
+
require 'json'
|
43
|
+
opts[:image] = kaniko_opts[:image]
|
44
|
+
script = ["echo #{kaniko_opts[:config].to_json.inspect} > \"#{kaniko_opts[:config_file]}\""]
|
45
|
+
cert_copies = Array(kaniko_opts[:trusted_ca_cert_source_files]).map do |cert|
|
46
|
+
"cat \"#{cert}\" >> \"#{kaniko_opts[:trusted_ca_cert_target_file]}\""
|
47
|
+
end
|
48
|
+
script.concat cert_copies
|
49
|
+
file_copies = kaniko_opts[:external_files].map do |source, dest|
|
50
|
+
"cp \"#{source}\" \"#{kaniko_opts[:context]}/#{dest}\""
|
51
|
+
end
|
52
|
+
script.concat file_copies
|
53
|
+
flags = kaniko_opts[:flags].clone
|
54
|
+
flags << 'no-push' if kaniko_opts[:destinations].empty?
|
55
|
+
flags_cli = flags.uniq.map { |f| "--#{f}" }.join(' ')
|
56
|
+
options_cli = kaniko_opts[:options].map { |k, v| "--#{k}=\"#{v}\"" }.join(' ')
|
57
|
+
build_args_cli = kaniko_opts[:build_args].map { |k, v| "--build-arg #{k}=\"#{v}\"" }.join(' ')
|
58
|
+
ignore_paths_cli = Array(kaniko_opts[:ignore_paths]).map { |p| "--ignore-path #{p}" }.join(' ')
|
59
|
+
insecure_registries_cli = Array(kaniko_opts[:insecure_registries]).map do |r|
|
60
|
+
"--insecure-registry #{r}"
|
61
|
+
end.join(' ')
|
62
|
+
registry_certificates_cli = kaniko_opts[:registry_certificates].map do |k, v|
|
63
|
+
"--registry-certificate #{k}=\"#{v}\""
|
64
|
+
end.join(' ')
|
65
|
+
registry_mirrors_cli = Array(kaniko_opts[:registry_mirrors]).map { |r| "--registry-mirror #{r}" }.join(' ')
|
66
|
+
skip_tls_verify_registrys_cli = Array(kaniko_opts[:skip_tls_verify_registry]).map do |r|
|
67
|
+
"--skip-tls-verify-registry #{r}"
|
68
|
+
end.join(' ')
|
69
|
+
destinations_cli = kaniko_opts[:destinations].map { |d| "--destination #{d}" }.join(' ')
|
70
|
+
kaniko_cmds = [
|
71
|
+
"\"#{kaniko_opts[:executor]}\"",
|
72
|
+
'--context',
|
73
|
+
"\"#{kaniko_opts[:context]}\"",
|
74
|
+
'--dockerfile',
|
75
|
+
"\"#{kaniko_opts[:dockerfile]}\"",
|
76
|
+
flags_cli,
|
77
|
+
options_cli,
|
78
|
+
build_args_cli,
|
79
|
+
ignore_paths_cli,
|
80
|
+
insecure_registries_cli,
|
81
|
+
registry_certificates_cli,
|
82
|
+
registry_mirrors_cli,
|
83
|
+
destinations_cli,
|
84
|
+
skip_tls_verify_registrys_cli
|
85
|
+
].reject(&:empty?)
|
86
|
+
script << kaniko_cmds.join(' ')
|
87
|
+
opts[:script] = script
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/pipedawg/pipeline.rb
CHANGED
@@ -10,8 +10,9 @@ module Pipedawg
|
|
10
10
|
@opts = {
|
11
11
|
jobs: [Pipedawg::Job.new],
|
12
12
|
stages: ['build'],
|
13
|
-
workflow:
|
13
|
+
workflow: nil
|
14
14
|
}.merge(opts)
|
15
|
+
update
|
15
16
|
end
|
16
17
|
|
17
18
|
def to_yaml
|
@@ -24,11 +25,11 @@ module Pipedawg
|
|
24
25
|
JSON.parse(pipeline.to_json).to_yaml
|
25
26
|
end
|
26
27
|
|
27
|
-
def to_yaml_file(file = '.
|
28
|
+
def to_yaml_file(file = 'pipeline.yml')
|
28
29
|
File.write(file, to_yaml)
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
+
def update
|
32
33
|
stages = []
|
33
34
|
opts[:jobs].each do |job|
|
34
35
|
stage = stage_from_needs(opts[:jobs], job.name)
|
data/lib/pipedawg/version.rb
CHANGED
data/lib/pipedawg.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipedawg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- harbottle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01
|
11
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generate GitLab CI pipelines.
|
14
14
|
email:
|
@@ -17,21 +17,13 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- ".bundle/config"
|
21
|
-
- ".gitignore"
|
22
|
-
- ".gitlab-ci.yml"
|
23
|
-
- ".rspec"
|
24
|
-
- ".rubocop.yml"
|
25
|
-
- ".travis.yml"
|
26
|
-
- Gemfile
|
27
20
|
- LICENSE.txt
|
28
21
|
- README.md
|
29
|
-
- Rakefile
|
30
22
|
- lib/pipedawg.rb
|
31
23
|
- lib/pipedawg/job.rb
|
24
|
+
- lib/pipedawg/kaniko_job.rb
|
32
25
|
- lib/pipedawg/pipeline.rb
|
33
26
|
- lib/pipedawg/version.rb
|
34
|
-
- pipedawg.gemspec
|
35
27
|
homepage: https://github.com/liger1978/pipedawg
|
36
28
|
licenses:
|
37
29
|
- MIT
|
@@ -54,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
46
|
- !ruby/object:Gem::Version
|
55
47
|
version: '0'
|
56
48
|
requirements: []
|
57
|
-
rubygems_version: 3.
|
49
|
+
rubygems_version: 3.1.2
|
58
50
|
signing_key:
|
59
51
|
specification_version: 4
|
60
52
|
summary: Generate GitLab CI pipelines.
|
data/.bundle/config
DELETED
data/.gitignore
DELETED
data/.gitlab-ci.yml
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in pipedawg.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem 'irb', '~> 1.4'
|
9
|
-
gem 'rake', '~> 12.0'
|
10
|
-
gem 'rdoc', '~> 6.4'
|
11
|
-
gem 'rspec', '~> 3.0'
|
12
|
-
gem 'rubocop', '~> 1.24', require: false
|
13
|
-
gem 'rubocop-rake', '~> 0.6', require: false
|
14
|
-
gem 'rubocop-rspec', '~> 2.7', require: false
|
data/Rakefile
DELETED
data/pipedawg.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'lib/pipedawg/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'pipedawg'
|
7
|
-
spec.version = Pipedawg::VERSION
|
8
|
-
spec.authors = ['harbottle']
|
9
|
-
spec.email = ['harbottle@room3d3.com']
|
10
|
-
|
11
|
-
spec.summary = 'Generate GitLab CI pipelines.'
|
12
|
-
spec.description = 'Generate GitLab CI pipelines.'
|
13
|
-
spec.homepage = 'https://github.com/liger1978/pipedawg'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
-
spec.metadata['source_code_uri'] = 'https://github.com/liger1978/pipedawg'
|
18
|
-
spec.metadata['changelog_uri'] = 'https://github.com/liger1978/pipedawg'
|
19
|
-
|
20
|
-
# Specify which files should be added to the gem when it is released.
|
21
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
-
end
|
25
|
-
spec.bindir = 'exe'
|
26
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = ['lib']
|
28
|
-
|
29
|
-
end
|