6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/kube_deploy_tools/make_configmap/options.rb', line 6
def options
$options ||= begin
res = {from_file: [], labels: {}}
OptionParser.new do |opts|
opts.banner = "Usage: #{opts.program_name}.rb [options]. Outputs YAML to STDOUT"
opts.on("--name [NAME]", "ConfigMap name") do |v|
res[:name] = v
end
res[:namespace] = "default"
opts.on("--namespace [NAMESPACE]", "ConfigMap namespace") do |v|
res[:namespace] = v
end
opts.on("--label [NAME=VALUE]", "ConfigMap metadata label") do |v|
res[:labels].store(*v.split('=', 2))
end
opts.on("--from-file [KEYFILE]", "Key file can be specified using its file path, in which case file basename will be used as
configmap key, or optionally with a key and file path, in which case the given key will be used. Specifying a directory
will iterate each named file in the directory whose basename is a valid configmap key.") do |v|
res[:from_file] << v
end
end.parse!
raise "no name given" unless res[:name].strip != ''
raise "no files given" if res[:from_file].empty?
res
end
end
|