Sha256: 22b28dcb961bffe08e495b4c6c111664373e77f50fc51d98a385c8686e957d97

Contents?: true

Size: 898 Bytes

Versions: 60

Compression:

Stored size: 898 Bytes

Contents

module Kontena
  module Callbacks
    class InstallSslCertificateAfterDeploy < Kontena::Callback

      include Kontena::Cli::Common

      matches_commands 'master create'

      def after
        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

60 entries across 60 versions & 1 rubygems

Version Path
kontena-cli-1.3.0.pre1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.2 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.2.rc2 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.2.rc1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.1.rc1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.0 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.0.rc3 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.0.rc2 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.0.rc1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.0.pre3 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.0.pre2 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.1.6 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.0.pre1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.1.5 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.1.5.rc3 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.1.5.rc2 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.1.5.rc1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.1.4 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb
kontena-cli-1.2.0.dev1 lib/kontena/callbacks/master/deploy/40_install_ssl_certificate_after_deploy.rb