Purge.initialize()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
1
# frozen_string_literal: true
2
3
require_relative '../../../action'
4
require_relative '../../../helper/ssh_methods'
5
6
module AMA
7
  module Chef
8
    module User
9
      class Action
10
        module Account
11
          module PublicKey
12
            class Purge < Action
13
              include Helper::SSHMethods
14
15
              attr_accessor :account
16
17
              # @param [AMA::Chef::User::Model::Account] account
18
              def initialize(account)
19
                @account = account
20
              end
21
22
              def apply(resource_factory)
23
                resource_id = "#{ssh_directory(@account.id)}/authorized_keys"
24
                ::Chef::Log.debug("Purging ssh keys for account #{@account.id}")
25
                resource_factory.file resource_id do
26
                  action :delete
27
                end
28
              end
29
            end
30
          end
31
        end
32
      end
33
    end
34
  end
35
end
36