pipedawg 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 041e80c36e4a1f30695c0d60233c8fcc3261ac734dee7d0770dde11ad1e0ac71
4
- data.tar.gz: ee48577c9c00e3ef4f76cabe22895d435b26bb10cd6dd4ff5a950dbaebaaf5bc
3
+ metadata.gz: 064c29963799087a56d2cde36f785bc9762cd50870dc9eeede4f9efbfc577f0f
4
+ data.tar.gz: fd51dfa82c3d16c215f284dfd7c84c5600906738fef8d6f6b0d69b22e967af33
5
5
  SHA512:
6
- metadata.gz: 83e2ef040fbdbec747968ca61d58079e720dd32cea77fd0dc0b39f451dab618e247cf85617f6f6f6dbaf881263e90c4b2f7b90b3df96d5c60e6a338db5b007d1
7
- data.tar.gz: 34cccd812da30055338afc7368a5f62f46c0df7ba8e7dc7c21e9590fdcd4a5d398df30be22f0e5aac6c7a9a3944f4683b1b96be79da9b75276aca89ee13e8d89
6
+ metadata.gz: c7241f30f45d72d1d43e03ef7b007c24756b1a16c483f605c179a02eb02c89b900926fd20c93502fbc94585cc9f1fa94ba41fefa27cabf497568b05ff252a75e
7
+ data.tar.gz: 7c72d19557c1f449dd56315465d1f22d66277005dfb39c59a67d83ef5389800511fcbbfc7fae3409f235d66834256d5f9566d63d8610f37b1a718c0d4f99285a
@@ -7,7 +7,7 @@ module Pipedawg
7
7
 
8
8
  def initialize(name = 'build', opts = {}, helm_opts = {})
9
9
  @helm_opts = {
10
- chart: name,
10
+ chart: name, debug: true,
11
11
  destinations: [{ user: nil, password: nil, url: nil }],
12
12
  helm: 'helm',
13
13
  image: { entrypoint: [''], name: 'alpine/helm' },
@@ -17,13 +17,21 @@ module Pipedawg
17
17
  update
18
18
  end
19
19
 
20
- def update
20
+ def update # rubocop:disable Metrics/AbcSize
21
21
  opts[:image] = helm_opts[:image] if helm_opts[:image]
22
- opts[:script] = [] + pull + (helm_opts[:destinations].map { |d| push(d) }).flatten(1)
22
+ opts[:script] = debug + pull + (helm_opts[:destinations].map { |d| push(d) }).flatten(1)
23
23
  end
24
24
 
25
25
  private
26
26
 
27
+ def debug
28
+ if helm_opts[:debug]
29
+ Pipedawg::Util.echo_proxy_vars
30
+ else
31
+ []
32
+ end
33
+ end
34
+
27
35
  def pull
28
36
  case helm_opts[:url]
29
37
  when nil
@@ -11,13 +11,12 @@ module Pipedawg
11
11
  config: {
12
12
  '$CI_REGISTRY': { username: '$CI_REGISTRY_USER', password: '$CI_REGISTRY_PASSWORD' }
13
13
  },
14
- config_file: '/kaniko/.docker/config.json', context: '${CI_PROJECT_DIR}',
15
- destinations: [], dockerfile: 'Dockerfile', executor: '/kaniko/executor',
16
- external_files: {}, flags: [], ignore_paths: [], insecure_registries: [],
17
- image: { entrypoint: [''], name: 'gcr.io/kaniko-project/executor:debug' },
18
- options: {}, registry_certificates: {}, registry_mirrors: [],
19
- skip_tls_verify_registry: [], trusted_ca_cert_source_files: [],
20
- trusted_ca_cert_target_file: '/kaniko/ssl/certs/ca-certificates.crt'
14
+ config_file: '/kaniko/.docker/config.json', context: '${CI_PROJECT_DIR}', debug: true,
15
+ destinations: [], dockerfile: 'Dockerfile', executor: '/kaniko/executor', external_files: {},
16
+ flags: [], ignore_paths: [], insecure_registries: [],
17
+ image: { entrypoint: [''], name: 'gcr.io/kaniko-project/executor:debug' }, options: {},
18
+ registry_certificates: {}, registry_mirrors: [], skip_tls_verify_registry: [],
19
+ trusted_ca_cert_source_files: [], trusted_ca_cert_target_file: '/kaniko/ssl/certs/ca-certificates.crt'
21
20
  }.merge(kaniko_opts)
