lib/k8s/kubeconfig/root.rb
# Rename a cluster. References in contexts will be updated.
# @param old_name [String] old cluster name
# @param new_name [String] new cluster name
# @return [String] new name
# @raise [ArgumentError] when cluster is not found or new name already exists
Rename a cluster. References in contexts will be updated.
Rename a cluster . References in contexts will be updated .
def rename_cluster(old_name, new_name)
        named_cluster = clusters.find { |c| c.name == old_name }
        raise ArgumentError, "cluster not found: #{old_name}" unless named_cluster
        raise ArgumentError, "cluster already exists: #{new_name}" if cluster(new_name)
        named_cluster.name = new_name
        contexts.each do |named_context|
          next unless named_context.context.cluster == old_name
          named_context.context.cluster = new_name
        end
        self.current_context = new_name if current_context == old_name
        new_name
      end
def rename_cluster ( old_name , new_name ) named_cluster = clusters . find { | c | c . name == old_name } raise ArgumentError , "cluster not found: #{old_name}" unless named_cluster raise ArgumentError , "cluster already exists: #{new_name}" if cluster ( new_name ) named_cluster . name = new_name contexts . each do | named_context | next unless named_context . context . cluster == old_name named_context . context . cluster = new_name end self . current_context = new_name if current_context == old_name new_name end
Rename a cluster.
Rename a cluster .
None
String
[ArgumentError] when cluster is not found or new name already exists
[ ArgumentError ] when cluster is not found or new name already exists
old_name
old cluster name
old cluster name
new_name
new cluster name
new cluster name