mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
vendor files
This commit is contained in:
70
vendor/k8s.io/kubernetes/pkg/kubectl/plugins/examples/aging/aging.rb
generated
vendored
Executable file
70
vendor/k8s.io/kubernetes/pkg/kubectl/plugins/examples/aging/aging.rb
generated
vendored
Executable file
@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'json'
|
||||
require 'date'
|
||||
|
||||
class Numeric
|
||||
def duration
|
||||
secs = self.to_int
|
||||
mins = secs / 60
|
||||
hours = mins / 60
|
||||
days = hours / 24
|
||||
|
||||
if days > 0
|
||||
"#{days} days and #{hours % 24} hours"
|
||||
elsif hours > 0
|
||||
"#{hours} hours and #{mins % 60} minutes"
|
||||
elsif mins > 0
|
||||
"#{mins} minutes and #{secs % 60} seconds"
|
||||
elsif secs >= 0
|
||||
"#{secs} seconds"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace = ENV['KUBECTL_PLUGINS_CURRENT_NAMESPACE'] || 'default'
|
||||
pods_json = `kubectl --namespace #{namespace} get pods -o json`
|
||||
pods_parsed = JSON.parse(pods_json)
|
||||
|
||||
puts "The Magnificent Aging Plugin."
|
||||
|
||||
data = Hash.new
|
||||
max_name_length = 0
|
||||
max_age = 0
|
||||
min_age = 0
|
||||
|
||||
pods_parsed['items'].each { |pod|
|
||||
name = pod['metadata']['name']
|
||||
creation = pod['metadata']['creationTimestamp']
|
||||
|
||||
age = Time.now - DateTime.parse(creation).to_time
|
||||
data[name] = age
|
||||
|
||||
if name.length > max_name_length
|
||||
max_name_length = name.length
|
||||
end
|
||||
if age > max_age
|
||||
max_age = age
|
||||
end
|
||||
if age < min_age
|
||||
min_age = age
|
||||
end
|
||||
}
|
||||
|
||||
data = data.sort_by{ |name, age| age }
|
||||
|
||||
if data.length > 0
|
||||
puts ""
|
||||
data.each { |name, age|
|
||||
output = ""
|
||||
output += name.rjust(max_name_length, ' ') + ": "
|
||||
bar_size = (age*80/max_age).ceil
|
||||
bar_size.times{ output += "▒" }
|
||||
output += " " + age.duration
|
||||
puts output
|
||||
puts ""
|
||||
}
|
||||
else
|
||||
puts "No pods"
|
||||
end
|
||||
|
5
vendor/k8s.io/kubernetes/pkg/kubectl/plugins/examples/aging/plugin.yaml
generated
vendored
Normal file
5
vendor/k8s.io/kubernetes/pkg/kubectl/plugins/examples/aging/plugin.yaml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
name: "aging"
|
||||
shortDesc: "Aging shows pods by age"
|
||||
longDesc: >
|
||||
Aging shows pods from the current namespace by age.
|
||||
command: ./aging.rb
|
3
vendor/k8s.io/kubernetes/pkg/kubectl/plugins/examples/hello/plugin.yaml
generated
vendored
Normal file
3
vendor/k8s.io/kubernetes/pkg/kubectl/plugins/examples/hello/plugin.yaml
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
name: "hello"
|
||||
shortDesc: "I say hello!"
|
||||
command: "echo Hello plugins!"
|
Reference in New Issue
Block a user