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