gitlab-org--gitlab-foss/lib/gitlab/kubernetes/namespace.rb

31 lines
557 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Gitlab
module Kubernetes
class Namespace
attr_accessor :name
def initialize(name, client)
2017-11-07 11:51:30 -05:00
@name = name
@client = client
end
def exists?
@client.get_namespace(name)
rescue ::Kubeclient::ResourceNotFoundError
false
end
def create!
resource = ::Kubeclient::Resource.new(metadata: { name: name })
@client.create_namespace(resource)
end
def ensure_exists!
exists? || create!
end
end
end
end