class ChefCLI::PolicyfileServices::PushArchive

def read_policyfile_lock(staging_dir)

def read_policyfile_lock(staging_dir)
  policyfile_lock_path = File.join(staging_dir, "Policyfile.lock.json")
  if looks_like_old_format_archive?(staging_dir)
    raise InvalidPolicyArchive, <<~MESSAGE
      This archive is in an unsupported format.
      This archive was created with an older version of ChefCLI. This version of
      ChefCLI does not support archives in the older format. Please Re-create the
      archive with a newer version of ChefCLI or Workstation.
    MESSAGE
  end
  unless File.exist?(policyfile_lock_path)
    raise InvalidPolicyArchive, "Archive does not contain a Policyfile.lock.json"
  end
  unless File.directory?(File.join(staging_dir, "cookbook_artifacts"))
    raise InvalidPolicyArchive, "Archive does not contain a cookbook_artifacts directory"
  end
  policy_data = load_policy_data(policyfile_lock_path)
  storage_config = Policyfile::StorageConfig.new.use_policyfile_lock(policyfile_lock_path)
  @policyfile_lock = ChefCLI::PolicyfileLock.new(storage_config).build_from_archive(policy_data)
  missing_cookbooks = policyfile_lock.cookbook_locks.select do |name, lock|
    !lock.installed?
  end
  unless missing_cookbooks.empty?
    message = "Archive does not have all cookbooks required by the Policyfile.lock. " +
      "Missing cookbooks: '#{missing_cookbooks.keys.join('", "')}'."
    raise InvalidPolicyArchive, message
  end
end