Class: Gitlab::BitbucketImport::KeyAdder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/bitbucket_import/key_adder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, current_user, access_params) ⇒ KeyAdder

Returns a new instance of KeyAdder


6
7
8
9
10
# File 'lib/gitlab/bitbucket_import/key_adder.rb', line 6

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

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client


4
5
6
# File 'lib/gitlab/bitbucket_import/key_adder.rb', line 4

def client
  @client
end

#current_userObject (readonly)

Returns the value of attribute current_user


4
5
6
# File 'lib/gitlab/bitbucket_import/key_adder.rb', line 4

def current_user
  @current_user
end

#repoObject (readonly)

Returns the value of attribute repo


4
5
6
# File 'lib/gitlab/bitbucket_import/key_adder.rb', line 4

def repo
  @repo
end

Instance Method Details

#executeObject


12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/bitbucket_import/key_adder.rb', line 12

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