Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f7648476
Commit
f7648476
authored
Jul 22, 2020
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always use expanded env name to load persisted env
Remove FF and accessing env through deployment
parent
2bcfaf6d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
45 deletions
+10
-45
app/models/ci/build.rb
app/models/ci/build.rb
+2
-4
changelogs/unreleased/id-persisted-env.yml
changelogs/unreleased/id-persisted-env.yml
+5
-0
ee/spec/policies/ci/build_policy_spec.rb
ee/spec/policies/ci/build_policy_spec.rb
+0
-16
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+3
-25
No files found.
app/models/ci/build.rb
View file @
f7648476
...
@@ -73,8 +73,7 @@ module Ci
...
@@ -73,8 +73,7 @@ module Ci
return
unless
has_environment?
return
unless
has_environment?
strong_memoize
(
:persisted_environment
)
do
strong_memoize
(
:persisted_environment
)
do
deployment
&
.
environment
||
Environment
.
find_by
(
name:
expanded_environment_name
,
project:
project
)
Environment
.
find_by
(
name:
expanded_environment_name
,
project:
project
)
end
end
end
end
...
@@ -457,8 +456,7 @@ module Ci
...
@@ -457,8 +456,7 @@ module Ci
strong_memoize
(
:expanded_environment_name
)
do
strong_memoize
(
:expanded_environment_name
)
do
# We're using a persisted expanded environment name in order to avoid
# We're using a persisted expanded environment name in order to avoid
# variable expansion per request.
# variable expansion per request.
if
Feature
.
enabled?
(
:ci_persisted_expanded_environment_name
,
project
,
default_enabled:
true
)
&&
if
metadata
&
.
expanded_environment_name
.
present?
metadata
&
.
expanded_environment_name
.
present?
metadata
.
expanded_environment_name
metadata
.
expanded_environment_name
else
else
ExpandVariables
.
expand
(
environment
,
->
{
simple_variables
})
ExpandVariables
.
expand
(
environment
,
->
{
simple_variables
})
...
...
changelogs/unreleased/id-persisted-env.yml
0 → 100644
View file @
f7648476
---
title
:
Always use expanded env name to load persisted environment
merge_request
:
37585
author
:
type
:
performance
ee/spec/policies/ci/build_policy_spec.rb
View file @
f7648476
...
@@ -15,21 +15,5 @@ RSpec.describe Ci::BuildPolicy do
...
@@ -15,21 +15,5 @@ RSpec.describe Ci::BuildPolicy do
subject
{
user
.
can?
(
:update_build
,
build
)
}
subject
{
user
.
can?
(
:update_build
,
build
)
}
it_behaves_like
'protected environments access'
it_behaves_like
'protected environments access'
context
'when a pipeline has manual deployment job'
do
let!
(
:build
)
{
create
(
:ee_ci_build
,
:with_deployment
,
:manual
,
:deploy_to_production
,
pipeline:
pipeline
)
}
before
do
project
.
add_developer
(
user
)
end
it
'does not expand environment name'
do
allow
(
build
.
project
).
to
receive
(
:protected_environments_feature_available?
)
{
true
}
expect
(
build
.
project
).
to
receive
(
:protected_environment_accessible_to?
)
expect
(
build
).
not_to
receive
(
:expanded_environment_name
)
subject
end
end
end
end
end
end
spec/models/ci/build_spec.rb
View file @
f7648476
...
@@ -1195,18 +1195,6 @@ RSpec.describe Ci::Build do
...
@@ -1195,18 +1195,6 @@ RSpec.describe Ci::Build do
is_expected
.
to
eq
(
'review/host'
)
is_expected
.
to
eq
(
'review/host'
)
end
end
context
'when ci_persisted_expanded_environment_name feature flag is disabled'
do
before
do
stub_feature_flags
(
ci_persisted_expanded_environment_name:
false
)
end
it
'returns an expanded environment name with a list of variables'
do
expect
(
build
).
to
receive
(
:simple_variables
).
once
.
and_call_original
is_expected
.
to
eq
(
'review/host'
)
end
end
end
end
end
end
...
@@ -2009,23 +1997,13 @@ RSpec.describe Ci::Build do
...
@@ -2009,23 +1997,13 @@ RSpec.describe Ci::Build do
it
{
is_expected
.
to
be_nil
}
it
{
is_expected
.
to
be_nil
}
end
end
context
'when build has a start environment'
do
let
(
:build
)
{
create
(
:ci_build
,
:with_deployment
,
:deploy_to_production
,
pipeline:
pipeline
)
}
it
'does not expand environment name'
do
expect
(
build
).
not_to
receive
(
:expanded_environment_name
)
subject
end
end
context
'when build has a stop environment'
do
context
'when build has a stop environment'
do
let
(
:build
)
{
create
(
:ci_build
,
:stop_review_app
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
:stop_review_app
,
pipeline:
pipeline
,
environment:
"foo-
#{
project
.
default_branch
}
"
)
}
it
'expands environment name'
do
it
'expands environment name'
do
expect
(
build
).
to
receive
(
:expanded_environment_name
)
expect
(
build
).
to
receive
(
:expanded_environment_name
)
.
and_call_original
subject
is_expected
.
to
eq
(
environment
)
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment