Class: Kontena::Cli::Config::Server
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Kontena::Cli::Config::Server
- Includes:
- ConfigurationInstance, Fields, TokenSerializer
- Defined in:
- lib/kontena/cli/config.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Server
constructor
A new instance of Server.
- #ssl_cert ⇒ OpenSSL::X509::Certificate?
-
#ssl_cert_path ⇒ String?
Path to ~/.kontena/certs/*.pem.
-
#ssl_subject_cn ⇒ String?
Ssl cert subject CN=.
- #uri ⇒ Object
Methods included from ConfigurationInstance
Methods included from TokenSerializer
Methods included from Fields
Constructor Details
#initialize(*args) ⇒ Server
Returns a new instance of Server.
573 574 575 576 |
# File 'lib/kontena/cli/config.rb', line 573 def initialize(*args) super @table[:account] ||= 'master' end |
Instance Method Details
#ssl_cert ⇒ OpenSSL::X509::Certificate?
594 595 596 597 598 599 600 |
# File 'lib/kontena/cli/config.rb', line 594 def ssl_cert if path = self.ssl_cert_path return OpenSSL::X509::Certificate.new(File.read(path)) else return nil end end |
#ssl_cert_path ⇒ String?
Returns path to ~/.kontena/certs/*.pem.
583 584 585 586 587 588 589 590 591 |
# File 'lib/kontena/cli/config.rb', line 583 def ssl_cert_path path = File.join(Dir.home, '.kontena', 'certs', "#{self.uri.host}.pem") if File.exist?(path) && File.readable?(path) return path else return nil end end |
#ssl_subject_cn ⇒ String?
Returns ssl cert subject CN=.
603 604 605 606 607 608 609 |
# File 'lib/kontena/cli/config.rb', line 603 def ssl_subject_cn if cert = self.ssl_cert return cert.subject.to_a.select{|name, data, type| name == 'CN' }.map{|name, data, type| data }.first else nil end end |
#uri ⇒ Object
578 579 580 |
# File 'lib/kontena/cli/config.rb', line 578 def uri @uri ||= URI.parse(self.url) end |