Class: GoogleSslCert::Cert
- Extended by:
- Memoist
- Defined in:
- lib/google_ssl_cert/cert.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize ⇒ Cert
constructor
A new instance of Cert.
Methods included from Helpers::Global
Methods included from Logging
Methods included from GoogleServices
#region_ssl_certificates, #resource_manager, #secret_manager_service, #ssl_certificates
Constructor Details
#initialize ⇒ Cert
Returns a new instance of Cert.
5 6 7 8 9 10 |
# File 'lib/google_ssl_cert/cert.rb', line 5 def initialize(*) super @cert_name = @options[:cert_name] @private_key = private_key @certificate = certificate end |
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/google_ssl_cert/cert.rb', line 12 def create validate! region = ENV['GOOGLE_REGION'] ssl_certificate_resource = { name: @cert_name, private_key: IO.read(@private_key), certificate: IO.read(@certificate), } if global? ssl_certificates.insert( project: ENV['GOOGLE_PROJECT'], ssl_certificate_resource: ssl_certificate_resource, ) logger.info "Global cert created: #{@cert_name}" else region_ssl_certificates.insert( project: ENV['GOOGLE_PROJECT'], region: region, ssl_certificate_resource: ssl_certificate_resource, ) logger.info "Region cert created: #{@cert_name} in region: #{region}" end rescue Google::Cloud::AlreadyExistsError => e logger.error "#{e.class}: #{e.}" end |