kdep 0.4.5 → 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 +4 -4
- data/lib/kdep/config.rb +2 -0
- data/lib/kdep/preset.rb +2 -0
- data/lib/kdep/template_context.rb +42 -0
- data/lib/kdep/version.rb +1 -1
- data/templates/resources/configmap.yml.erb +1 -1
- data/templates/resources/cronjob.yml.erb +4 -1
- data/templates/resources/deployment.yml.erb +1 -1
- data/templates/resources/job.yml.erb +1 -1
- data/templates/resources/statefulset.yml.erb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f292fc84fbd868827a225e5a63ec7ef74949f954216c69fd6eac1fb8d431f7ff
|
|
4
|
+
data.tar.gz: b3486a1fc6c39ed310d0cf4a138421fcbbf46b2d7b31deb59f403d5d37c62e5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
@@ -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: <%=
|
|
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: <%=
|
|
32
|
+
image: <%= image_ref %>
|
|
33
33
|
<% if @config["image_pull_policy"] -%>
|
|
34
34
|
imagePullPolicy: <%= @config["image_pull_policy"] %>
|
|
35
35
|
<% end -%>
|
|
@@ -14,7 +14,7 @@ spec:
|
|
|
14
14
|
restartPolicy: Never
|
|
15
15
|
containers:
|
|
16
16
|
- name: <%= name %>
|
|
17
|
-
image: <%=
|
|
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: <%=
|
|
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
|
+
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-
|
|
11
|
+
date: 2026-07-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: envspec
|