2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-02 13:55:02 -04:00
|
|
|
module Clusters
|
|
|
|
module Applications
|
|
|
|
class BaseHelmService
|
|
|
|
attr_accessor :app
|
|
|
|
|
|
|
|
def initialize(app)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
2018-11-23 10:17:17 -05:00
|
|
|
def log_error(error)
|
|
|
|
meta = {
|
|
|
|
exception: error.class.name,
|
|
|
|
error_code: error.respond_to?(:error_code) ? error.error_code : nil,
|
|
|
|
service: self.class.name,
|
|
|
|
app_id: app.id,
|
|
|
|
project_ids: app.cluster.project_ids,
|
|
|
|
group_ids: app.cluster.group_ids,
|
|
|
|
message: error.message
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.error(meta)
|
|
|
|
Gitlab::Sentry.track_acceptable_exception(error, extra: meta)
|
|
|
|
end
|
|
|
|
|
|
|
|
def logger
|
|
|
|
@logger ||= Gitlab::Kubernetes::Logger.build
|
|
|
|
end
|
|
|
|
|
2017-11-02 13:55:02 -04:00
|
|
|
def cluster
|
|
|
|
app.cluster
|
|
|
|
end
|
|
|
|
|
|
|
|
def kubeclient
|
|
|
|
cluster.kubeclient
|
|
|
|
end
|
|
|
|
|
|
|
|
def helm_api
|
2017-12-22 12:23:43 -05:00
|
|
|
@helm_api ||= Gitlab::Kubernetes::Helm::Api.new(kubeclient)
|
2017-11-02 13:55:02 -04:00
|
|
|
end
|
2017-11-07 09:26:14 -05:00
|
|
|
|
|
|
|
def install_command
|
|
|
|
@install_command ||= app.install_command
|
|
|
|
end
|
2018-12-19 03:50:12 -05:00
|
|
|
|
|
|
|
def upgrade_command(new_values = "")
|
|
|
|
app.upgrade_command(new_values)
|
|
|
|
end
|
2017-11-02 13:55:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|