8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/uffizzi/services/cluster/delete_service.rb', line 8
def exclude_kubeconfig(cluster_id, kubeconfig)
cluster_config = Uffizzi::ConfigHelper.cluster_config_by_id(cluster_id)
return if cluster_config.nil?
kubeconfig_path = cluster_config[:kubeconfig_path]
Uffizzi::ConfigFile.write_option(:clusters, Uffizzi::ConfigHelper.clusters_config_without(cluster_id))
KubeconfigService.save_to_filepath(kubeconfig_path, kubeconfig) do |kubeconfig_by_path|
if kubeconfig_by_path.nil?
msg = "Warning: kubeconfig at path #{kubeconfig_path} does not exist"
return Uffizzi.ui.say(msg)
end
new_kubeconfig = KubeconfigService.exclude(kubeconfig_by_path, kubeconfig)
first_context = KubeconfigService.get_first_context(new_kubeconfig)
new_current_context = first_context.present? ? first_context['name'] : nil
KubeconfigService.update_current_context(new_kubeconfig, new_current_context)
end
end
|