krane 3.7.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bb4b346e9146186c9e1549f71708707568aa9872a2b7e0e1a0e6fd01e9f4d52
4
- data.tar.gz: fb3662468c546ba6717cfd9de125cd4d6ef2caa2269404a618c2152770fc0d3d
3
+ metadata.gz: 034cf54d143695589902632153ddb65969bae6135c88b076ec023c3c7dc3264a
4
+ data.tar.gz: 309a1d3c9cf5afad784f48a12d9fe1b13568f1485aec95b0007739a13973932a
5
5
  SHA512:
6
- metadata.gz: 7a4e23ab9d917f223c6e294a61b26d17791c3554257bbc81a95e5372f1d90af727a13b3bf470008be750fafbb7dbef322486289a2b247e9e60881eff2f4bad15
7
- data.tar.gz: b73325f5894e1a9ed67e75d1dc1759ceea4afe58aad5be81f27905bd3d0a10ff38012494c26cf68b06c338cd24367bb8e6d472e7b394aed3f3e0f3dd1ff56546
6
+ metadata.gz: 44e89c3a956dec061b554f17a38a2e7afc552cf94a5071470baa3f60fb16ae2510f287d9dd8c2f9e9cc92d78fc330be225de62ce43c3be9bb22eab06104076c4
7
+ data.tar.gz: c9d79cd30d415ea7dc718541921a9c02cb60712fe2d021e22869bb03c0e7608b918f8c285a0362fe19d709780c8c48d4f3b5a3c6ba7fa34d299613421350722a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## next
2
2
 
3
+ ## 3.7.1
4
+
5
+ - Add a `--partials-dir` parameter. When provided, this path will be check for partials first, prior to both `./partials` and `../partials` being checked.
6
+
3
7
  ## 3.7.0
4
8
 
5
9
  - Annotate individual resources with `last-applied-configuration` when using `krane deploy` with `--annotate-individuals`. Previously, eligible resources that were made with `create` or `replace` were applied along with the rest of the resources. However, this causes issues when a mutating admission controller modifies otherwise immutable fields.
@@ -11,6 +11,8 @@ module Krane
11
11
  desc: "[DEPRECATED] Read resources from stdin" },
12
12
  "current-sha" => { type: :string, banner: "SHA", desc: "Expose SHA `current_sha` in ERB bindings",
13
13
  lazy_default: '' },
14
+ "partials-dir" => { type: :string, banner: "partials", required:false, default: nil,
15
+ desc: "First directory to look for partials, before checking `./partials` and `../partials`" },
14
16
  }
15
17
 
16
18
  def self.from_options(options)
@@ -32,6 +34,7 @@ module Krane
32
34
  current_sha: options['current-sha'],
33
35
  filenames: paths,
34
36
  bindings: bindings_parser.parse,
37
+ partials_dir: options['partials-dir'],
35
38
  )
36
39
  renderer.run!(stream: STDOUT)
37
40
  end
@@ -14,11 +14,13 @@ module Krane
14
14
  # @param current_sha [String] The SHA of the commit
15
15
  # @param filenames [Array<String>] An array of filenames and/or directories containing templates (*required*)
16
16
  # @param bindings [Hash] Bindings parsed by Krane::BindingsParser
17
- def initialize(logger: nil, current_sha:, filenames: [], bindings:)
17
+ # @params partials_dir [String] A directory to look for partials, before checking `./partials` and `../partials`
18
+ def initialize(logger: nil, current_sha:, filenames: [], bindings:, partials_dir: nil)
18
19
  @logger = logger || Krane::FormattedLogger.build
19
20
  @filenames = filenames.map { |path| File.expand_path(path) }
20
21
  @bindings = bindings
21
22
  @current_sha = current_sha
23
+ @partials_dir = partials_dir
22
24
  end
23
25
 
24
26
  # Runs the task, returning a boolean representing success or failure
@@ -58,7 +60,7 @@ module Krane
58
60
  @logger.phase_heading("Rendering template(s)")
59
61
  count = 0
