summaryrefslogtreecommitdiff
path: root/lib/tasks/gitlab/x509/update.rake
blob: d3c63fa8514623770c7c4cc0d9e2cb71fe74f6a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'logger'

desc "GitLab | X509 | Update signatures when certificate store has changed"
namespace :gitlab do
  namespace :x509 do
    task update_signatures: :environment do
      update_certificates
    end

    def update_certificates
      logger = Logger.new($stdout)

      unless X509CommitSignature.exists?
        logger.info("Unable to find any x509 commit signatures. Exiting.")
        return
      end

      logger.info("Start to update x509 commit signatures")

      X509CommitSignature.find_each do |sig|
        sig.x509_commit&.update_signature!(sig)
      end

      logger.info("End update x509 commit signatures")
    end
  end
end