Class: Kubeclient::Config
Defined Under Namespace
Classes: Context
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) context(context_name = nil)
- - (Object) contexts
-
- (Config) initialize(kcfg, kcfg_path)
constructor
A new instance of Config.
Constructor Details
Method: Kubeclient::Config#initialize
- Defined in:
- lib/kubeclient/config.rb
- (Config) initialize(kcfg, kcfg_path)
Returns a new instance of Config
19 20 21 22 23 |
# File 'lib/kubeclient/config.rb', line 19 def initialize(kcfg, kcfg_path) @kcfg = kcfg @kcfg_path = kcfg_path fail 'Unknown kubeconfig version' if @kcfg['apiVersion'] != 'v1' end |
Class Method Details
Method: Kubeclient::Config.read
- Defined in:
- lib/kubeclient/config.rb
+ (Object) read(filename)
25 26 27 |
# File 'lib/kubeclient/config.rb', line 25 def self.read(filename) Config.new(YAML.load_file(filename), File.dirname(filename)) end |
Instance Method Details
Method: Kubeclient::Config#context
- Defined in:
- lib/kubeclient/config.rb
- (Object) context(context_name = nil)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/kubeclient/config.rb', line 33 def context(context_name = nil) cluster, user = fetch_context(context_name || @kcfg['current-context']) ca_cert_data = fetch_cluster_ca_data(cluster) client_cert_data = fetch_user_cert_data(user) client_key_data = fetch_user_key_data(user) = {} unless ca_cert_data.nil? cert_store = OpenSSL::X509::Store.new cert_store.add_cert(OpenSSL::X509::Certificate.new(ca_cert_data)) [:verify_ssl] = OpenSSL::SSL::VERIFY_PEER [:cert_store] = cert_store else [:verify_ssl] = OpenSSL::SSL::VERIFY_NONE end unless client_cert_data.nil? [:client_cert] = OpenSSL::X509::Certificate.new(client_cert_data) end unless client_key_data.nil? [:client_key] = OpenSSL::PKey.read(client_key_data) end Context.new(cluster['server'], @kcfg['apiVersion'], ) end |
Method: Kubeclient::Config#contexts
- Defined in:
- lib/kubeclient/config.rb
- (Object) contexts
29 30 31 |
# File 'lib/kubeclient/config.rb', line 29 def contexts return @kcfg['contexts'].map { |x| x['name'] } end |