Class: K8y::REST::Config
- Inherits:
-
Object
- Object
- K8y::REST::Config
- Defined in:
- lib/k8y/rest/config.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(base_path:, transport:, auth:) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(base_path:, transport:, auth:) ⇒ Config
Returns a new instance of Config.
31 32 33 34 35 |
# File 'lib/k8y/rest/config.rb', line 31 def initialize(base_path:, transport:, auth:) @base_path = base_path @transport = transport @auth = auth end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
10 11 12 |
# File 'lib/k8y/rest/config.rb', line 10 def auth @auth end |
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
10 11 12 |
# File 'lib/k8y/rest/config.rb', line 10 def base_path @base_path end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
10 11 12 |
# File 'lib/k8y/rest/config.rb', line 10 def transport @transport end |
Class Method Details
.from_kubeconfig(kubeconfig, context: nil, path: "/") ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/k8y/rest/config.rb', line 13 def from_kubeconfig(kubeconfig, context: nil, path: "/") context = context ? context : kubeconfig.current_context ConfigValidator.new(kubeconfig, context: context).validate! cluster = kubeconfig.cluster_for_context(context) base_path = File.join(cluster.server, path) transport = if URI(base_path).scheme == "https" Transport.from_kubeconfig(kubeconfig, context: context) end auth = Auth.from_kubeconfig(kubeconfig, context: context) new( base_path: base_path, transport: transport, auth: auth ) end |