2018-11-16 19:37:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-01 18:46:02 -05:00
|
|
|
module Gitlab
|
|
|
|
module Kubernetes
|
|
|
|
class ConfigMap
|
2018-08-07 08:39:38 -04:00
|
|
|
def initialize(name, files)
|
2018-03-01 18:46:02 -05:00
|
|
|
@name = name
|
2018-08-07 08:39:38 -04:00
|
|
|
@files = files
|
2018-03-01 18:46:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def generate
|
|
|
|
resource = ::Kubeclient::Resource.new
|
|
|
|
resource.metadata = metadata
|
2018-08-07 08:39:38 -04:00
|
|
|
resource.data = files
|
2018-03-01 18:46:02 -05:00
|
|
|
resource
|
|
|
|
end
|
|
|
|
|
2018-06-25 05:57:29 -04:00
|
|
|
def config_map_name
|
|
|
|
"values-content-configuration-#{name}"
|
|
|
|
end
|
|
|
|
|
2018-03-01 18:46:02 -05:00
|
|
|
private
|
|
|
|
|
2018-08-07 08:39:38 -04:00
|
|
|
attr_reader :name, :files
|
2018-03-01 18:46:02 -05:00
|
|
|
|
|
|
|
def metadata
|
|
|
|
{
|
|
|
|
name: config_map_name,
|
|
|
|
namespace: namespace,
|
|
|
|
labels: { name: config_map_name }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def namespace
|
|
|
|
Gitlab::Kubernetes::Helm::NAMESPACE
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|