Class: K8y::Kubeconfig::Context
- Inherits:
-
Object
- Object
- K8y::Kubeconfig::Context
- Defined in:
- lib/k8y/kubeconfig/context.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
readonly
Returns the value of attribute cluster.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, cluster:, namespace:, user:) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(name:, cluster:, namespace:, user:) ⇒ Context
Returns a new instance of Context.
20 21 22 23 24 25 |
# File 'lib/k8y/kubeconfig/context.rb', line 20 def initialize(name:, cluster:, namespace:, user:) @name = name @cluster = cluster @namespace = namespace @user = user end |
Instance Attribute Details
#cluster ⇒ Object (readonly)
Returns the value of attribute cluster.
6 7 8 |
# File 'lib/k8y/kubeconfig/context.rb', line 6 def cluster @cluster end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/k8y/kubeconfig/context.rb', line 6 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/k8y/kubeconfig/context.rb', line 6 def namespace @namespace end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/k8y/kubeconfig/context.rb', line 6 def user @user end |
Class Method Details
.from_hash(hash) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/k8y/kubeconfig/context.rb', line 8 def self.from_hash(hash) context = hash.fetch("context") new( name: hash.fetch("name"), cluster: context.fetch("cluster"), namespace: context.fetch("namespace", nil), user: context.fetch("user") ) rescue Psych::Exception, KeyError => e raise Error, e end |