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)


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

def cluster_namespace
  options[consts::NAMESPACE]
end

#confirmed?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


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

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

#fname_exprsArray<String>

Returns:

  • (Array<String>)


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

def fname_exprs
  options[consts::VALUE_FNAMES]
end

#in_cluster?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


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

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

#inline_val_exprsArray<String>

Returns:

  • (Array<String>)


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

def inline_val_exprs
  options[consts::INLINE_ASSIGNMENT]
end

#k8s_auth_passwordString

Returns:

  • (String)


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

def k8s_auth_password
  options[consts::K8S_PASSWORD]
end

#k8s_auth_tokenString

Returns:

  • (String)


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

def k8s_auth_token
  options[consts::K8S_TOKEN]
end

#k8s_auth_typeString

Returns:

  • (String)


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

def k8s_auth_type
  options[consts::K8S_AUTH_TYPE]
end

#k8s_auth_usernameString

Returns:

  • (String)


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

def k8s_auth_username
  options[consts::K8S_USERNAME]
end

#kube_config_pathString

Returns:

  • (String)


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

def kube_config_path
  options[consts::KUBE_CONFIG_PATH]
end

#kube_context_nameString

Returns:

  • (String)


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

def kube_context_name
  options[consts::KUBE_CONFIG_CONTEXT]
end

#load_defaults?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


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

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

#local_engine?Boolean

Returns:

  • (Boolean)


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

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)


40
41
42
# File 'lib/config/run_opts.rb', line 40

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

#output_table?TrueClass, FalseClass

Returns:

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

Returns:

  • (TrueClass, FalseClass)


30
31
32
# File 'lib/config/run_opts.rb', line 30

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

#project_rootString

Returns:

  • (String)


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

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

#read_state_fromString

Returns:

  • (String)


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

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

#reads_state?TrueClass, FalseClass

Returns:

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

Returns:

  • (TrueClass, FalseClass)


85
86
87
# File 'lib/config/run_opts.rb', line 85

def reads_state_strictly?
  options[consts::STRICT_READ_STATE]
end

#remote_engine?Boolean

Returns:

  • (Boolean)


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

def remote_engine?
  revision_tag.present?
end

#revision_tag?String

Returns:

  • (?String)


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

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

#ruby_versionString

Returns:

  • (String)


45
46
47
# File 'lib/config/run_opts.rb', line 45

def ruby_version
  options[consts::RUBY_VER]
end

#state_backend_typeString

Returns:

  • (String)


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

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

#verbose?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


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

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

#write_state_msgString

Returns:

  • (String)


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

def write_state_msg
  options[consts::WRITE_STATE_MESSAGE]
end

#write_state_toString

Returns:

  • (String)


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

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

#writes_state?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


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

def writes_state?
  write_state_to.present?
end