22
21
  super name, opts
23
22
  update
@@ -26,11 +25,19 @@ module Pipedawg
26
25
  def update # rubocop:disable Metrics/AbcSize
27
26
  require 'json'
28
27
  opts[:image] = kaniko_opts[:image] if kaniko_opts[:image]
29
- opts[:script] = config + cert_copies + file_copies + Array(kaniko_cmd)
28
+ opts[:script] = debug + config + cert_copies + file_copies + Array(kaniko_cmd)
30
29
  end
31
30
 
32
31
  private
33
32
 
33
+ def debug
34
+ if kaniko_opts[:debug]
35
+ Pipedawg::Util.echo_proxy_vars
36
+ else
37
+ []
38
+ end
39
+ end
40
+
34
41
  def config
35
42
  ["echo #{kaniko_opts[:config].to_json.inspect} > \"#{kaniko_opts[:config_file]}\""]
36
43
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedawg
4
+ # util class
5
+ class Util
6
+ def self.expand_env_vars(item) # rubocop:disable Metrics/MethodLength
7
+ case item
8
+ when Array
9
+ item.map { |i| expand_env_vars(i) }
10
+ when Hash
11
+ item.each { |k, v| item[k] = expand_env_vars(v) }
12
+ item
13
+ when String
14
+ item.gsub(/\${([^} ]+)}/) do |e|
15
+ ENV[e.gsub('${', '').gsub('}', '')]
16
+ end
17
+ else
18
+ item
19
+ end
20
+ end
21
+
22
+ def self.puts_proxy_vars
23
+ puts 'Proxy settings:'
24
+ puts "http_proxy: #{ENV['http_proxy']}"
25
+ puts "https_proxy: #{ENV['https_proxy']}"
26
+ puts "no_proxy: #{ENV['no_proxy']}"
27
+ puts "HTTP_PROXY: #{ENV['HTTP_PROXY']}"
28
+ puts "HTTPS_PROXY: #{ENV['HTTPS_PROXY']}"
29
+ puts "NO_PROXY: #{ENV['NO_PROXY']}"
30
+ end
31
+
32
+ def self.echo_proxy_vars
33
+ script = ['echo Proxy settings:']
34
+ script << 'echo http_proxy: "${http_proxy}"'
35
+ script << 'echo https_proxy: "${https_proxy}"'
36
+ script << 'echo no_proxy: "${no_proxy}"'
37
+ script << 'echo HTTP_PROXY: "${HTTP_PROXY}"'
38
+ script << 'echo HTTPS_PROXY: "${HTTPS_PROXY}"'
39
+ script << 'echo NO_PROXY: "${NO_PROXY}"'
40
+ script
41
+ end
42
+ end
43
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pipedawg
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/pipedawg.rb CHANGED
@@ -4,6 +4,7 @@ require 'pipedawg/job'
4
4
  require 'pipedawg/helm_copy_job'
5
5
  require 'pipedawg/kaniko_job'
6
6
  require 'pipedawg/pipeline'
7
+ require 'pipedawg/util'
7
8
  require 'pipedawg/version'
8
9
 
9
10
  module Pipedawg
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipedawg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - harbottle
@@ -24,6 +24,7 @@ files:
24
24
  - lib/pipedawg/job.rb
25
25
  - lib/pipedawg/kaniko_job.rb
26
26
  - lib/pipedawg/pipeline.rb
27
+ - lib/pipedawg/util.rb
27
28
  - lib/pipedawg/version.rb
28
29
  homepage: https://github.com/liger1978/pipedawg
29
30
  licenses: