kube_deploy_tools 3.0.5 → 3.0.9

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: 9f4077fc4d8fce7c7d5e9ea6f664f7be3f19b1c9e41ef8a1fa909685f195550d
4
- data.tar.gz: 33e8aeebd5a2235e23111c36dcef8b228c0754b45b9a1af03cd2054437649ccc
3
+ metadata.gz: 647bca1b43df72e42a02b1177678afd9f05c1c14f923a924ae62a573080928fa
4
+ data.tar.gz: 98d5c912c3890ad176b2b57035ff63b677cf44728bce05b34b7e9853ba8a21fb
5
5
  SHA512:
6
- metadata.gz: aeca489af252fafbc3e493197765b3bbbd8db09ff21ef0372d07d87f53317f00bd3d55e3efdc27fec2d0f7ad9555ead6a5adbff73486cdea45ad3e45efb294c1
7
- data.tar.gz: c5be546497348d309048bcefd55f0d255c50f2fd2a21405f091a9042089984d6e118b59024a4f60c47af7c3a3aa401c900482c250c31244af35a827062dc342e
6
+ metadata.gz: d5d4d909e52925fcda3b36878f8ab9540efe2675814214e5ec8e5b5c0536fc2be629122b704c3a9bd009d8d612853f3ee22c9f37e91c51cdd77d713da8341dcb
7
+ data.tar.gz: a63cda5c818c5e0930745adcd67747c8d46ab4635ebd9adbbb1b84306fb24067bdc4a5633c34f06b3f91099008593c46fb4c709fac7ed6901e6d50875d603650
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/kube_deploy_tools.svg)](https://badge.fury.io/rb/kube_deploy_tools)
2
+
1
3
  # kube_deploy_tools (kdt)
2
4
 
3
5
  `kube_deploy_tools` (kdt) is a tool to simplify kubernetes manifest generation
@@ -28,6 +30,7 @@ a complete production lifecycle, they are also designed to be used
28
30
  individually.
29
31
 
30
32
  [Helm]: https://helm.sh
33
+ [ERB]: https://ruby-doc.org/stdlib-2.7.1/libdoc/erb/rdoc/ERB.html
31
34
 
32
35
  # Getting Started
33
36
 
@@ -103,7 +106,7 @@ To explore further,
103
106
  * Run `kdt deploy -f build/kubernetes/prod_default --context my-kube-context` to send your generated
104
107
  manifests to a Kubernetes API server.
105
108
 
106
- [complete description]: XXX
109
+ [complete description]: schemas/v2.schema.json
107
110
 
108
111
  # FAQ
109
112
 
@@ -118,19 +121,6 @@ For breaking changes, new features, and new fixes, see
118
121
 
119
122
  # Contribute
120
123
 
121
- ```bash
122
- # Install ruby w/ Homebrew
123
- brew install ruby
124
-
125
- # Or install ruby w/ rbenv
126
- brew install rbenv ruby-build
127
- rbenv install 2.3.0
128
- rbenv global 2.3.0
129
-
130
- # Install gem
131
- gem install bundler
132
- ```
133
-
134
124
  ```bash
135
125
  bundle install --with development
136
126
 
@@ -140,3 +130,11 @@ bundle exec rake test
140
130
  # Exec a binary in bin/
141
131
  bundle exec kdt generate
142
132
  ```
133
+
134
+ We accept [pull requests]. They will be reviewed by a member of the LiveRamp development team as soon as possible.
135
+ Once the PR is merged, GitHub will auto-draft the release. Be sure to
136
+ add the same version as a tag (vX.Y.Z) and then publish it.
137
+ [GitHub Workflow] will then publish the gems.
138
+
139
+ [GitHub Workflow]: https://github.com/LiveRamp/kube_deploy_tools/blob/master/.github/workflows/release.yml
140
+ [pull requests]: https://github.com/LiveRamp/kube_deploy_tools/pulls
@@ -29,12 +29,21 @@ module KubeDeployTools
29
29
  local_artifact_path
30
30
  end
31
31
 
32
+ def get_registry_build_path(project:)
33
+ # NOTE: If the naming format changes, it represents a breaking change
34
+ # where all past clients will not be able to list/download new builds
35
+ # and new clients will not be able to list/download old builds. Change
36
+ # with caution.
37
+ #
38
+ "#{@bucket}/project/#{project}/build"
39
+ end
40
+
32
41
  def get_registry_artifact_path(name:, flavor:, project:, build_number:)
33
42
  # NOTE(joshk): If the naming format changes, it represents a breaking
34
43
  # change where all past clients will not be able to download new builds and
35
44
  # new clients will not be able to download old builds. Change with caution.
36
45
  #
37
- "#{@bucket}/project/#{project}/build/#{build_number}/artifact/#{get_artifact_name(name: name, flavor: flavor)}"
46
+ "#{get_registry_build_path(project: project)}/#{build_number}/artifact/#{get_artifact_name(name: name, flavor: flavor)}"
38
47
  end
39
48
 
40
49
  def get_artifact_name(name:, flavor:)
@@ -84,6 +93,18 @@ module KubeDeployTools
84
93
  output_path
85
94
  end
86
95
 
96
+ def get_latest_build_number(project)
97
+ out = Shellrunner.check_call('gsutil', 'ls', get_registry_build_path(project: project))
98
+
99
+ # pick out the build numbers from the list
100
+ build_regex = /([0-9]+)\/$/
101
+ build_entries = out.scan(build_regex)
102
+
103
+ build_entries.
104
+ map { |x| x[0].to_s.to_i }.
105
+ max.to_s
106
+ end
107
+
87
108
  def upload(local_dir:, name:, flavor:, project:, build_number:)
88
109
  # Pack up contents of each flavor_dir to a correctly named artifact.
89
110
  flavor_dir = File.join(local_dir, "#{name}_#{flavor}")
@@ -2,6 +2,9 @@ require 'optparse'
2
2
 
3
3
  require 'kube_deploy_tools/object'
4
4
 
5
+ # As of kubernetes 1.23 valid dry-run options are: none, client, server.
6
+ VALID_DRY_RUN_VALUES = %w[none client server].freeze
7
+
5
8
  module KubeDeployTools
6
9
  class Deploy::Optparser
7
10
  class Options
@@ -21,7 +24,7 @@ module KubeDeployTools
21
24
  def initialize
22
25
  self.project = File.basename(`git config remote.origin.url`.chomp, '.git')
23
26
  self.flavor = 'default'
24
- self.dry_run = true
27
+ self.dry_run = 'client'
25
28
  self.glob_files = []
26
29
  end
27
30
 
@@ -54,8 +57,19 @@ module KubeDeployTools
54
57
  self.build_number = p
55
58
  end
56
59
 
57
- parser.on('--dry-run DRY_RUN', TrueClass, "If true, will only dry-run apply Kubernetes manifests without sending them to the apiserver. Default is dry-run mode: #{dry_run}.") do |p|
58
- self.dry_run = p
60
+ # As of kubernetes 1.23 valid dry-run options are: none, client, server.
61
+ # Legacy values map accordingly: true => client, false => none
62
+ parser.on('--dry-run DRY_RUN', "Will only dry-run apply Kubernetes manifests without sending them to the apiserver. Default is dry-run mode: #{dry_run}. Must be '#{VALID_DRY_RUN_VALUES}'") do |p|
63
+ legacy_mapping = { 'true' => 'client', 'false' => 'none' }
64
+
65
+ if legacy_mapping.include?(p) then
66
+ self.dry_run = legacy_mapping[p]
67
+ Logger.warn("#{p} is no longer a supported dry-run value. Setting to value '#{self.dry_run}'.")
68
+ elsif VALID_DRY_RUN_VALUES.include?(p)
69
+ self.dry_run = p
70
+ else
71
+ raise ArgumentError, "#{p} is not a valid dry-run value. Expect one of '#{VALID_DRY_RUN_VALUES.join(', ')}'"
72
+ end
59
73
  end
60
74
 
61
75
  parser.on('--include INCLUDE', "Include glob pattern. Example: --include=**/* will include every file. Default is ''.") do |p|
@@ -64,10 +64,9 @@ module KubeDeployTools
64
64
  end
65
65
 
66
66
  def do_deploy(dry_run)
67
- success = false
68
67
  Logger.reset
69
68
  Logger.phase_heading('Initializing deploy')
70
- Logger.warn('Running in dry-run mode') if dry_run
69
+ Logger.warn('Running in dry-run mode') if dry_run != 'none'
71
70
 
72
71
  if !@namespace.nil? && @namespace != 'default'
73
72
  Logger.warn("Deploying to non-default Namespace: #{@namespace}")
@@ -98,7 +97,7 @@ module KubeDeployTools
98
97
  success
99
98
  end
100
99
 
101
- def run(dry_run: true)
100
+ def run(dry_run: 'client')
102
101
  do_deploy(dry_run)
103
102
  end
104
103
 
@@ -161,7 +160,7 @@ module KubeDeployTools
161
160
  raise FatalDeploymentError, "Template '#{filepath}' cannot be parsed"
162
161
  end
163
162
 
164
- def kubectl_apply(resources, dry_run: true)
163
+ def kubectl_apply(resources, dry_run: 'client')
165
164
  resources.each do |resource|
166
165
  @max_retries.times do |try|
167
166
  args = ['apply', '-f', resource.filepath, "--dry-run=#{dry_run}"]
@@ -1,3 +1,4 @@
1
+ require 'tempfile'
1
2
 
2
3
  module KubeDeployTools
3
4
  module DeployConfigFileUtil
@@ -248,6 +248,10 @@ module KubeDeployTools
248
248
  # the 'other' hash wins.
249
249
  @image_registries = other.image_registries.merge(@image_registries)
250
250
 
251
+ @artifact_registries = other.artifact_registries.merge(@artifact_registries)
252
+
253
+ @artifact_registry = other.artifact_registry if @artifact_registry.empty?
254
+
251
255
  # Same behavior as above for #default_flags.
252
256
  @default_flags = other.default_flags.merge(@default_flags)
253
257
 
@@ -1,3 +1,3 @@
1
1
  module KubeDeployTools
2
- VERSION = '3.0.5'
2
+ VERSION = '3.0.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_deploy_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabien Goncalves
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2020-05-27 00:00:00.000000000 Z
19
+ date: 2022-01-07 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: colorize
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  - !ruby/object:Gem::Version
185
185
  version: '0'
186
186
  requirements: []
187
- rubygems_version: 3.0.3
187
+ rubygems_version: 3.0.3.1
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Kubernetes Deploy Tools