summaryrefslogtreecommitdiff
path: root/app/services/clusters/applications/create_service.rb
blob: c6f729aaa8aa6485a3129d5045f8dcaa912948cf (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
# frozen_string_literal: true

module Clusters
  module Applications
    class CreateService < Clusters::Applications::BaseService
      private

      def worker_class(application)
        application.updateable? ? ClusterUpgradeAppWorker : ClusterInstallAppWorker
      end

      def builders
        {
          "helm" => -> (cluster) { cluster.application_helm || cluster.build_application_helm },
          "ingress" => -> (cluster) { cluster.application_ingress || cluster.build_application_ingress },
          "cert_manager" => -> (cluster) { cluster.application_cert_manager || cluster.build_application_cert_manager },
          "runner" => -> (cluster) { cluster.application_runner || cluster.build_application_runner }
        }.tap do |hash|
          hash.merge!(project_builders) if cluster.project_type?
        end
      end

      # These applications will need extra configuration to enable them to work
      # with groups of projects
      def project_builders
        {
          "prometheus" => -> (cluster) { cluster.application_prometheus || cluster.build_application_prometheus },
          "jupyter" => -> (cluster) { cluster.application_jupyter || cluster.build_application_jupyter },
          "knative" => -> (cluster) { cluster.application_knative || cluster.build_application_knative }
        }
      end
    end
  end
end