Class: KubeDeployTools::Generate::Optparser::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/kube_deploy_tools/generate/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



8
9
10
11
12
13
# File 'lib/kube_deploy_tools/generate/options.rb', line 8

def initialize
  self.input_path = File.join('kubernetes/')
  self.output_path = File.join('build', 'kubernetes')
  self.file_filters = []
  self.literals = {}
end

Instance Attribute Details

#file_filtersObject

Returns the value of attribute file_filters.



6
7
8
# File 'lib/kube_deploy_tools/generate/options.rb', line 6

def file_filters
  @file_filters
end

#input_pathObject

Returns the value of attribute input_path.



6
7
8
# File 'lib/kube_deploy_tools/generate/options.rb', line 6

def input_path
  @input_path
end

#literalsObject

Returns the value of attribute literals.



6
7
8
# File 'lib/kube_deploy_tools/generate/options.rb', line 6

def literals
  @literals
end

#manifest_fileObject

Returns the value of attribute manifest_file.



6
7
8
# File 'lib/kube_deploy_tools/generate/options.rb', line 6

def manifest_file
  @manifest_file
end

#output_pathObject

Returns the value of attribute output_path.



6
7
8
# File 'lib/kube_deploy_tools/generate/options.rb', line 6

def output_path
  @output_path
end

Returns the value of attribute print_flags_only.



6
7
8
# File 'lib/kube_deploy_tools/generate/options.rb', line 6

def print_flags_only
  @print_flags_only
end

Instance Method Details

#define_options(parser) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/kube_deploy_tools/generate/options.rb', line 15

def define_options(parser)
  parser.on('-mMANIFEST', '--manifest MANIFEST', 'The configuration MANIFEST to render deploys with.') do |f|
    self.manifest_file = f
  end

  parser.on('-iPATH', '--input-path PATH', 'Path where Kubernetes manifests and manifest templates (.erb) are located.') do |p|
    self.input_path = p
  end

  parser.on('-oPATH', '--output-path PATH', 'Path where rendered manifests should be written.') do |p|
    self.output_path = p
  end

  parser.on('-p', '--print', 'Print all available ERB config values only.') do |p|
    self.print_flags_only = p
  end

  parser.on('--from-literal KEY=VALUE', "Specify a key and literal value in the ERB context e.g. mykey=myvalue") do |p|
    parts = p.split('=')
    raise ArgumentError, "Expected --from-literal to be in the format key=value, but got '#{p}'" if parts.length != 2
    key, value = parts
    self.literals[key] = value
  end

  parser.on('--include INCLUDE', "Include glob pattern. Example: --include=**/* will include every file. Default is ''.") do |p|
    self.file_filters.push(["include_files", p])
  end

  parser.on('--exclude EXCLUDE', "Exclude glob pattern. Example: --exclude=**/gazette/* will exclude every file in gazette folder. Default is ''.") do |p|
    self.file_filters.push(["exclude_files", p])
  end

  parser.on('--include-dir INCLUDE', "Recursively include all files in a directory and its subdirectories. Example: --include-dir=gazette/ (equivalent of --include=**/gazette/**/*)") do |p|
    self.file_filters.push(["include_dir", p])
  end

  parser.on('--exclude-dir EXCLUDE', "Recursively exclude all files in a directory and its subdirectories. Example: --exclude-dir=gazette/ (equivalent of --exclude=**/gazette/**/*)") do |p|
    self.file_filters.push(["exclude_dir", p])
  end
end