You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: config_validation.rb
    path of file: ./repos/chef/lib/chef/data_collector
    
    the code of the file until where you have to start completion: #
# Copyright:: Copyright (c) Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require "uri" unless defined?(URI)
require "chef-utils/dist" unless defined?(ChefUtils::Dist)

class Chef
  class DataCollector

    # @api private
    module ConfigValidation
      class << self
        def validate_server_url!
          # if we have a server_url set we ALWAYS validate it, and we MUST have an output_location set to skip server_url validation
          # (having output_locations set and no server_url is valid, but both of them unset blows up in here)
          return if !Chef::Config[:data_collector][:server_url] && Chef::Config[:data_collector][:output_locations
    
        def should_be_enabled?
          running_mode = ( Chef::Config[:solo_legacy_mode] || Chef::Config[:local_mode] ) ? :solo : :client
          want_mode = Chef::Config[:data_collector][:mode]

          case
          when Chef::Config[:why_run]
            Chef::Log.trace("data collector is disabled for why run mode")
            false
          when (want_mode != :both) && running_mode != want_mode
            Chef::Log.trace("data collector is configured to only run in #{Chef::Config[:data_collector][:mode]} modes, disabling it")
            false
          when !(Chef::Config[:data_collector][:server_url] || Chef::Config[:data_collector][:output_locations])
            Chef::Log.trace("Neither data collector URL or output locations have been configured, disabling data collector")
            false
          when running_mode == :client && Chef::Config[:data_collector][:token]
            Chef::Log.warn("Data collector token authentication is not recommended for client-server mode. " \
                           "Please upgrade #{ChefUtils::Dist::Server::PRODUCT} to 12.11 or later and remove the token from your config file " \
                           "to use key based authentication instead")
            true
          when Chef::Config[:data_collector][:output_locations] && !valid_hash_with_keys?(Chef::Config[:data_collector][:output_locations], :urls)
            # we can run fine to a file without a token, even in solo mode.
            unless valid_hash_with_keys?(Chef::Config[:data_collector][:output_locations], :files)
              raise Chef::Exceptions::ConfigurationError,
                "Chef::Config[:data_collector][:output_locations] is empty. Please supply an hash of valid URLs and / or local file paths."
            end