Welcome to mirror list, hosted at ThFree Co, Russian Federation.

key_adder.rb « bitbucket_import « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0b63f025d0ad45900d8c4816e4703ab9200935c5 (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
module Gitlab
  module BitbucketImport
    class KeyAdder
      attr_reader :repo, :current_user, :client

      def initialize(repo, current_user, access_params)
        @repo, @current_user = repo, current_user
        @client = Client.new(access_params[:bitbucket_access_token],
                             access_params[:bitbucket_access_token_secret])
      end

      def execute
        return false unless BitbucketImport.public_key.present?

        project_identifier = "#{repo["owner"]}/#{repo["slug"]}"
        client.add_deploy_key(project_identifier, BitbucketImport.public_key)

        true
      rescue
        false
      end
    end
  end
end