def validate(environment, cookbooks) # rubocop:disable CyclomaticComplexity
      env = nil
      file = %W{environments/#{environment}.rb environments/#{environment}.json}.find { |f| File.exist?(f) }
      environment = environment.split("/").last if environment =~ /\// # pull out directories
      if file
        case file
        when /\.json$/
          env = Chef::JSONCompat.from_json(IO.read(file))
        when /\.rb$/
          env = do_ruby_environment_file(file)
        end
        if env.name != environment
          STDERR.puts "ERROR: Environment '#{environment}' listed in the manifest does not match the name '#{env.name}' within the #{file} file."
          exit(-1)
        end
        env.cookbook_versions.keys.each do |dep|
          do_cookbook_version(cookbooks, dep, environment)
        end
      else # environment is not here
        STDERR.puts "ERROR: Invalid Environment '#{environment}' listed in the manifest but not found in the environments directory."
        exit(-1)
      end
    end
def validate(environment, cookbooks) # rubocop:disable CyclomaticComplexity
      env = nil
      file = %W{environments/#{environment}.rb environments/#{environment}.json}.find { |f| File.exist?(f) }
      environment = environment.split("/").last if environment =~ /\// # pull out directories
      if file
        case file
        when /\.json$/
          env = Chef::JSONCompat.from_json(IO.read(file))
        when /\.rb$/
          env = do_ruby_environment_file(file)
        end
        if env.name != environment
          STDERR.puts "ERROR: Environment '#{environment}' listed in the manifest does not match the name '#{env.name}' within the #{file} file."
          exit(-1)
        end
        env.cookbook_versions.keys.each do |dep|
          do_cookbook_version(cookbooks, dep, environment)
        end
      else # environment is not here
        STDERR.puts "ERROR: Invalid Environment '#{environment}' listed in the manifest but not found in the environments directory."
        exit(-1)
      end
    end
validate the content of the environment file