Commit 7edf3f51 authored by Thong Kuah's avatar Thong Kuah

Sync `groups` and `group` to fix validation

Otherwise adding to `groups` will cause validation based on `group` to
fail.

This is consistent with how Clusters::Cluster#first_project. The
alternative is to switch validation to use `groups` as well.
parent b81b8f3a
......@@ -5,6 +5,7 @@ module Clusters
prepend EE::Clusters::Cluster
include Presentable
include Gitlab::Utils::StrongMemoize
self.table_name = 'clusters'
......@@ -26,9 +27,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
......@@ -121,12 +119,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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment