Class: Gitlab::Kubernetes::Namespace
- Inherits:
-
Object
- Object
- Gitlab::Kubernetes::Namespace
- Defined in:
- lib/gitlab/kubernetes/namespace.rb
Instance Attribute Summary collapse
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #create! ⇒ Object
- #ensure_exists! ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(name, client, labels: nil) ⇒ Namespace
constructor
A new instance of Namespace.
Constructor Details
#initialize(name, client, labels: nil) ⇒ Namespace
Returns a new instance of Namespace.
8 9 10 11 12 |
# File 'lib/gitlab/kubernetes/namespace.rb', line 8 def initialize(name, client, labels: nil) @name = name @client = client @labels = labels end |
Instance Attribute Details
#labels ⇒ Object
Returns the value of attribute labels.
6 7 8 |
# File 'lib/gitlab/kubernetes/namespace.rb', line 6 def labels @labels end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/gitlab/kubernetes/namespace.rb', line 6 def name @name end |
Instance Method Details
#create! ⇒ Object
20 21 22 23 24 25 |
# File 'lib/gitlab/kubernetes/namespace.rb', line 20 def create! resource = ::Kubeclient::Resource.new(metadata: { name: name, labels: labels }) log_event(:begin_create) @client.create_namespace(resource) end |
#ensure_exists! ⇒ Object
27 28 29 30 31 32 |
# File 'lib/gitlab/kubernetes/namespace.rb', line 27 def ensure_exists! exists? || create! rescue ::Kubeclient::HttpError => error log_create_failed(error) raise end |
#exists? ⇒ Boolean
14 15 16 17 18 |
# File 'lib/gitlab/kubernetes/namespace.rb', line 14 def exists? @client.get_namespace(name) rescue ::Kubeclient::ResourceNotFoundError false end |