debian-mirror-gitlab/app/services/clusters/applications/base_helm_service.rb

55 lines
1.1 KiB
Ruby
Raw Normal View History

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 = {
2019-05-30 16:15:17 +05:30
exception: error.class.name,
2019-02-15 15:39:39 +05:30
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,
2019-05-30 16:15:17 +05:30
group_ids: app.cluster.group_ids,
message: error.message
2019-02-15 15:39:39 +05:30
}
2019-05-30 16:15:17 +05:30
logger.error(meta)
2019-02-15 15:39:39 +05:30
Gitlab::Sentry.track_acceptable_exception(error, extra: meta)
end
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
@helm_api ||= Gitlab::Kubernetes::Helm::Api.new(kubeclient)
end
def install_command
@install_command ||= app.install_command
end
2019-03-02 22:35:43 +05:30
def upgrade_command(new_values = "")
app.upgrade_command(new_values)
end
2018-03-17 18:26:18 +05:30
end
end
end