Class: Kerbi::RunOpts

Inherits:
Object
  • Object
show all
Defined in:
lib/config/run_opts.rb

Overview

Convenience accessor struct for getting values from the CLI args. noinspection RubyTooManyMethodsInspection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli_opts, defaults) ⇒ Kerbi::RunOpts

Parameters:

  • cli_opts (Hash{Symbol, Object})

    CLI args as a hash via Thor

  • defaults (Hash{Symbol, Object})

    contextual defaults (per cmd)



14
15
16
17
18
19
# File 'lib/config/run_opts.rb', line 14

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

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/config/run_opts.rb', line 9

def options
  @options
end

Instance Method Details

#cluster_namespaceString

Returns:

  • (String)


108
109
110
# File 'lib/config/run_opts.rb', line 108

def cluster_namespace
  options[consts::NAMESPACE]
end

#fname_exprsArray<String>

Returns:

  • (Array<String>)


48
49
50
# File 'lib/config/run_opts.rb', line 48

def fname_exprs
  options[consts::VALUE_FNAMES]
end

#inline_val_exprsArray<String>

Returns:

  • (Array<String>)


53
54
55
# File 'lib/config/run_opts.rb', line 53

def inline_val_exprs
  options[consts::INLINE_ASSIGNMENT]
end

#k8s_auth_passwordString

Returns:

  • (String)


123
124
125
# File 'lib/config/run_opts.rb', line 123

def k8s_auth_password
  options[consts::K8S_PASSWORD]
end

#k8s_auth_tokenString

Returns:

  • (String)


128
129
130
# File 'lib/config/run_opts.rb', line 128

def k8s_auth_token
  options[consts::K8S_TOKEN]
end

#k8s_auth_typeString

Returns:

  • (String)


93
94
95
# File 'lib/config/run_opts.rb', line 93

def k8s_auth_type
  options[consts::K8S_AUTH_TYPE]
end

#k8s_auth_usernameString

Returns:

  • (String)


118
119
120
# File 'lib/config/run_opts.rb', line 118

def k8s_auth_username
  options[consts::K8S_USERNAME]
end

#kube_config_pathString

Returns:

  • (String)


98
99
100
# File 'lib/config/run_opts.rb', line 98

def kube_config_path
  options[consts::KUBE_CONFIG_PATH]
end

#kube_context_nameString

Returns:

  • (String)


103
104
105
# File 'lib/config/run_opts.rb', line 103

def kube_context_name
  options[consts::KUBE_CONFIG_CONTEXT]
end

#load_defaults?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


58
59
60
# File 'lib/config/run_opts.rb', line 58

def load_defaults?
  options[consts::LOAD_DEFAULT_VALUES].present?
end

#output_formatString

Returns:

  • (String)


22
23
24
25
# File 'lib/config/run_opts.rb', line 22

def output_format
  value = options[consts::OUTPUT_FMT]
  value || default
end

#output_json?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


38
39
40
# File 'lib/config/run_opts.rb', line 38

def output_json?
  self.output_format == 'json'
end

#output_table?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


33
34
35
# File 'lib/config/run_opts.rb', line 33

def output_table?
  self.output_format == 'table'
end

#output_yaml?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


28
29
30
# File 'lib/config/run_opts.rb', line 28

def output_yaml?
  self.output_format == 'yaml'
end

#project_rootString

Returns:

  • (String)


138
139
140
# File 'lib/config/run_opts.rb', line 138

def project_root
  options[consts::PROJECT_ROOT].presence
end

#read_state_fromString

Returns:

  • (String)


63
64
65
# File 'lib/config/run_opts.rb', line 63

def read_state_from
  options[consts::READ_STATE].presence
end

#reads_state?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


78
79
80
# File 'lib/config/run_opts.rb', line 78

def reads_state?
  read_state_from.present?
end

#reads_state_strictly?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


83
84
85
# File 'lib/config/run_opts.rb', line 83

def reads_state_strictly?
  options[consts::STRICT_READ_STATE]
end

#ruby_versionString

Returns:

  • (String)


43
44
45
# File 'lib/config/run_opts.rb', line 43

def ruby_version
  options[consts::RUBY_VER]
end

#state_backend_typeString

Returns:

  • (String)


113
114
115
# File 'lib/config/run_opts.rb', line 113

def state_backend_type
  options[consts::STATE_BACKEND_TYPE]
end

#verbose?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


73
74
75
# File 'lib/config/run_opts.rb', line 73

def verbose?
  options[consts::VERBOSE].present?
end

#write_state_msgString

Returns:

  • (String)


133
134
135
# File 'lib/config/run_opts.rb', line 133

def write_state_msg
  options[consts::WRITE_STATE_MESSAGE]
end

#write_state_toString

Returns:

  • (String)


68
69
70
# File 'lib/config/run_opts.rb', line 68

def write_state_to
  options[consts::WRITE_STATE].presence
end

#writes_state?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


88
89
90
# File 'lib/config/run_opts.rb', line 88

def writes_state?
  write_state_to.present?
end