Commit fba367ca authored by Mark Chao's avatar Mark Chao

Merge branch '227052-removing-ci_variables_api_filter_environment_scope' into 'master'

Remove FF ci_variables_api_filter_environment_scope

See merge request gitlab-org/gitlab!41680
parents c08875ac 33b368da
...@@ -154,11 +154,7 @@ curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://git ...@@ -154,11 +154,7 @@ curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://git
## The `filter` parameter ## The `filter` parameter
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34490) in GitLab 13.2. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34490) in GitLab 13.2.
> - It's deployed behind a feature flag, disabled by default. > - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/227052) in GitLab 13.4.
> - [Became enabled by default](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/39209) on GitLab 13.3.
> - It's enabled on GitLab.com.
> - It's recommended for production use.
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable).
This parameter is used for filtering by attributes, such as `environment_scope`. This parameter is used for filtering by attributes, such as `environment_scope`.
...@@ -167,21 +163,3 @@ Example usage: ...@@ -167,21 +163,3 @@ Example usage:
```shell ```shell
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables/VARIABLE_1?filter[environment_scope]=production" curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables/VARIABLE_1?filter[environment_scope]=production"
``` ```
### Enable or disable
It is deployed behind a feature flag that is **enabled by default**.
[GitLab administrators with access to the GitLab Rails console](../administration/feature_flags.md)
can opt to disable it for your instance.
To disable it:
```ruby
Feature.disable(:ci_variables_api_filter_environment_scope)
```
To enable it:
```ruby
Feature.enable(:ci_variables_api_filter_environment_scope)
```
...@@ -17,7 +17,6 @@ module API ...@@ -17,7 +17,6 @@ module API
def find_variable(params) def find_variable(params)
variables = ::Ci::VariablesFinder.new(user_project, params).execute.to_a variables = ::Ci::VariablesFinder.new(user_project, params).execute.to_a
return variables.first unless ::Gitlab::Ci::Features.variables_api_filter_environment_scope?
return variables.first unless variables.many? # rubocop: disable CodeReuse/ActiveRecord return variables.first unless variables.many? # rubocop: disable CodeReuse/ActiveRecord
conflict!("There are multiple variables with provided parameters. Please use 'filter[environment_scope]'") conflict!("There are multiple variables with provided parameters. Please use 'filter[environment_scope]'")
......
...@@ -31,11 +31,6 @@ module Gitlab ...@@ -31,11 +31,6 @@ module Gitlab
::Feature.enabled?(:ci_store_pipeline_messages, project, default_enabled: true) ::Feature.enabled?(:ci_store_pipeline_messages, project, default_enabled: true)
end end
# Remove in https://gitlab.com/gitlab-org/gitlab/-/issues/227052
def self.variables_api_filter_environment_scope?
::Feature.enabled?(:ci_variables_api_filter_environment_scope, default_enabled: true)
end
def self.raise_job_rules_without_workflow_rules_warning? def self.raise_job_rules_without_workflow_rules_warning?
::Feature.enabled?(:ci_raise_job_rules_without_workflow_rules_warning, default_enabled: true) ::Feature.enabled?(:ci_raise_job_rules_without_workflow_rules_warning, default_enabled: true)
end end
......
...@@ -60,25 +60,10 @@ RSpec.describe API::Variables do ...@@ -60,25 +60,10 @@ RSpec.describe API::Variables do
let!(:var2) { create(:ci_variable, project: project, key: 'key1', environment_scope: 'production') } let!(:var2) { create(:ci_variable, project: project, key: 'key1', environment_scope: 'production') }
context 'when filter[environment_scope] is not passed' do context 'when filter[environment_scope] is not passed' do
context 'FF ci_variables_api_filter_environment_scope is enabled' do it 'returns 409' do
it 'returns 409' do get api("/projects/#{project.id}/variables/key1", user)
get api("/projects/#{project.id}/variables/key1", user)
expect(response).to have_gitlab_http_status(:conflict) expect(response).to have_gitlab_http_status(:conflict)
end
end
context 'FF ci_variables_api_filter_environment_scope is disabled' do
before do
stub_feature_flags(ci_variables_api_filter_environment_scope: false)
end
it 'returns random one' do
get api("/projects/#{project.id}/variables/key1", user)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['key']).to eq('key1')
end
end end
end end
...@@ -232,25 +217,10 @@ RSpec.describe API::Variables do ...@@ -232,25 +217,10 @@ RSpec.describe API::Variables do
let!(:var2) { create(:ci_variable, project: project, key: 'key1', environment_scope: 'production') } let!(:var2) { create(:ci_variable, project: project, key: 'key1', environment_scope: 'production') }
context 'when filter[environment_scope] is not passed' do context 'when filter[environment_scope] is not passed' do
context 'FF ci_variables_api_filter_environment_scope is enabled' do it 'returns 409' do
it 'returns 409' do get api("/projects/#{project.id}/variables/key1", user)
get api("/projects/#{project.id}/variables/key1", user)
expect(response).to have_gitlab_http_status(:conflict) expect(response).to have_gitlab_http_status(:conflict)
end
end
context 'FF ci_variables_api_filter_environment_scope is disabled' do
before do
stub_feature_flags(ci_variables_api_filter_environment_scope: false)
end
it 'updates random one' do
put api("/projects/#{project.id}/variables/key1", user), params: { value: 'new_val' }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['value']).to eq('new_val')
end
end end
end end
...@@ -312,26 +282,10 @@ RSpec.describe API::Variables do ...@@ -312,26 +282,10 @@ RSpec.describe API::Variables do
let!(:var2) { create(:ci_variable, project: project, key: 'key1', environment_scope: 'production') } let!(:var2) { create(:ci_variable, project: project, key: 'key1', environment_scope: 'production') }
context 'when filter[environment_scope] is not passed' do context 'when filter[environment_scope] is not passed' do
context 'FF ci_variables_api_filter_environment_scope is enabled' do it 'returns 409' do
it 'returns 409' do get api("/projects/#{project.id}/variables/key1", user)
get api("/projects/#{project.id}/variables/key1", user)
expect(response).to have_gitlab_http_status(:conflict)
end
end
context 'FF ci_variables_api_filter_environment_scope is disabled' do
before do
stub_feature_flags(ci_variables_api_filter_environment_scope: false)
end
it 'deletes random one' do expect(response).to have_gitlab_http_status(:conflict)
expect do
delete api("/projects/#{project.id}/variables/key1", user), params: { 'filter[environment_scope]': 'production' }
expect(response).to have_gitlab_http_status(:no_content)
end.to change {project.variables.count}.by(-1)
end
end end
end end
......
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