kdep 0.4.8 → 0.4.9

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: 1ed0d8de8dfb58cc372615340a068aecb3f8092aecafdbc6d1c6480c14477d57
4
- data.tar.gz: 8dde50b29b917321144fcca1d0cb83cff8b66a702442c5bf19375ae527f4cf6e
3
+ metadata.gz: 92fded408b48545949833a1473e7b905dc7ce0b8b7c58415ad77b532f0205227
4
+ data.tar.gz: 2af6988f918a2ba676a4a2d5780a950581f0e93596e772d4e04f3ca65b9fdba0
5
5
  SHA512:
6
- metadata.gz: 3669fafcc6315fcdb7af39bb0b31cb7314a953b3185988523af63e1d9ab1fb60a458ba141dc22e3735e00de5df8a821b862b657aaae68d36e8326e0a0f304f2b
7
- data.tar.gz: 7cbb7445b6909b46e74f47245c88df5fa8d7d93617a949b14059aef3f50c2981941ed129d70f013dede5e2789ad363e55d8768698129059c412c03d631851b81
6
+ metadata.gz: 8f1d30adf7eb1fe069115dc5cea6458f1e83ef4ef3025fb32912b9fee74f0b68582606fa71aa2e0b306e3ed80a5dda2dacec74760b3e9eb02884e794c18ec75c
7
+ data.tar.gz: d6b64df4bbe169c1f80c2169f6c3378d6ab62ce57096f6aa0d4f5cf8f3251f25cde1ffbfce1e490028a60bb9872f1848fc9bef016cc34aed23160e4e0144b99b
@@ -3,11 +3,14 @@ require "optparse"
3
3
  module Kdep
4
4
  module Commands
5
5
  class Log
6
+ # kubectl refuses to follow more than --max-log-requests streams (default 5)
7
+ MIN_LOG_REQUESTS = 5
8
+
6
9
  def self.option_parser
7
10
  OptionParser.new do |opts|
8
11
  opts.banner = "Usage: kdep log [deploy]"
9
12
  opts.separator ""
10
- opts.separator "Streams pod logs with error highlighting."
13
+ opts.separator "Streams logs from all running pods (prefixed by pod) with error highlighting."
11
14
  opts.separator ""
12
15
  opts.on("-f", "--[no-]follow", "Follow log output (default: true)")
13
16
  opts.on("-c", "--container=NAME", "Container name for multi-container pods")
@@ -50,40 +53,43 @@ module Kdep
50
53
  exit 1
51
54
  end
52
55
 
53
- # Find running pod
56
+ # Count matching pods (fails fast when none is running)
54
57
  namespace = config["namespace"]
55
58
  app_name = config["name"]
56
- pod_name = find_pod(namespace, app_name)
59
+ pod_count = count_pods(namespace, app_name)
57
60
 
58
- # Stream logs
59
- stream_logs(pod_name, namespace)
61
+ # Stream logs from every pod matching the app label
62
+ stream_logs(namespace, app_name, pod_count)
60
63
  end
61
64
 
62
65
  private
63
66
 
64
- def find_pod(namespace, app_name)
67
+ # kubectl logs -l streams every pod the selector matches, whatever its
68
+ # phase (Completed leftovers, Pending surge pods), so the stream limit
69
+ # must count all of them -- only the guard looks at Running.
70
+ def count_pods(namespace, app_name)
65
71
  data = Kdep::Kubectl.run_json(
66
72
  "get", "pods",
67
73
  "-n", namespace,
68
- "-l", "app=#{app_name}",
69
- "--field-selector", "status.phase=Running"
74
+ "-l", "app=#{app_name}"
70
75
  )
71
- pods = data["items"]
76
+ pods = data["items"] || []
72
77
 
73
- if pods.nil? || pods.empty?
78
+ if pods.none? { |pod| pod.dig("status", "phase") == "Running" }
74
79
  @ui.error("No running pods found for #{app_name} in #{namespace}")
75
80
  exit 1
76
81
  end
77
82
 
78
- pods[0]["metadata"]["name"]
83
+ pods.length
79
84
  end
80
85
 
81
- def stream_logs(pod_name, namespace)
86
+ def stream_logs(namespace, app_name, pod_count)
82
87
  follow = @command_options.fetch(:follow, true)
83
88
  tail = @command_options.fetch(:tail, 100)
84
89
  container = @command_options[:container]
85
90
 
86
- args = ["kubectl", "logs", pod_name, "-n", namespace]
91
+ args = ["kubectl", "logs", "-n", namespace, "-l", "app=#{app_name}", "--prefix", "--ignore-errors"]
92
+ args << "--max-log-requests=#{[pod_count, MIN_LOG_REQUESTS].max}"
87
93
  args << "-f" if follow
88
94
  args << "--tail=#{tail}"
89
95
 
data/lib/kdep/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kdep
2
- VERSION = "0.4.8"
2
+ VERSION = "0.4.9"
3
3
  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.8
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leadfy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-15 00:00:00.000000000 Z
11
+ date: 2026-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: envspec
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 3.2.32
192
+ rubygems_version: 3.5.19
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: Kubernetes deployment CLI