2018-12-04 13:40:47 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module CiVariablesHelper
|
|
|
|
def ci_variable_protected_by_default?
|
|
|
|
Gitlab::CurrentSettings.current_application_settings.protected_ci_variables
|
|
|
|
end
|
|
|
|
|
|
|
|
def ci_variable_protected?(variable, only_key_value)
|
|
|
|
if variable && !only_key_value
|
|
|
|
variable.protected
|
|
|
|
else
|
|
|
|
ci_variable_protected_by_default?
|
|
|
|
end
|
|
|
|
end
|
2019-03-29 15:46:31 +00:00
|
|
|
|
|
|
|
def ci_variable_masked?(variable, only_key_value)
|
|
|
|
if variable && !only_key_value
|
|
|
|
variable.masked
|
|
|
|
else
|
2019-05-07 19:37:29 +00:00
|
|
|
false
|
2019-03-29 15:46:31 +00:00
|
|
|
end
|
|
|
|
end
|
2019-05-06 13:11:42 +00:00
|
|
|
|
|
|
|
def ci_variable_type_options
|
|
|
|
[
|
|
|
|
%w(Variable env_var),
|
|
|
|
%w(File file)
|
|
|
|
]
|
|
|
|
end
|
2019-06-04 15:36:40 +00:00
|
|
|
|
|
|
|
def ci_variable_maskable_regex
|
2019-06-05 16:26:06 +00:00
|
|
|
Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(/^\//, '').sub(/\/[a-z]*$/, '').gsub('\/', '/')
|
2019-06-04 15:36:40 +00:00
|
|
|
end
|
2018-12-04 13:40:47 +00:00
|
|
|
end
|