kdep 0.4.4 → 0.4.6

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: 43bdf0f4f94cbd1170fbffe7adf406ec3dc47b3a3c05a4c28d10fe56b53d7841
4
- data.tar.gz: 71b4d6b94ccd86fecab7f87cee451edbda62065f9f7c4a6ad0c59569a521905f
3
+ metadata.gz: f292fc84fbd868827a225e5a63ec7ef74949f954216c69fd6eac1fb8d431f7ff
4
+ data.tar.gz: b3486a1fc6c39ed310d0cf4a138421fcbbf46b2d7b31deb59f403d5d37c62e5c
5
5
  SHA512:
6
- metadata.gz: 7ad745df8ac27c8525dd7dd6693ab2d8353950ada764783532b42540cf4392dfa862a4ead9ec360a833bb301fd0448ed7acd636594be15aa08fcbcabe655e652
7
- data.tar.gz: 9a6d018d56d79c6c5f6ee4120fcb3a2b5b13cef257578e22b717c1cf26772d6bdc9339dd03ce4b285e48a2cbcc01e3ff401f8af4bc060864c90f981e8dd6aa17
6
+ metadata.gz: 9c5521c97e1c89ab7bd74f94967d735dca9d46e497dbeaa788274138ebe45ce6c28e4f8ecd24bfb1d2a9180ed995e3713bc488c23793b40154b7d98b38f4c71d
7
+ data.tar.gz: cb3a4a8b54be7f2852396207eab1971c47f2922b30878f8d26d2b4625e3cb130a5408d6eaa78e1ad06b815e9ac009c4719e992ffad9c18fc9432ee0525df4518
data/lib/kdep/config.rb CHANGED
@@ -49,6 +49,8 @@ module Kdep
49
49
  preset_name = config.fetch("preset", "custom")
50
50
  defaults = Kdep::Defaults.for_preset(preset_name)
51
51
  result = deep_merge(defaults, config)
52
+ # Persist the resolved name: every consumer reads config["preset"] directly
53
+ result["preset"] = preset_name
52
54
 
53
55
  # Name default: derive from project folder + deploy folder name
54
56
  # deploy_dir is [project]/kdep/[deploy], so go up 2 levels for project name
data/lib/kdep/preset.rb CHANGED
@@ -3,6 +3,8 @@ module Kdep
3
3
  BUILT_IN = %w[web worker job cronjob statefulset statefulset_svc helm custom].freeze
4
4
 
5
5
  def initialize(preset_name, deploy_dir)
6
+ raise "preset: is required in app.yml" if preset_name.to_s.strip.empty?
7
+
6
8
  @preset_name = preset_name
7
9
  @deploy_dir = deploy_dir
8
10
  end
@@ -1,3 +1,5 @@
1
+ require "json"
2
+
1
3
  module Kdep
2
4
  class TemplateContext
3
5
  def initialize(config, secrets = {})
@@ -18,5 +20,45 @@ module Kdep
18
20
  def yaml_value(val)
19
21
  val.is_a?(String) ? val : val.to_s
20
22
  end
23
+
24
+ # Helper: fully-qualified container image reference, "[registry/]image:tag".
25
+ #
26
+ # An empty or whitespace-only `registry:` counts as absent. Ruby treats ""
27
+ # as truthy, so the old inline `@config["registry"] ? ... : ...` ternary in
28
+ # every template emitted a leading slash ("/image:tag") for `registry: ""` --
29
+ # a real gotcha for upstream-image deploys (repleadfy/kdep#1). Same for a
30
+ # blank `tag:`, which would otherwise render an invalid trailing colon.
31
+ def image_ref
32
+ registry = @config["registry"].to_s.strip
33
+ image = @config["image"].to_s
34
+ tag = @config["tag"].to_s.strip
35
+ tag = "latest" if tag.empty?
36
+
37
+ repository = registry.empty? ? image : "#{registry}/#{image}"
38
+ "#{repository}:#{tag}"
39
+ end
40
+
41
+ # Helper: render one ConfigMap `data:` value.
42
+ #
43
+ # Multiline values become YAML block scalars, so config files mounted into
44
+ # containers (prometheus.yml, fluent.conf, curator action files...) survive
45
+ # intact instead of collapsing into one quoted line (repleadfy/kdep#1).
46
+ # Single-line values stay quoted strings: ConfigMap data values must be
47
+ # strings, so an unquoted `8080` or `true` would be rejected by the API.
48
+ #
49
+ # `indent` is the column the block body sits at -- two levels under `data:`.
50
+ def configmap_value(value, indent = 4)
51
+ str = value.to_s
52
+ return str.to_json unless str.include?("\n")
53
+
54
+ pad = " " * indent
55
+ # `|` keeps a single trailing newline, `|-` strips it -- preserve whichever
56
+ # the value actually had, since some consumers care.
57
+ chomp = str.end_with?("\n")
58
+ body = chomp ? str.sub(/\n\z/, "") : str
59
+ lines = body.split("\n", -1).map { |line| line.empty? ? "" : "#{pad}#{line}" }
60
+
61
+ "#{chomp ? "|" : "|-"}\n#{lines.join("\n")}"
62
+ end
21
63
  end
