diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-11-06 09:34:02 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-11-06 09:34:02 +0000 |
commit | fec402ae9100a9ba11611dc45830c84c45c3f862 (patch) | |
tree | 63dbcf7344905b7e82cfc07b16a4798191d8cd4d | |
parent | 485a0bf777cd8f777afb91af6c80b1092bf69cbe (diff) | |
parent | 1b47b2147f327537e98bcf42adbcff11180367fe (diff) | |
download | gitlab-ce-34758-group-level-kubernetes-cluster-configuration.tar.gz |
Merge branch '34758-unique-environment-scope' into 'master'34758-group-level-kubernetes-cluster-configuration
Sync `groups` and `group` to fix EE validation
See merge request gitlab-org/gitlab-ce!22788
-rw-r--r-- | app/models/clusters/cluster.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index 2bd373e0950..e80d35d0f3c 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -3,6 +3,7 @@ module Clusters class Cluster < ActiveRecord::Base include Presentable + include Gitlab::Utils::StrongMemoize self.table_name = 'clusters' @@ -24,9 +25,6 @@ module Clusters has_many :cluster_groups, class_name: 'Clusters::Group' has_many :groups, through: :cluster_groups, class_name: '::Group' - has_one :cluster_group, -> { order(id: :desc) }, class_name: 'Clusters::Group' - has_one :group, through: :cluster_group, class_name: '::Group' - # we force autosave to happen when we save `Cluster` model has_one :provider_gcp, class_name: 'Clusters::Providers::Gcp', autosave: true @@ -119,12 +117,19 @@ module Clusters end def first_project - return @first_project if defined?(@first_project) - - @first_project = projects.first + strong_memoize(:first_project) do + projects.first + end end alias_method :project, :first_project + def first_group + strong_memoize(:first_group) do + groups.first + end + end + alias_method :group, :first_group + def kubeclient platform_kubernetes.kubeclient if kubernetes? end |