2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Clusters
|
|
|
|
module Applications
|
|
|
|
class BaseHelmService
|
|
|
|
attr_accessor :app
|
|
|
|
|
|
|
|
def initialize(app)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
def log_error(error)
|
|
|
|
meta = {
|
|
|
|
error_code: error.respond_to?(:error_code) ? error.error_code : nil,
|
|
|
|
service: self.class.name,
|
|
|
|
app_id: app.id,
|
2019-07-31 22:56:46 +05:30
|
|
|
app_name: app.name,
|
2019-02-15 15:39:39 +05:30
|
|
|
project_ids: app.cluster.project_ids,
|
2019-07-07 11:18:12 +05:30
|
|
|
group_ids: app.cluster.group_ids
|
2019-02-15 15:39:39 +05:30
|
|
|
}
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
Gitlab::ErrorTracking.track_exception(error, meta)
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
def log_event(event)
|
|
|
|
meta = {
|
|
|
|
service: self.class.name,
|
|
|
|
app_id: app.id,
|
|
|
|
app_name: app.name,
|
|
|
|
project_ids: app.cluster.project_ids,
|
|
|
|
group_ids: app.cluster.group_ids,
|
|
|
|
event: event
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.info(meta)
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
def logger
|
|
|
|
@logger ||= Gitlab::Kubernetes::Logger.build
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def cluster
|
|
|
|
app.cluster
|
|
|
|
end
|
|
|
|
|
|
|
|
def kubeclient
|
|
|
|
cluster.kubeclient
|
|
|
|
end
|
|
|
|
|
|
|
|
def helm_api
|
2020-04-08 14:13:33 +05:30
|
|
|
@helm_api ||= Gitlab::Kubernetes::Helm::API.new(kubeclient)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def install_command
|
|
|
|
@install_command ||= app.install_command
|
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
def update_command
|
|
|
|
@update_command ||= app.update_command
|
|
|
|
end
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
def patch_command(new_values = "")
|
|
|
|
app.patch_command(new_values)
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|