Commit b668969c authored by Marius Bobin's avatar Marius Bobin

Cleanup secret variables refactoring in variables builder

Changelog: other
parent 554e3e67
---
name: ci_variables_builder_memoize_secret_variables
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79850
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/351995
milestone: '14.8'
type: development
group: group::pipeline execution
default_enabled: false
...@@ -24,8 +24,8 @@ module Gitlab ...@@ -24,8 +24,8 @@ module Gitlab
variables.concat(user_variables(job.user)) variables.concat(user_variables(job.user))
variables.concat(job.dependency_variables) if dependencies variables.concat(job.dependency_variables) if dependencies
variables.concat(secret_instance_variables) variables.concat(secret_instance_variables)
variables.concat(secret_group_variables(environment: environment, ref: job.git_ref)) variables.concat(secret_group_variables(environment: environment))
variables.concat(secret_project_variables(environment: environment, ref: job.git_ref)) variables.concat(secret_project_variables(environment: environment))
variables.concat(job.trigger_request.user_variables) if job.trigger_request variables.concat(job.trigger_request.user_variables) if job.trigger_request
variables.concat(pipeline.variables) variables.concat(pipeline.variables)
variables.concat(pipeline.pipeline_schedule.job_variables) if pipeline.pipeline_schedule variables.concat(pipeline.pipeline_schedule.job_variables) if pipeline.pipeline_schedule
...@@ -75,21 +75,21 @@ module Gitlab ...@@ -75,21 +75,21 @@ module Gitlab
end end
end end
def secret_group_variables(environment:, ref:) def secret_group_variables(environment:)
if memoize_secret_variables? strong_memoize_with(:secret_group_variables, environment) do
memoized_secret_group_variables(environment: environment) group_variables_builder
else .secret_variables(
return [] unless project.group environment: environment,
protected_ref: protected_ref?)
project.group.ci_variables_for(ref, project, environment: environment)
end end
end end
def secret_project_variables(environment:, ref:) def secret_project_variables(environment:)
if memoize_secret_variables? strong_memoize_with(:secret_project_variables, environment) do
memoized_secret_project_variables(environment: environment) project_variables_builder
else .secret_variables(
project.ci_variables_for(ref: ref, environment: environment) environment: environment,
protected_ref: protected_ref?)
end end
end end
...@@ -120,24 +120,6 @@ module Gitlab ...@@ -120,24 +120,6 @@ module Gitlab
end end
end end
def memoized_secret_project_variables(environment:)
strong_memoize_with(:secret_project_variables, environment) do
project_variables_builder
.secret_variables(
environment: environment,
protected_ref: protected_ref?)
end
end
def memoized_secret_group_variables(environment:)
strong_memoize_with(:secret_group_variables, environment) do
group_variables_builder
.secret_variables(
environment: environment,
protected_ref: protected_ref?)
end
end
def ci_node_total_value(job) def ci_node_total_value(job)
parallel = job.options&.dig(:parallel) parallel = job.options&.dig(:parallel)
parallel = parallel.dig(:total) if parallel.is_a?(Hash) parallel = parallel.dig(:total) if parallel.is_a?(Hash)
...@@ -150,14 +132,6 @@ module Gitlab ...@@ -150,14 +132,6 @@ module Gitlab
end end
end end
def memoize_secret_variables?
strong_memoize(:memoize_secret_variables) do
::Feature.enabled?(:ci_variables_builder_memoize_secret_variables,
project,
default_enabled: :yaml)
end
end
def strong_memoize_with(name, *args) def strong_memoize_with(name, *args)
container = strong_memoize(name) { {} } container = strong_memoize(name) { {} }
......
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