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)



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

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#project_uriObject

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_nameObject

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_namespaceString

Returns:

  • (String)


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

def cluster_namespace
  options[consts::NAMESPACE]
end

#confirmed?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


168
169
170
# File 'lib/config/run_opts.rb', line 168

def confirmed?
  options[consts::PRE_CONFIRM].present?
end

#fname_exprsArray<String>

Returns:

  • (Array<String>)


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

def fname_exprs
  options[consts::VALUE_FNAMES]
end

#in_cluster?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


163
164
165
# File 'lib/config/run_opts.rb', line 163

def in_cluster?
  k8s_auth_type == 'in-cluster'
end

#inline_val_exprsArray<String>

Returns:

  • (Array<String>)


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

def inline_val_exprs
  options[consts::INLINE_ASSIGNMENT]
end

#k8s_auth_passwordString

Returns:

  • (String)


125
126
127
# File 'lib/config/run_opts.rb', line 125

def k8s_auth_password
  options[consts::K8S_PASSWORD]
end

#k8s_auth_tokenString

Returns:

  • (String)


130
131
132
# File 'lib/config/run_opts.rb', line 130

def k8s_auth_token
  options[consts::KUBE_ACCESS_TOKEN]
end

#k8s_auth_typeString

Returns:

  • (String)


158
159
160
# File 'lib/config/run_opts.rb', line 158

def k8s_auth_type
  options[consts::K8S_AUTH_TYPE]
end

#k8s_auth_usernameString

Returns:

  • (String)


120
121
122
# File 'lib/config/run_opts.rb', line 120

def k8s_auth_username
  options[consts::K8S_USERNAME]
end

#kube_config_pathString

Returns:

  • (String)


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

def kube_config_path
  options[consts::KUBE_CONFIG_PATH]
end

#kube_context_nameString

Returns:

  • (String)


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

def kube_context_name
  options[consts::KUBE_CONFIG_CONTEXT]
end

#load_defaults?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


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

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

#local_engine?Boolean

Returns:

  • (Boolean)


153
154
155
# File 'lib/config/run_opts.rb', line 153

def local_engine?
  !remote_engine?
end

#output_formatString

Returns:

  • (String)


24
25
26
27
# File 'lib/config/run_opts.rb', line 24

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

#output_json?TrueClass, FalseClass

Returns:

  • (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

Returns:

  • (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

Returns:

  • (TrueClass, FalseClass)


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

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

#project_rootString

Returns:

  • (String)


140
141
142
# File 'lib/config/run_opts.rb', line 140

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

#read_state_fromString

Returns:

  • (String)


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

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

#reads_state?TrueClass, FalseClass

Returns:

  • (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

Returns:

  • (TrueClass, FalseClass)


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

def reads_state_strictly?
  options[consts::STRICT_READ_STATE]
end

#remote_engine?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'lib/config/run_opts.rb', line 149

def remote_engine?
  revision_tag.present?
end

#revision_tag?String

Returns:

  • (?String)


145
146
147
# File 'lib/config/run_opts.rb', line 145

def revision_tag
  options[consts::REVISION_TAG].presence
end

#ruby_versionString

Returns:

  • (String)


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

def ruby_version
  options[consts::RUBY_VER]
end

#state_backend_typeString

Returns:

  • (String)


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

def state_backend_type
  value = options[consts::STATE_BACKEND_TYPE]
  value.is_a?(String) ? value : ''
end

#verbose?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


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

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

#write_state_msgString

Returns:

  • (String)


135
136
137
# File 'lib/config/run_opts.rb', line 135

def write_state_msg
  options[consts::WRITE_STATE_MESSAGE]
end

#write_state_toString

Returns:

  • (String)


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

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

#writes_state?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


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

def writes_state?
  write_state_to.present?
end