Cleanup expanded_environment_name
usage
Context
- https://gitlab.com/gitlab-org/gitlab/-/blob/692261c95f5af1bbb3c2266e7843c1ab82be269f/app/models/environment.rb#L415 - Should work with this MR because we are changing
Ci::Deployable#expanded_environment_name
but this method could be refactored to pull jobs directly fromEnvironments::Job
.- https://gitlab.com/gitlab-org/gitlab/-/blob/59fe8b887ec512fe38f887500007d0c5906c630b/app/services/ci/clone_job_service.rb#L39-42 - We may want to have an issue about cleaning this up after we run the background migration to backfill the data.
- https://gitlab.com/gitlab-org/gitlab/-/blob/e8a5d10ebee124d6d26ac8db01b5a6061ee46286/lib/gitlab/data_builder/build.rb#L107-114 - We should be using the
Environments::Job
.- https://gitlab.com/gitlab-org/gitlab/-/blob/e8a5d10ebee124d6d26ac8db01b5a6061ee46286/lib/gitlab/data_builder/pipeline.rb#L151-159 - we should be using the
Environments::Job
.
Problem
With the introduction of Environments::Job
model we now have a better association to fetch the persisted environment.
We should reduce to the minimum (or remove) the usage of expanded_environment_name
and to use the persisted environment, instead of comparing environments by name.
Even the definition of Ci::Deployable#persisted_environment
should use job.job_environment.environment
instead of a lookup by name.
Related issues
Edited by Fabio Pitino