pipedawg 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pipedawg/helm_copy_job.rb +107 -0
- data/lib/pipedawg/kaniko_job.rb +2 -2
- data/lib/pipedawg/version.rb +1 -1
- data/lib/pipedawg.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 114b51a7224d92e384383b3485e96547a250ae90cc64a89250d7a45ff3ae35c0
|
4
|
+
data.tar.gz: 98eac24c50bdeb4282077b32e45afc87f9e8f3db01f47c5b837d36a9a3866ca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1504e970a5b8b629f5b95a92a8fd9edc4685d3d98adbf3f94631a0c0d4b12beaadb83a30b5337ba9ad03310956ce1c9e7924f6c04f968bca8287e0c45a69eb5e
|
7
|
+
data.tar.gz: 80e24f54810711abc38902ab44aae67499372f9d73c265aedc82d6d6bc2c3dd7d26f230195a435580674502bb40563e67810be18ebbb51bd2e35c4b735888fb0
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pipedawg
|
4
|
+
# helm_copy_job class
|
5
|
+
class HelmCopyJob < Job
|
6
|
+
attr_accessor :helm_opts
|
7
|
+
|
8
|
+
def initialize(name = 'build', opts = {}, helm_opts = {})
|
9
|
+
@helm_opts = {
|
10
|
+
chart: name,
|
11
|
+
destinations: [{ user: nil, password: nil, url: nil }],
|
12
|
+
helm: 'helm',
|
13
|
+
image: { entrypoint: [''], name: 'alpine/helm' },
|
14
|
+
password: nil, url: nil, user: nil, version: nil
|
15
|
+
}.merge(helm_opts)
|
16
|
+
super name, opts
|
17
|
+
update
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
opts[:image] = helm_opts[:image] if helm_opts[:image]
|
22
|
+
opts[:script] = [] + pull + (helm_opts[:destinations].map { |d| push(d) }).flatten(1)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def pull
|
28
|
+
case helm_opts[:url]
|
29
|
+
when nil
|
30
|
+
[]
|
31
|
+
when %r{^oci://}
|
32
|
+
pull_oci
|
33
|
+
else
|
34
|
+
pull_classic
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def push(destination)
|
39
|
+
case destination[:url]
|
40
|
+
when nil
|
41
|
+
[]
|
42
|
+
when %r{^oci://}
|
43
|
+
push_oci(destination)
|
44
|
+
else
|
45
|
+
push_classic(destination)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def pull_oci # rubocop:disable Metrics/AbcSize
|
50
|
+
script = []
|
51
|
+
if helm_opts[:url] && helm_opts[:chart] && helm_opts[:version]
|
52
|
+
script = ['export HELM_EXPERIMENTAL_OCI=1']
|
53
|
+
script << login_oci(helm_opts) if helm_opts[:user] && helm_opts[:password]
|
54
|
+
script << "\"#{helm_opts[:helm]}\" pull \"#{helm_opts[:url]}/#{helm_opts[:chart]}\" --version \"#{helm_opts[:version]}\"" # rubocop:disable Layout/LineLength
|
55
|
+
end
|
56
|
+
script
|
57
|
+
end
|
58
|
+
|
59
|
+
def push_oci(destination) # rubocop:disable Metrics/AbcSize
|
60
|
+
script = []
|
61
|
+
if destination[:url] && helm_opts[:chart] && helm_opts[:version]
|
62
|
+
script = ['export HELM_EXPERIMENTAL_OCI=1']
|
63
|
+
script << login_oci(destination) if destination[:user] && destination[:password]
|
64
|
+
script << "\"#{helm_opts[:helm]}\" push \"#{helm_opts[:chart]}-#{helm_opts[:version]}.tgz\" \"#{destination[:url]}\"" # rubocop:disable Layout/LineLength
|
65
|
+
end
|
66
|
+
script
|
67
|
+
end
|
68
|
+
|
69
|
+
def login_oci(login_opts)
|
70
|
+
require 'uri'
|
71
|
+
"echo \"#{login_opts[:password]}\" | \"#{helm_opts[:helm]}\" registry login --username \"#{login_opts[:user]}\" --password-stdin \"#{URI(login_opts[:url]).host}\"" # rubocop:disable Layout/LineLength
|
72
|
+
end
|
73
|
+
|
74
|
+
def pull_classic # rubocop:disable Metrics/AbcSize
|
75
|
+
script = []
|
76
|
+
if helm_opts[:url] && helm_opts[:chart] && helm_opts[:version]
|
77
|
+
suffix = login_classic(helm_opts)
|
78
|
+
script << "\"#{helm_opts[:helm]}\" repo add source \"#{helm_opts[:url]}\"#{suffix}"
|
79
|
+
script << "\"#{helm_opts[:helm]}\" repo update"
|
80
|
+
script << "\"#{helm_opts[:helm]}\" pull \"source/#{helm_opts[:chart]}\" --version \"#{helm_opts[:version]}\""
|
81
|
+
end
|
82
|
+
script
|
83
|
+
end
|
84
|
+
|
85
|
+
def push_classic(destination)
|
86
|
+
script = []
|
87
|
+
if destination[:url] && helm_opts[:chart] && helm_opts[:version]
|
88
|
+
script << plugin_classic
|
89
|
+
suffix = login_classic(destination)
|
90
|
+
script << "\"#{helm_opts[:helm]}\" cm-push \"#{helm_opts[:chart]}-#{helm_opts[:version]}.tgz\" \"#{destination[:url]}\"#{suffix}" # rubocop:disable Layout/LineLength
|
91
|
+
end
|
92
|
+
script
|
93
|
+
end
|
94
|
+
|
95
|
+
def login_classic(login_opts)
|
96
|
+
if login_opts[:user] && login_opts[:password]
|
97
|
+
" --username \"#{login_opts[:user]}\" --password \"#{login_opts[:password]}\""
|
98
|
+
else
|
99
|
+
''
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def plugin_classic
|
104
|
+
"\"#{helm_opts[:helm]}\" plugin list | grep -q cm-push || \"#{helm_opts[:helm]}\" plugin install https://github.com/chartmuseum/helm-push"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/pipedawg/kaniko_job.rb
CHANGED
@@ -23,7 +23,7 @@ module Pipedawg
|
|
23
23
|
flags: [],
|
24
24
|
ignore_paths: [],
|
25
25
|
insecure_registries: [],
|
26
|
-
|
26
|
+
image: {
|
27
27
|
entrypoint: [''],
|
28
28
|
name: 'gcr.io/kaniko-project/executor:debug'
|
29
29
|
},
|
@@ -40,7 +40,7 @@ module Pipedawg
|
|
40
40
|
|
41
41
|
def update # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
42
42
|
require 'json'
|
43
|
-
opts[:image] = kaniko_opts[:image]
|
43
|
+
opts[:image] = kaniko_opts[:image] if kaniko_opts[:image]
|
44
44
|
script = ["echo #{kaniko_opts[:config].to_json.inspect} > \"#{kaniko_opts[:config_file]}\""]
|
45
45
|
cert_copies = Array(kaniko_opts[:trusted_ca_cert_source_files]).map do |cert|
|
46
46
|
"cat \"#{cert}\" >> \"#{kaniko_opts[:trusted_ca_cert_target_file]}\""
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- harbottle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generate GitLab CI pipelines.
|
14
14
|
email:
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- LICENSE.txt
|
21
21
|
- README.md
|
22
22
|
- lib/pipedawg.rb
|
23
|
+
- lib/pipedawg/helm_copy_job.rb
|
23
24
|
- lib/pipedawg/job.rb
|
24
25
|
- lib/pipedawg/kaniko_job.rb
|
25
26
|
- lib/pipedawg/pipeline.rb
|