Class: LearnOpen::GitSSHConnector
- Inherits:
-
Object
- Object
- LearnOpen::GitSSHConnector
- Defined in:
- lib/learn_open/services/git_ssh_connector.rb
Constant Summary collapse
- GIT_SSH_USER =
'git'
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#ssh_connection ⇒ Object
readonly
Returns the value of attribute ssh_connection.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(git_server:, environment:) ⇒ GitSSHConnector
constructor
A new instance of GitSSHConnector.
- #managed_environment? ⇒ Boolean
- #ssh_authenticated? ⇒ Boolean
- #ssh_unauthenticated? ⇒ Boolean
- #upload_ssh_keys! ⇒ Object
Constructor Details
#initialize(git_server:, environment:) ⇒ GitSSHConnector
Returns a new instance of GitSSHConnector.
11 12 13 14 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 11 def initialize(git_server:, environment:) @ssh_connection = LearnOpen.ssh_adapter.new(user: GIT_SSH_USER, hostname: git_server) @environment = environment end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
3 4 5 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 3 def environment @environment end |
#ssh_connection ⇒ Object (readonly)
Returns the value of attribute ssh_connection.
3 4 5 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 3 def ssh_connection @ssh_connection end |
Class Method Details
.call(git_server:, environment:) ⇒ Object
7 8 9 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 7 def self.call(git_server:, environment:) self.new(git_server: git_server, environment: environment).call end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 16 def call if managed_environment? && ssh_unauthenticated? upload_ssh_keys! end ssh_authenticated? end |
#managed_environment? ⇒ Boolean
28 29 30 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 28 def managed_environment? environment.managed? end |
#ssh_authenticated? ⇒ Boolean
36 37 38 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 36 def ssh_authenticated? ssh_connection.authenticated? end |
#ssh_unauthenticated? ⇒ Boolean
32 33 34 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 32 def ssh_unauthenticated? !ssh_authenticated? end |
#upload_ssh_keys! ⇒ Object
24 25 26 |
# File 'lib/learn_open/services/git_ssh_connector.rb', line 24 def upload_ssh_keys! LearnOpen.learn_web_client.add_ssh_key(key: ssh_connection.public_key) end |