class Kontena::Cli::Grids::TrustedSubnets::RemoveCommand

Public Instance Methods

execute() click to toggle source
# File lib/kontena/cli/grids/trusted_subnets/remove_command.rb, line 11
def execute
  subnets.each do |subnet|
    grid = client.get("grids/#{current_grid}")
    confirm_command(subnet) unless forced?
    trusted_subnets = grid['trusted_subnets'] || []
    unless trusted_subnets.delete(subnet)
      exit_with_error("Grid #{pastel.cyan(current_grid)} does not have trusted subnet #{pastel.cyan(subnet)}")
    end
    data = {trusted_subnets: trusted_subnets}
    spinner "Removing trusted subnet #{pastel.cyan(subnet)} from #{pastel.cyan(current_grid)} grid " do
      client.put("grids/#{current_grid}", data)
    end
  end
end