diff options
author | Nick Thomas <nick@gitlab.com> | 2017-08-28 21:33:35 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-08-30 20:50:44 +0100 |
commit | b84ca08e351fc9238bef4e6b4bf74158d25d4f1d (patch) | |
tree | e7ec9704ec449b547b6193c5e0ba771a5aae62c2 /lib/gitlab/ssh_public_key.rb | |
parent | 6847060266792471c9c14518a5106e0f622cd6c5 (diff) | |
download | gitlab-ce-b84ca08e351fc9238bef4e6b4bf74158d25d4f1d.tar.gz |
Address review comments
Diffstat (limited to 'lib/gitlab/ssh_public_key.rb')
-rw-r--r-- | lib/gitlab/ssh_public_key.rb | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/gitlab/ssh_public_key.rb b/lib/gitlab/ssh_public_key.rb index a3f8730fb04..89ca1298120 100644 --- a/lib/gitlab/ssh_public_key.rb +++ b/lib/gitlab/ssh_public_key.rb @@ -13,6 +13,10 @@ module Gitlab Technologies.find { |tech| tech.name.to_s == name.to_s } end + def self.technology_for_key(key) + Technologies.find { |tech| key.is_a?(tech.key_class) } + end + def self.supported_sizes(name) technology(name)&.supported_sizes end @@ -37,9 +41,7 @@ module Gitlab end def type - return unless valid? - - technology.name + technology.name if valid? end def bits @@ -63,12 +65,7 @@ module Gitlab def technology @technology ||= - begin - tech = Technologies.find { |tech| key.is_a?(tech.key_class) } - raise "Unsupported key type: #{key.class}" unless tech - - tech - end + self.class.technology_for_key(key) || raise("Unsupported key type: #{key.class}") end end end |