60
62
  template_sets.with_resource_definitions_and_filename(current_sha: @current_sha,
61
- bindings: @bindings, raw: true) do |rendered_content, filename|
63
+ bindings: @bindings, raw: true, partials_dir: @partials_dir) do |rendered_content, filename|
62
64
  write_to_stream(rendered_content, filename, stream)
63
65
  count += 1
64
66
  end
@@ -16,11 +16,14 @@ module Krane
16
16
  end
17
17
  class PartialNotFound < InvalidTemplateError; end
18
18
 
19
- def initialize(current_sha:, template_dir:, logger:, bindings: {})
19
+ def initialize(current_sha:, template_dir:, logger:, bindings: {}, partials_dir: nil)
20
20
  @current_sha = current_sha
21
21
  @template_dir = template_dir
22
22
  @partials_dirs =
23
23
  %w(partials ../partials).map { |d| File.expand_path(File.join(@template_dir, d)) }
24
+ # Prepend the partial_dir to the list of partials_dirs so that the user-provided
25
+ # directory is used first.
26
+ @partials_dirs.unshift(File.expand_path(partials_dir)) if partials_dir
24
27
  @logger = logger
25
28
  @bindings = bindings
26
29
  # Max length of podname is only 63chars so try to save some room by truncating sha to 8 chars
@@ -17,13 +17,14 @@ module Krane
17
17
  @render_erb = render_erb
18
18
  end
19
19
 
20
- def with_resource_definitions_and_filename(current_sha: nil, bindings: nil, raw: false)
20
+ def with_resource_definitions_and_filename(current_sha: nil, bindings: nil, raw: false, partials_dir: nil)
21
21
  if @render_erb
22
22
  @renderer = Renderer.new(
23
23
  template_dir: @template_dir,
24
24
  logger: @logger,
25
25
  current_sha: current_sha,
26
26
  bindings: bindings,
27
+ partials_dir: partials_dir,
27
28
  )
28
29
  end
29
30
  with_delayed_exceptions(@files, Krane::InvalidTemplateError) do |filename|
@@ -123,20 +124,21 @@ module Krane
123
124
  end
124
125
  end
125
126
 
126
- def with_resource_definitions_and_filename(current_sha: nil, bindings: nil, raw: false)
127
+ def with_resource_definitions_and_filename(current_sha: nil, bindings: nil, raw: false, partials_dir: nil)
127
128
  with_delayed_exceptions(@template_sets, Krane::InvalidTemplateError) do |template_set|
128
129
  template_set.with_resource_definitions_and_filename(
129
130
  current_sha: current_sha,
130
131
  bindings: bindings,
131
- raw: raw
132
+ raw: raw,
133
+ partials_dir: partials_dir,
132
134
  ) do |r_def, filename|
133
135
  yield r_def, filename
134
136
  end
135
137
  end
136
138
  end
137
139
 
138
- def with_resource_definitions(current_sha: nil, bindings: nil, raw: false)
139
- with_resource_definitions_and_filename(current_sha: current_sha, bindings: bindings, raw: raw) do |r_def, _|
140
+ def with_resource_definitions(current_sha: nil, bindings: nil, raw: false, partials_dir: nil)
141
+ with_resource_definitions_and_filename(current_sha: current_sha, bindings: bindings, raw: raw, partials_dir: partials_dir) do |r_def, _|
140
142
  yield r_def
141
143
  end
142
144
  end
data/lib/krane/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Krane
3
- VERSION = "3.7.0"
3
+ VERSION = "3.7.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: krane
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Verey
@@ -9,7 +9,7 @@ authors:
9
9
  - Kir Shatrov
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-01-16 00:00:00.000000000 Z
12
+ date: 2025-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -525,7 +525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
525
525
  - !ruby/object:Gem::Version
526
526
  version: '0'
527
527
  requirements: []
528
- rubygems_version: 3.6.2
528
+ rubygems_version: 3.6.5
529
529
  specification_version: 4
530
530
  summary: A command line tool that helps you ship changes to a Kubernetes namespace
531
531
  and understand the result