2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
module Clusters
|
|
|
|
module Applications
|
2019-07-07 11:18:12 +05:30
|
|
|
class Runner < ApplicationRecord
|
2022-03-02 08:16:31 +05:30
|
|
|
VERSION = '0.36.0'
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
self.table_name = 'clusters_applications_runners'
|
|
|
|
|
|
|
|
include ::Clusters::Concerns::ApplicationCore
|
|
|
|
include ::Clusters::Concerns::ApplicationStatus
|
2018-11-18 11:00:15 +05:30
|
|
|
include ::Clusters::Concerns::ApplicationVersion
|
2018-03-27 19:54:05 +05:30
|
|
|
include ::Clusters::Concerns::ApplicationData
|
|
|
|
|
|
|
|
belongs_to :runner, class_name: 'Ci::Runner', foreign_key: :runner_id
|
2019-07-07 11:18:12 +05:30
|
|
|
delegate :project, :group, to: :cluster
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
default_value_for :version, VERSION
|
|
|
|
|
|
|
|
def chart
|
|
|
|
"#{name}/gitlab-runner"
|
|
|
|
end
|
|
|
|
|
|
|
|
def repository
|
|
|
|
'https://charts.gitlab.io'
|
|
|
|
end
|
|
|
|
|
|
|
|
def values
|
|
|
|
content_values.to_yaml
|
|
|
|
end
|
|
|
|
|
|
|
|
def install_command
|
2021-01-29 00:20:46 +05:30
|
|
|
helm_command_module::InstallCommand.new(
|
2018-11-18 11:00:15 +05:30
|
|
|
name: name,
|
|
|
|
version: VERSION,
|
2018-11-20 20:47:30 +05:30
|
|
|
rbac: cluster.platform_kubernetes_rbac?,
|
2018-03-27 19:54:05 +05:30
|
|
|
chart: chart,
|
2018-11-18 11:00:15 +05:30
|
|
|
files: files,
|
2020-10-24 23:57:45 +05:30
|
|
|
repository: repository
|
2018-03-27 19:54:05 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
def prepare_uninstall
|
2022-03-02 08:16:31 +05:30
|
|
|
# No op, see https://gitlab.com/gitlab-org/gitlab/-/issues/350180.
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def post_uninstall
|
|
|
|
runner.destroy!
|
|
|
|
end
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def gitlab_url
|
|
|
|
Gitlab::Routing.url_helpers.root_url(only_path: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
def specification
|
|
|
|
{
|
|
|
|
"gitlabUrl" => gitlab_url,
|
|
|
|
"runners" => { "privileged" => privileged }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def content_values
|
|
|
|
YAML.load_file(chart_values_file).deep_merge!(specification)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|