1 | # frozen_string_literal: true |
||
2 | |||
3 | # rubocop:disable Metrics/AbcSize |
||
4 | |||
5 | require_relative '../../../action' |
||
6 | |||
7 | module AMA |
||
8 | module Chef |
||
9 | module User |
||
10 | View Code Duplication | class Action |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
11 | module Account |
||
12 | module PrivateKey |
||
13 | class Add < Action |
||
14 | attr_accessor :account |
||
15 | attr_accessor :key |
||
16 | |||
17 | # @param [AMA::Chef::User::Model::Account] account |
||
18 | # @param [AMA::Chef::User::Model::PrivateKey] key |
||
19 | def initialize(account, key) |
||
20 | @account = account |
||
21 | @key = key |
||
22 | end |
||
23 | |||
24 | def apply(resource_factory) |
||
25 | account = @account |
||
26 | key = @key |
||
27 | name = "#{account.id}:#{key.owner}:#{key.id}" |
||
28 | resource_factory.ssh_private_key name do |
||
29 | id key.id.to_s |
||
30 | user account.id.to_s |
||
31 | content key.content.to_s |
||
32 | install_public_key key.install_public_key |
||
33 | passphrase key.passphrase unless key.passphrase.nil? |
||
34 | perform_validation key.validate |
||
35 | end |
||
36 | end |
||
37 | end |
||
38 | end |
||
39 | end |
||
40 | end |
||
41 | end |
||
42 | end |
||
43 | end |
||
44 |