Class: Certsweeper::Client
- Inherits:
-
Object
- Object
- Certsweeper::Client
- Defined in:
- lib/certsweeper/client.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(cli_options = {}, aws_configuration = {}) ⇒ Client
constructor
A new instance of Client.
- #list ⇒ Object
- #remove(cert_name) ⇒ Object
- #remove_all ⇒ Object
Constructor Details
#initialize(cli_options = {}, aws_configuration = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 |
# File 'lib/certsweeper/client.rb', line 7 def initialize( = {}, aws_configuration = {}) @cli_options = @logger ||= Logger.new STDOUT aws_configuration[:logger] = Logger.new STDOUT if @cli_options.verbose @aws_configuration = aws_configuration @iam = Aws::IAM::Resource.new aws_configuration end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/certsweeper/client.rb', line 5 def logger @logger end |
Instance Method Details
#list ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/certsweeper/client.rb', line 17 def list Enumerator.new do |y| @iam.server_certificates.each do |cert| if expired?(cert) && (not use_by_elb?(cert)) y << cert end end end end |
#remove(cert_name) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/certsweeper/client.rb', line 36 def remove(cert_name) list.each do |cert| if cert..server_certificate_name == cert_name cert.delete unless @cli_options[:dry_run] return [cert..server_certificate_name] end end [] end |
#remove_all ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/certsweeper/client.rb', line 27 def remove_all removed_cert_name = [] list.each do |cert| cert.delete unless @cli_options[:dry_run] removed_cert_name << cert..server_certificate_name end removed_cert_name end |