Class: KubeDeployTools::Generate::Optparser::Options
- Defined in:
- lib/kube_deploy_tools/generate/options.rb
Instance Attribute Summary collapse
-
#file_filters ⇒ Object
Returns the value of attribute file_filters.
-
#input_path ⇒ Object
Returns the value of attribute input_path.
-
#literals ⇒ Object
Returns the value of attribute literals.
-
#manifest_file ⇒ Object
Returns the value of attribute manifest_file.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#print_flags_only ⇒ Object
Returns the value of attribute print_flags_only.
Instance Method Summary collapse
- #define_options(parser) ⇒ Object
-
#initialize ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize ⇒ Options
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_filters ⇒ Object
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_path ⇒ Object
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 |
#literals ⇒ Object
Returns the value of attribute literals.
6 7 8 |
# File 'lib/kube_deploy_tools/generate/options.rb', line 6 def literals @literals end |
#manifest_file ⇒ Object
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_path ⇒ Object
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 |
#print_flags_only ⇒ Object
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 (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 |