| Total Complexity | 2 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | # frozen_string_literal: true |
||
| 13 | class Add < Action |
||
| 14 | include Helper::SSHMethods |
||
| 15 | |||
| 16 | attr_accessor :account |
||
| 17 | attr_accessor :private_key |
||
| 18 | attr_accessor :remote |
||
| 19 | |||
| 20 | # @param [AMA::Chef::User::Model::Account] account |
||
| 21 | # @param [AMA::Chef::User::Model::PrivateKey] private_key |
||
| 22 | # @param [AMA::Chef::User::Model::PrivateKey::Remote] remote |
||
| 23 | def initialize(account, private_key, remote) |
||
| 24 | @account = account |
||
| 25 | @private_key = private_key |
||
| 26 | @remote = remote |
||
| 27 | end |
||
| 28 | |||
| 29 | def apply(resource_factory) |
||
| 30 | path = "#{ssh_directory(@account.id)}/#{@private_key.id}" |
||
| 31 | options = @remote.options.merge('IdentityFile' => path) |
||
| 32 | account = @account |
||
| 33 | key = @private_key |
||
| 34 | remote = @remote |
||
| 35 | name = "#{account.id}:#{key.owner}:#{key.id}:#{remote.id}" |
||
| 36 | resource_factory.ssh_config name do |
||
| 37 | user account.id.to_s |
||
| 38 | host remote.id.to_s |
||
| 39 | options options |
||
| 40 | end |
||
| 41 | end |
||
| 42 | end |
||
| 43 | end |
||
| 50 |