Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base_helm_service.rb « applications « clusters « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f38051bcad211b7a1ab3c9b33d74cd178a1e0af1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true

module Clusters
  module Applications
    class BaseHelmService
      attr_accessor :app

      def initialize(app)
        @app = app
      end

      protected

      def log_error(error)
        meta = {
          error_code: error.respond_to?(:error_code) ? error.error_code : nil,
          service: self.class.name,
          app_id: app.id,
          app_name: app.name,
          project_ids: app.cluster.project_ids,
          group_ids: app.cluster.group_ids
        }

        Gitlab::ErrorTracking.track_exception(error, meta)
      end

      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

      def logger
        @logger ||= Gitlab::Kubernetes::Logger.build
      end

      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

      def update_command
        @update_command ||= app.update_command
      end

      def upgrade_command(new_values = "")
        app.upgrade_command(new_values)
      end
    end
  end
end