2017-11-02 06:14:10 -04:00
|
|
|
module Clusters
|
2017-11-02 10:10:46 -04:00
|
|
|
module Applications
|
|
|
|
class Helm < ActiveRecord::Base
|
|
|
|
self.table_name = 'clusters_applications_helm'
|
|
|
|
|
2017-11-02 12:57:50 -04:00
|
|
|
include ::Clusters::Concerns::ApplicationStatus
|
2017-11-02 06:14:10 -04:00
|
|
|
|
2017-11-02 10:31:25 -04:00
|
|
|
belongs_to :cluster, class_name: 'Clusters::Cluster', foreign_key: :cluster_id
|
2017-11-02 06:14:10 -04:00
|
|
|
|
2017-11-02 11:57:18 -04:00
|
|
|
default_value_for :version, Gitlab::Kubernetes::Helm::HELM_VERSION
|
2017-11-02 06:14:10 -04:00
|
|
|
|
2017-11-03 06:10:50 -04:00
|
|
|
validates :cluster, presence: true
|
|
|
|
|
2017-11-07 08:26:14 -05:00
|
|
|
after_initialize :set_initial_status
|
|
|
|
|
2017-11-03 14:20:29 -04:00
|
|
|
def self.application_name
|
|
|
|
self.to_s.demodulize.underscore
|
|
|
|
end
|
|
|
|
|
2017-11-07 08:26:14 -05:00
|
|
|
def set_initial_status
|
2017-11-07 08:52:11 -05:00
|
|
|
return unless not_installable?
|
|
|
|
|
2017-11-07 08:26:14 -05:00
|
|
|
self.status = 'installable' if cluster&.platform_kubernetes_active?
|
2017-11-06 09:48:44 -05:00
|
|
|
end
|
|
|
|
|
2017-11-02 06:14:10 -04:00
|
|
|
def name
|
2017-11-03 14:20:29 -04:00
|
|
|
self.class.application_name
|
2017-11-02 06:14:10 -04:00
|
|
|
end
|
2017-11-07 09:26:14 -05:00
|
|
|
|
|
|
|
def install_command
|
|
|
|
Gitlab::Kubernetes::Helm::InstallCommand.new(name, true)
|
|
|
|
end
|
2017-11-02 06:14:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|