Module: Uffizzi::ConfigHelper
- Defined in:
- lib/uffizzi/helpers/config_helper.rb
Defined Under Namespace
Classes: ConfigParamsError
Constant Summary
collapse
- CLUSTER_PARAMS =
[:kubeconfig_path, :name].freeze
Class Method Summary
collapse
Class Method Details
.account_config(id:, name: nil, has_installation: false, vclusters_controller_url: nil) ⇒ Object
20
21
22
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 20
def account_config(id:, name: nil, has_installation: false, vclusters_controller_url: nil)
{ id: id, name: name, has_installation: has_installation, vclusters_controller_url: vclusters_controller_url }
end
|
.cluster_config_by_id(id) ⇒ Object
38
39
40
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 38
def cluster_config_by_id(id)
clusters.detect { |c| c[:id] == id }
end
|
.clusters_config_without(id) ⇒ Object
34
35
36
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 34
def clusters_config_without(id)
clusters.reject { |c| c[:id] == id }
end
|
.dev_environment ⇒ Object
59
60
61
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 59
def dev_environment
read_option_from_config(:dev_environment) || {}
end
|
.previous_current_context_by_path(path) ⇒ Object
51
52
53
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 51
def previous_current_context_by_path(path)
cluster_previous_current_contexts.detect { |c| c[:kubeconfig_path] == path }
end
|
.previous_current_contexts_without(path) ⇒ Object
47
48
49
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 47
def previous_current_contexts_without(path)
cluster_previous_current_contexts.reject { |c| c[:kubeconfig_path] == path }
end
|
.read_account_config ⇒ Object
63
64
65
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 63
def read_account_config
read_option_from_config(:account)
end
|
.read_option_from_config(option) ⇒ Object
.set_dev_environment(cluster_name, params = {}) ⇒ Object
55
56
57
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 55
def set_dev_environment(cluster_name, params = {})
{ cluster_name: cluster_name }.merge(params)
end
|
.set_previous_current_context_by_path(path, current_context) ⇒ Object
42
43
44
45
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 42
def set_previous_current_context_by_path(path, current_context)
current_contexts = previous_current_contexts_without(path)
current_contexts << { current_context: current_context, kubeconfig_path: path }
end
|
.update_clusters_config_by_id(id, params) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/uffizzi/helpers/config_helper.rb', line 24
def update_clusters_config_by_id(id, params)
unavailable_params = params.keys - CLUSTER_PARAMS
raise ConfigParamsError.new(unavailable_params, :cluster) if unavailable_params.present?
current_cluster = cluster_config_by_id(id) || {}
new_current_cluster = current_cluster.merge({ id: id }).merge(params)
clusters_config_without(id) << new_current_cluster
end
|