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
109 110 111 |
# File 'lib/config/run_opts.rb', line 109 def cluster_namespace [consts::NAMESPACE] end |
#confirmed? ⇒ TrueClass, FalseClass
168 169 170 |
# File 'lib/config/run_opts.rb', line 168 def confirmed? [consts::PRE_CONFIRM].present? end |
#fname_exprs ⇒ Array<String>
54 55 56 |
# File 'lib/config/run_opts.rb', line 54 def fname_exprs [consts::VALUE_FNAMES] end |
#in_cluster? ⇒ TrueClass, FalseClass
163 164 165 |
# File 'lib/config/run_opts.rb', line 163 def in_cluster? k8s_auth_type == 'in-cluster' end |
#inline_val_exprs ⇒ Array<String>
59 60 61 |
# File 'lib/config/run_opts.rb', line 59 def inline_val_exprs [consts::INLINE_ASSIGNMENT] end |
#k8s_auth_password ⇒ String
125 126 127 |
# File 'lib/config/run_opts.rb', line 125 def k8s_auth_password [consts::K8S_PASSWORD] end |
#k8s_auth_token ⇒ String
130 131 132 |
# File 'lib/config/run_opts.rb', line 130 def k8s_auth_token [consts::KUBE_ACCESS_TOKEN] end |
#k8s_auth_type ⇒ String
158 159 160 |
# File 'lib/config/run_opts.rb', line 158 def k8s_auth_type [consts::K8S_AUTH_TYPE] end |
#k8s_auth_username ⇒ String
120 121 122 |
# File 'lib/config/run_opts.rb', line 120 def k8s_auth_username [consts::K8S_USERNAME] end |
#kube_config_path ⇒ String
99 100 101 |
# File 'lib/config/run_opts.rb', line 99 def kube_config_path [consts::KUBE_CONFIG_PATH] end |
#kube_context_name ⇒ String
104 105 106 |
# File 'lib/config/run_opts.rb', line 104 def kube_context_name [consts::KUBE_CONFIG_CONTEXT] end |
#load_defaults? ⇒ TrueClass, FalseClass
64 65 66 |
# File 'lib/config/run_opts.rb', line 64 def load_defaults? [consts::LOAD_DEFAULT_VALUES].present? end |
#local_engine? ⇒ Boolean
153 154 155 |
# File 'lib/config/run_opts.rb', line 153 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
44 45 46 |
# File 'lib/config/run_opts.rb', line 44 def output_json? self.output_format == 'json' end |
#output_table? ⇒ TrueClass, FalseClass
39 40 41 |
# File 'lib/config/run_opts.rb', line 39 def output_table? self.output_format == 'table' end |
#output_yaml? ⇒ TrueClass, FalseClass
34 35 36 |
# File 'lib/config/run_opts.rb', line 34 def output_yaml? self.output_format == 'yaml' end |
#project_root ⇒ String
140 141 142 |
# File 'lib/config/run_opts.rb', line 140 def project_root [consts::PROJECT_ROOT].presence || project_uri end |
#read_state_from ⇒ String
69 70 71 |
# File 'lib/config/run_opts.rb', line 69 def read_state_from [consts::READ_STATE].presence end |
#reads_state? ⇒ TrueClass, FalseClass
84 85 86 |
# File 'lib/config/run_opts.rb', line 84 def reads_state? read_state_from.present? end |
#reads_state_strictly? ⇒ TrueClass, FalseClass
89 90 91 |
# File 'lib/config/run_opts.rb', line 89 def reads_state_strictly? [consts::STRICT_READ_STATE] end |
#remote_engine? ⇒ Boolean
149 150 151 |
# File 'lib/config/run_opts.rb', line 149 def remote_engine? revision_tag.present? end |
#revision_tag ⇒ ?String
145 146 147 |
# File 'lib/config/run_opts.rb', line 145 def revision_tag [consts::REVISION_TAG].presence end |
#ruby_version ⇒ String
49 50 51 |
# File 'lib/config/run_opts.rb', line 49 def ruby_version [consts::RUBY_VER] end |
#state_backend_type ⇒ String
114 115 116 117 |
# File 'lib/config/run_opts.rb', line 114 def state_backend_type value = [consts::STATE_BACKEND_TYPE] value.is_a?(String) ? value : '' end |
#verbose? ⇒ TrueClass, FalseClass
79 80 81 |
# File 'lib/config/run_opts.rb', line 79 def verbose? [consts::VERBOSE].present? end |
#write_state_msg ⇒ String
135 136 137 |
# File 'lib/config/run_opts.rb', line 135 def write_state_msg [consts::WRITE_STATE_MESSAGE] end |
#write_state_to ⇒ String
74 75 76 |
# File 'lib/config/run_opts.rb', line 74 def write_state_to [consts::WRITE_STATE].presence end |
#writes_state? ⇒ TrueClass, FalseClass
94 95 96 |
# File 'lib/config/run_opts.rb', line 94 def writes_state? write_state_to.present? end |