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