Sha256: 55982a98a88f719651a4e3a237eb25d195501daac3b60262de0cf9c2131d83c3

Contents?: true

Size: 899 Bytes

Versions: 77

Compression:

Stored size: 899 Bytes

Contents

module Kontena
  module Callbacks
    class InstallSslCertificateAfterDeploy < Kontena::Callback

      matches_commands 'master create'

      def after
        extend Kontena::Cli::Common

        return unless command.exit_code == 0
        return unless command.result.kind_of?(Hash)
        return unless command.result.has_key?(:ssl_certificate)
        return unless command.result.has_key?(:public_ip)

        cert_dir = File.join(Dir.home, '.kontena/certs')
        unless File.directory?(cert_dir)
          require 'fileutils'
          FileUtils.mkdir_p(cert_dir)
        end

        cert_file = File.join(cert_dir, "#{command.result[:public_ip]}.pem")

        spinner "Installing SSL certificate to #{cert_file}" do
          File.unlink(cert_file) if File.exist?(cert_file)
          File.write(cert_file, command.result[:ssl_certificate])
        end
      end
    end
  end
end


Version data entries

77 entries across 77 versions & 2 rubygems

Version Path
kontena-cli-1.4.1.rc1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.1.pre1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.3.5 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.3.5.rc1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.rc2 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.rc1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre14 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre13 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre12 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre11 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre10 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre9 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre8 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre7 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre6 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre5 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre4 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre3 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.4.0.pre2 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb