summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2019-03-12 10:15:33 +0000
committerKamil TrzciƄski <ayufan@ayufan.eu>2019-03-12 10:15:33 +0000
commit7e9348f3594ee158dfd4aaa9e03e5bb5dd36aead (patch)
tree74e03ba375331ab619a766d5d2a3c12aaa267095 /app/models/namespace.rb
parentdb37b5a4c8d408e1bce0843162c609dcb1781188 (diff)
downloadgitlab-ce-7e9348f3594ee158dfd4aaa9e03e5bb5dd36aead.tar.gz
Enable/disable Auto DevOps at Group level
- Includes instance methods on Group model to detect when a group has AutoDevOps explicitly/implicitly enabled/disabled. - Includes migration to add a new column to namespaces table - Add UI necessary modifications - Add service and controller to update auto devops related instances - Updates project and groups auto devops badges Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52447
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index a5c479bdc0c..dea34e812ca 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -11,6 +11,7 @@ class Namespace < ApplicationRecord
include IgnorableColumn
include FeatureGate
include FromUnion
+ include Gitlab::Utils::StrongMemoize
ignore_column :deleted_at
@@ -267,6 +268,22 @@ class Namespace < ApplicationRecord
owner.refresh_authorized_projects
end
+ def auto_devops_enabled?
+ first_auto_devops_config[:status]
+ end
+
+ def first_auto_devops_config
+ return { scope: :group, status: auto_devops_enabled } unless auto_devops_enabled.nil?
+
+ strong_memoize(:first_auto_devops_config) do
+ if has_parent?
+ parent.first_auto_devops_config
+ else
+ { scope: :instance, status: Gitlab::CurrentSettings.auto_devops_enabled? }
+ end
+ end
+ end
+
private
def path_or_parent_changed?