def select_a_server(name, url)
      # no url, no name, try to use current master
      if url.nil? && name.nil?
        if config.current_master
          return config.current_master
        else
          exit_with_error 'URL not specified and current master not selected'
        end
      end

      if name && url
        exact_match = config.find_server_by(url: url, name: name)
        return exact_match if exact_match # found an exact match, going to use that one.

        name_match = config.find_server(name)

        if name_match
          #found a server with the provided name, set the provided url to it and return
          name_match.url = url
          return name_match
        else
          # nothing found, create new.
          return Kontena::Cli::Config::Server.new(name: name, url: url)
        end
      elsif name
        # only --name provided, try to find a server with that name
        name_match = config.find_server(name)

        if name_match && name_match.url
          return name_match
        else
          exit_with_error "Master #{name} was found from config, but it does not have an URL and no URL was provided on command line"
        end
      elsif url
        # only url provided
        if url =~ /^https?:\/\//
          # url is actually an url
          url_match = config.find_server_by(url: url)
          if url_match
            return url_match
          else
            return Kontena::Cli::Config::Server.new(url: url, name: nil)
          end
        else
          name_match = config.find_server(url)
          if name_match
            unless name_match.url
              exit_with_error "Master #{url} was found from config, but it does not have an URL and no URL was provided on command line"
            end
            return name_match
          else
            exit_with_error "Can't find a master with name #{name} from configuration"
          end
        end
      end
    end
def select_a_server(name, url)
      # no url, no name, try to use current master
      if url.nil? && name.nil?
        if config.current_master
          return config.current_master
        else
          exit_with_error 'URL not specified and current master not selected'
        end
      end

      if name && url
        exact_match = config.find_server_by(url: url, name: name)
        return exact_match if exact_match # found an exact match, going to use that one.

        name_match = config.find_server(name)

        if name_match
          #found a server with the provided name, set the provided url to it and return
          name_match.url = url
          return name_match
        else
          # nothing found, create new.
          return Kontena::Cli::Config::Server.new(name: name, url: url)
        end
      elsif name
        # only --name provided, try to find a server with that name
        name_match = config.find_server(name)

        if name_match && name_match.url
          return name_match
        else
          exit_with_error "Master #{name} was found from config, but it does not have an URL and no URL was provided on command line"
        end
      elsif url
        # only url provided
        if url =~ /^https?:\/\//
          # url is actually an url
          url_match = config.find_server_by(url: url)
          if url_match
            return url_match
          else
            return Kontena::Cli::Config::Server.new(url: url, name: nil)
          end
        else
          name_match = config.find_server(url)
          if name_match
            unless name_match.url
              exit_with_error "Master #{url} was found from config, but it does not have an URL and no URL was provided on command line"
            end
            return name_match
          else
            exit_with_error "Can't find a master with name #{name} from configuration"
          end
        end
      end
    end
Figure out or create a server based on url or name.

 No name or url provided: try to use current_master
 A name provided with --name but no url defined: try to find a server by name from config
 An URL starting with 'http' provided: try to find a server by url from config
 An URL not starting with 'http' provided: try to find a server by name
 An URL and a name provided
  - If a server is found by name: use entry and update URL to the provided url
  - Else create a new entry with the url and name

 @param name [String] master name
 @param url [String] master url or name
 @return [Kontena::Cli::Config::Server]