22
64
  end
data/lib/kdep/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kdep
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.6"
3
3
  end
@@ -6,6 +6,6 @@ metadata:
6
6
  <% if @config["configmap"] && !@config["configmap"].empty? -%>
7
7
  data:
8
8
  <% @config["configmap"].sort.each do |key, value| -%>
9
- <%= key %>: "<%= value %>"
9
+ <%= key %>: <%= configmap_value(value) %>
10
10
  <% end -%>
11
11
  <% end -%>
@@ -5,6 +5,9 @@ metadata:
5
5
  namespace: <%= namespace %>
6
6
  spec:
7
7
  schedule: "<%= @config["schedule"] %>"
8
+ <% if @config["time_zone"] -%>
9
+ timeZone: "<%= @config["time_zone"] %>"
10
+ <% end -%>
8
11
  <% if @config.key?("suspend") -%>
9
12
  suspend: <%= @config["suspend"] %>
10
13
  <% end -%>
@@ -34,7 +37,7 @@ spec:
34
37
  <% end -%>
35
38
  containers:
36
39
  - name: <%= @config["container_name"] || name %>
37
- image: <%= @config["registry"] ? "#{@config["registry"]}/#{image}" : image %>:<%= @config["tag"] || "latest" %>
40
+ image: <%= image_ref %>
38
41
  <% if @config["image_pull_policy"] -%>
39
42
  imagePullPolicy: <%= @config["image_pull_policy"] %>
40
43
  <% end -%>
@@ -29,7 +29,7 @@ spec:
29
29
  <% end -%>
30
30
  containers:
31
31
  - name: <%= @config["container_name"] || name %>
32
- image: <%= @config["registry"] ? "#{@config["registry"]}/#{image}" : image %>:<%= @config["tag"] || "latest" %>
32
+ image: <%= image_ref %>
33
33
  <% if @config["image_pull_policy"] -%>
34
34
  imagePullPolicy: <%= @config["image_pull_policy"] %>
35
35
  <% end -%>
@@ -58,7 +58,8 @@ spec:
58
58
  <% tls_hosts = @config["tls_hosts"] || {} -%>
59
59
  <% group_domains.each do |domain| -%>
60
60
  <% host = domain.is_a?(Hash) ? domain["host"] : domain -%>
61
- <% tls_secret = tls_hosts[host] || @config["tls_secret_name"] || "#{host.gsub(".", "-")}-cert-secret" -%>
61
+ <% per_domain_tls = domain.is_a?(Hash) ? domain["tls_secret"] : nil -%>
62
+ <% tls_secret = per_domain_tls || tls_hosts[host] || @config["tls_secret_name"] || "#{host.gsub(".", "-")}-cert-secret" -%>
62
63
  - hosts:
63
64
  - <%= host %>
64
65
  secretName: <%= tls_secret %>
@@ -14,7 +14,7 @@ spec:
14
14
  restartPolicy: Never
15
15
  containers:
16
16
  - name: <%= name %>
17
- image: <%= @config["registry"] ? "#{@config["registry"]}/#{image}" : image %>:<%= @config["tag"] || "latest" %>
17
+ image: <%= image_ref %>
18
18
  <% if @config["command"] -%>
19
19
  command: <%= @config["command"].is_a?(Array) ? @config["command"].inspect : "[\"#{@config["command"]}\"]" %>
20
20
  <% end -%>
@@ -30,7 +30,7 @@ spec:
30
30
  <% end -%>
31
31
  containers:
32
32
  - name: <%= @config["container_name"] || name %>
33
- image: <%= @config["registry"] ? "#{@config["registry"]}/#{image}" : image %>:<%= @config["tag"] || "latest" %>
33
+ image: <%= image_ref %>
34
34
  <% if @config["image_pull_policy"] -%>
35
35
  imagePullPolicy: <%= @config["image_pull_policy"] %>
36
36
  <% end -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kdep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leadfy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-01 00:00:00.000000000 Z
11
+ date: 2026-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: envspec
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
- rubygems_version: 3.5.22
188
+ rubygems_version: 3.2.32
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: Kubernetes deployment CLI