Sha256: 8515b6dc09362dddf7e2c71116f73419260b3e35dc6840d11f52f677591f7aa2
Contents?: true
Size: 1.08 KB
Versions: 17
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require 'uffizzi/helpers/config_helper' require 'uffizzi/services/kubeconfig_service' class ClusterDeleteService class << self 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 end end
Version data entries
17 entries across 17 versions & 1 rubygems