Class: Kerbi::RunOpts
- Inherits:
-
Object
- Object
- Kerbi::RunOpts
- Defined in:
- lib/config/run_opts.rb
Overview
Convenience accessor struct for getting values from the CLI args. noinspection RubyTooManyMethodsInspection
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#project_uri ⇒ Object
Returns the value of attribute project_uri.
-
#release_name ⇒ Object
Returns the value of attribute release_name.
Instance Method Summary collapse
- #cluster_namespace ⇒ String
- #confirmed? ⇒ TrueClass, FalseClass
- #fname_exprs ⇒ Array<String>
- #in_cluster? ⇒ TrueClass, FalseClass
- #initialize(cli_opts, defaults) ⇒ Kerbi::RunOpts constructor
- #inline_val_exprs ⇒ Array<String>
- #k8s_auth_password ⇒ String
- #k8s_auth_token ⇒ String
- #k8s_auth_type ⇒ String
- #k8s_auth_username ⇒ String
- #kube_config_path ⇒ String
- #kube_context_name ⇒ String
- #load_defaults? ⇒ TrueClass, FalseClass
- #local_engine? ⇒ Boolean
- #output_format ⇒ String
- #output_json? ⇒ TrueClass, FalseClass
- #output_table? ⇒ TrueClass, FalseClass
- #output_yaml? ⇒ TrueClass, FalseClass
- #project_root ⇒ String
- #read_state_from ⇒ String
- #reads_state? ⇒ TrueClass, FalseClass
- #reads_state_strictly? ⇒ TrueClass, FalseClass
- #remote_engine? ⇒ Boolean
- #revision_tag ⇒ ?String
- #ruby_version ⇒ String
- #state_backend_type ⇒ String
- #verbose? ⇒ TrueClass, FalseClass
- #write_state_msg ⇒ String
- #write_state_to ⇒ String
- #writes_state? ⇒ TrueClass, FalseClass
Constructor Details
#initialize(cli_opts, defaults) ⇒ Kerbi::RunOpts
16 17 18 19 20 21 |
# File 'lib/config/run_opts.rb', line 16 def initialize(cli_opts, defaults) @options = defaults.deep_dup. merge(Kerbi::ConfigFile.read.deep_dup). merge(cli_opts.deep_dup). freeze end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/config/run_opts.rb', line 9 def @options end |
#project_uri ⇒ Object
Returns the value of attribute project_uri.
11 12 13 |
# File 'lib/config/run_opts.rb', line 11 def project_uri @project_uri end |
#release_name ⇒ Object
Returns the value of attribute release_name.
10 11 12 |
# File 'lib/config/run_opts.rb', line 10 def release_name @release_name end |
Instance Method Details
#cluster_namespace ⇒ String
105 106 107 |
# File 'lib/config/run_opts.rb', line 105 def cluster_namespace [consts::NAMESPACE] end |
#confirmed? ⇒ TrueClass, FalseClass
164 165 166 |
# File 'lib/config/run_opts.rb', line 164 def confirmed? [consts::PRE_CONFIRM].present? end |
#fname_exprs ⇒ Array<String>
50 51 52 |
# File 'lib/config/run_opts.rb', line 50 def fname_exprs [consts::VALUE_FNAMES] end |
#in_cluster? ⇒ TrueClass, FalseClass
159 160 161 |
# File 'lib/config/run_opts.rb', line 159 def in_cluster? k8s_auth_type == 'in-cluster' end |
#inline_val_exprs ⇒ Array<String>
55 56 57 |
# File 'lib/config/run_opts.rb', line 55 def inline_val_exprs [consts::INLINE_ASSIGNMENT] end |
#k8s_auth_password ⇒ String
121 122 123 |
# File 'lib/config/run_opts.rb', line 121 def k8s_auth_password [consts::K8S_PASSWORD] end |
#k8s_auth_token ⇒ String
126 127 128 |
# File 'lib/config/run_opts.rb', line 126 def k8s_auth_token [consts::K8S_TOKEN] end |
#k8s_auth_type ⇒ String
154 155 156 |
# File 'lib/config/run_opts.rb', line 154 def k8s_auth_type [consts::K8S_AUTH_TYPE] end |
#k8s_auth_username ⇒ String
116 117 118 |
# File 'lib/config/run_opts.rb', line 116 def k8s_auth_username [consts::K8S_USERNAME] end |
#kube_config_path ⇒ String
95 96 97 |
# File 'lib/config/run_opts.rb', line 95 def kube_config_path [consts::KUBE_CONFIG_PATH] end |
#kube_context_name ⇒ String
100 101 102 |
# File 'lib/config/run_opts.rb', line 100 def kube_context_name [consts::KUBE_CONFIG_CONTEXT] end |
#load_defaults? ⇒ TrueClass, FalseClass
60 61 62 |
# File 'lib/config/run_opts.rb', line 60 def load_defaults? [consts::LOAD_DEFAULT_VALUES].present? end |
#local_engine? ⇒ Boolean
149 150 151 |
# File 'lib/config/run_opts.rb', line 149 def local_engine? !remote_engine? end |
#output_format ⇒ String
24 25 26 27 |
# File 'lib/config/run_opts.rb', line 24 def output_format value = [consts::OUTPUT_FMT] value || default end |
#output_json? ⇒ TrueClass, FalseClass
40 41 42 |
# File 'lib/config/run_opts.rb', line 40 def output_json? self.output_format == 'json' end |
#output_table? ⇒ TrueClass, FalseClass
35 36 37 |
# File 'lib/config/run_opts.rb', line 35 def output_table? self.output_format == 'table' end |
#output_yaml? ⇒ TrueClass, FalseClass
30 31 32 |
# File 'lib/config/run_opts.rb', line 30 def output_yaml? self.output_format == 'yaml' end |
#project_root ⇒ String
136 137 138 |
# File 'lib/config/run_opts.rb', line 136 def project_root [consts::PROJECT_ROOT].presence || project_uri end |
#read_state_from ⇒ String
65 66 67 |
# File 'lib/config/run_opts.rb', line 65 def read_state_from [consts::READ_STATE].presence end |
#reads_state? ⇒ TrueClass, FalseClass
80 81 82 |
# File 'lib/config/run_opts.rb', line 80 def reads_state? read_state_from.present? end |
#reads_state_strictly? ⇒ TrueClass, FalseClass
85 86 87 |
# File 'lib/config/run_opts.rb', line 85 def reads_state_strictly? [consts::STRICT_READ_STATE] end |
#remote_engine? ⇒ Boolean
145 146 147 |
# File 'lib/config/run_opts.rb', line 145 def remote_engine? revision_tag.present? end |
#revision_tag ⇒ ?String
141 142 143 |
# File 'lib/config/run_opts.rb', line 141 def revision_tag [consts::REVISION_TAG].presence end |
#ruby_version ⇒ String
45 46 47 |
# File 'lib/config/run_opts.rb', line 45 def ruby_version [consts::RUBY_VER] end |
#state_backend_type ⇒ String
110 111 112 113 |
# File 'lib/config/run_opts.rb', line 110 def state_backend_type value = [consts::STATE_BACKEND_TYPE] value.is_a?(String) ? value : '' end |
#verbose? ⇒ TrueClass, FalseClass
75 76 77 |
# File 'lib/config/run_opts.rb', line 75 def verbose? [consts::VERBOSE].present? end |
#write_state_msg ⇒ String
131 132 133 |
# File 'lib/config/run_opts.rb', line 131 def write_state_msg [consts::WRITE_STATE_MESSAGE] end |
#write_state_to ⇒ String
70 71 72 |
# File 'lib/config/run_opts.rb', line 70 def write_state_to [consts::WRITE_STATE].presence end |
#writes_state? ⇒ TrueClass, FalseClass
90 91 92 |
# File 'lib/config/run_opts.rb', line 90 def writes_state? write_state_to.present? end |