blob: 5522a01758f0b7a346ea6ba0a0ea9159e4978791 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
module Ci
class GroupVariable < Ci::ApplicationRecord
include Ci::HasVariable
include Ci::Maskable
include Ci::RawVariable
include Limitable
include Presentable
prepend HasEnvironmentScope
belongs_to :group, class_name: "::Group"
alias_attribute :secret_value, :value
validates :key, uniqueness: {
scope: [:group_id, :environment_scope],
message: "(%{value}) has already been taken"
}
scope :unprotected, -> { where(protected: false) }
scope :by_environment_scope, -> (environment_scope) { where(environment_scope: environment_scope) }
scope :for_groups, ->(group_ids) { where(group_id: group_ids) }
scope :for_environment_scope_like, -> (query) do
top_level = 'LOWER(ci_group_variables.environment_scope) LIKE LOWER(?) || \'%\''
search_like = "%#{sanitize_sql_like(query)}%"
where(top_level, search_like)
end
scope :environment_scope_names, -> do
group(:environment_scope)
.order(:environment_scope)
.pluck(:environment_scope)
end
self.limit_name = 'group_ci_variables'
self.limit_scope = :group
def audit_details
key
end
def group_name
group.name
end
def group_ci_cd_settings_path
Gitlab::Routing.url_helpers.group_settings_ci_cd_path(group)
end
end
end
|