Sha256: 98a0650e0d8eb45665e91bae544befa79a01de3d1f21e556a639393049bb4287

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'uffizzi/helpers/config_helper'
require 'uffizzi/services/cluster/common_service'
require 'uffizzi/services/kubeconfig_service'

class ClusterCreateService
  class << self
    def save_kubeconfig(kubeconfig, kubeconfig_path, is_update_current_context)
      kubeconfig_path = kubeconfig_path.nil? ? KubeconfigService.default_path : kubeconfig_path
      KubeconfigService.save_to_filepath(kubeconfig_path, kubeconfig) do |kubeconfig_by_path|
        merged_kubeconfig = KubeconfigService.merge(kubeconfig_by_path, kubeconfig)

        if is_update_current_context
          new_current_context = KubeconfigService.get_current_context(kubeconfig)
          new_kubeconfig = KubeconfigService.update_current_context(merged_kubeconfig, new_current_context)

          next new_kubeconfig if kubeconfig_by_path.nil?

          previous_current_context = KubeconfigService.get_current_context(kubeconfig_by_path)
          ClusterCommonService.save_previous_current_context(kubeconfig_path, previous_current_context)
          new_kubeconfig
        else
          merged_kubeconfig
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
uffizzi-cli-2.4.11 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.10 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.9 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.8 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.7 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.6 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.5 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.4 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.3 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.2 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.1 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.4.0 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.3.4 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.3.3 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.3.2 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.3.1 lib/uffizzi/services/cluster/create_service.rb
uffizzi-cli-2.3.0 lib/uffizzi/services/cluster/create_service.rb