Commit a316ac96 authored by Tiger's avatar Tiger Committed by Tiger Watson

Remove :scoped_group_variables feature flag

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58200
parent cb4d67f0
...@@ -130,9 +130,6 @@ export default { ...@@ -130,9 +130,6 @@ export default {
return true; return true;
}, },
scopedVariablesEnabled() {
return !this.isGroup || this.glFeatures.scopedGroupVariables;
},
scopedVariablesAvailable() { scopedVariablesAvailable() {
return !this.isGroup || this.glFeatures.groupScopedCiVariables; return !this.isGroup || this.glFeatures.groupScopedCiVariables;
}, },
...@@ -230,17 +227,11 @@ export default { ...@@ -230,17 +227,11 @@ export default {
</gl-form-group> </gl-form-group>
<div class="d-flex"> <div class="d-flex">
<gl-form-group <gl-form-group :label="__('Type')" label-for="ci-variable-type" class="w-50 gl-mr-5">
:label="__('Type')"
label-for="ci-variable-type"
class="w-50 gl-mr-5"
:class="{ 'w-100': !scopedVariablesEnabled }"
>
<gl-form-select id="ci-variable-type" v-model="variable_type" :options="typeOptions" /> <gl-form-select id="ci-variable-type" v-model="variable_type" :options="typeOptions" />
</gl-form-group> </gl-form-group>
<gl-form-group <gl-form-group
v-if="scopedVariablesEnabled"
:label="__('Environment scope')" :label="__('Environment scope')"
label-for="ci-variable-env" label-for="ci-variable-env"
class="w-50" class="w-50"
......
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
computed: { computed: {
...mapState(['variables', 'valuesHidden', 'isGroup', 'isLoading', 'isDeleting']), ...mapState(['variables', 'valuesHidden', 'isLoading', 'isDeleting']),
valuesButtonText() { valuesButtonText() {
return this.valuesHidden ? __('Reveal values') : __('Hide values'); return this.valuesHidden ? __('Reveal values') : __('Hide values');
}, },
...@@ -70,9 +70,6 @@ export default { ...@@ -70,9 +70,6 @@ export default {
return this.variables && this.variables.length > 0; return this.variables && this.variables.length > 0;
}, },
fields() { fields() {
if (this.isGroup && !this.glFeatures.scopedGroupVariables) {
return this.$options.fields.filter((field) => field.key !== 'environment_scope');
}
return this.$options.fields; return this.$options.fields;
}, },
}, },
......
...@@ -10,7 +10,6 @@ module Groups ...@@ -10,7 +10,6 @@ module Groups
before_action :authorize_admin_group! before_action :authorize_admin_group!
before_action :authorize_update_max_artifacts_size!, only: [:update] before_action :authorize_update_max_artifacts_size!, only: [:update]
before_action :define_variables, only: [:show] before_action :define_variables, only: [:show]
before_action :push_feature_flags, only: [:show]
before_action :push_licensed_features, only: [:show] before_action :push_licensed_features, only: [:show]
feature_category :continuous_integration feature_category :continuous_integration
...@@ -94,10 +93,6 @@ module Groups ...@@ -94,10 +93,6 @@ module Groups
params.require(:group).permit(:max_artifacts_size) params.require(:group).permit(:max_artifacts_size)
end end
def push_feature_flags
push_frontend_feature_flag(:scoped_group_variables, group)
end
# Overridden in EE # Overridden in EE
def push_licensed_features def push_licensed_features
end end
......
...@@ -805,13 +805,11 @@ class Group < Namespace ...@@ -805,13 +805,11 @@ class Group < Namespace
variables = Ci::GroupVariable.where(group: list_of_ids) variables = Ci::GroupVariable.where(group: list_of_ids)
variables = variables.unprotected unless project.protected_for?(ref) variables = variables.unprotected unless project.protected_for?(ref)
if Feature.enabled?(:scoped_group_variables, self, default_enabled: :yaml) variables = if environment
variables = if environment variables.on_environment(environment)
variables.on_environment(environment) else
else variables.where(environment_scope: '*')
variables.where(environment_scope: '*') end
end
end
variables = variables.group_by(&:group_id) variables = variables.group_by(&:group_id)
list_of_ids.reverse.flat_map { |group| variables[group.id] }.compact list_of_ids.reverse.flat_map { |group| variables[group.id] }.compact
......
...@@ -7,9 +7,8 @@ ...@@ -7,9 +7,8 @@
%tr %tr
%td.gl-text-truncate %td.gl-text-truncate
= variable.key = variable.key
- if Feature.enabled?(:scoped_group_variables, default_enabled: :yaml) %td.gl-text-truncate
%td.gl-text-truncate = variable.environment_scope
= variable.environment_scope
%td.gl-text-truncate %td.gl-text-truncate
%a.group-origin-link{ href: group_settings_ci_cd_path(variable.group) } %a.group-origin-link{ href: group_settings_ci_cd_path(variable.group) }
= variable.group.name = variable.group.name
%tr %tr
%th %th
= s_('Key') = s_('Key')
- if Feature.enabled?(:scoped_group_variables, default_enabled: :yaml) %th
%th = s_('Environments')
= s_('Environments')
%th %th
= s_('Group') = s_('Group')
---
name: scoped_group_variables
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55256
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/323298
milestone: '13.10'
type: development
group: group::configure
default_enabled: false
...@@ -31,14 +31,16 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a ...@@ -31,14 +31,16 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a
"variable_type": "env_var", "variable_type": "env_var",
"value": "TEST_1", "value": "TEST_1",
"protected": false, "protected": false,
"masked": false "masked": false,
"environment_scope": "*"
}, },
{ {
"key": "TEST_VARIABLE_2", "key": "TEST_VARIABLE_2",
"variable_type": "env_var", "variable_type": "env_var",
"value": "TEST_2", "value": "TEST_2",
"protected": false, "protected": false,
"masked": false "masked": false,
"environment_scope": "*"
} }
] ]
``` ```
...@@ -66,7 +68,8 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a ...@@ -66,7 +68,8 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a
"variable_type": "env_var", "variable_type": "env_var",
"value": "TEST_1", "value": "TEST_1",
"protected": false, "protected": false,
"masked": false "masked": false,
"environment_scope": "*"
} }
``` ```
...@@ -86,6 +89,7 @@ POST /groups/:id/variables ...@@ -86,6 +89,7 @@ POST /groups/:id/variables
| `variable_type` | string | no | The type of a variable. Available types are: `env_var` (default) and `file` | | `variable_type` | string | no | The type of a variable. Available types are: `env_var` (default) and `file` |
| `protected` | boolean | no | Whether the variable is protected | | `protected` | boolean | no | Whether the variable is protected |
| `masked` | boolean | no | Whether the variable is masked | | `masked` | boolean | no | Whether the variable is masked |
| `environment_scope` **(PREMIUM)** | string | no | The [environment scope](../ci/variables/README.md#limit-the-environment-scope-of-a-cicd-variable) of a variable |
```shell ```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/variables" --form "key=NEW_VARIABLE" --form "value=new value" curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/variables" --form "key=NEW_VARIABLE" --form "value=new value"
...@@ -97,7 +101,8 @@ curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitla ...@@ -97,7 +101,8 @@ curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitla
"value": "new value", "value": "new value",
"variable_type": "env_var", "variable_type": "env_var",
"protected": false, "protected": false,
"masked": false "masked": false,
"environment_scope": "*"
} }
``` ```
...@@ -117,6 +122,7 @@ PUT /groups/:id/variables/:key ...@@ -117,6 +122,7 @@ PUT /groups/:id/variables/:key
| `variable_type` | string | no | The type of a variable. Available types are: `env_var` (default) and `file` | | `variable_type` | string | no | The type of a variable. Available types are: `env_var` (default) and `file` |
| `protected` | boolean | no | Whether the variable is protected | | `protected` | boolean | no | Whether the variable is protected |
| `masked` | boolean | no | Whether the variable is masked | | `masked` | boolean | no | Whether the variable is masked |
| `environment_scope` **(PREMIUM)** | string | no | The [environment scope](../ci/variables/README.md#limit-the-environment-scope-of-a-cicd-variable) of a variable |
```shell ```shell
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/variables/NEW_VARIABLE" --form "value=updated value" curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/variables/NEW_VARIABLE" --form "value=updated value"
...@@ -128,7 +134,8 @@ curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab ...@@ -128,7 +134,8 @@ curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab
"value": "updated value", "value": "updated value",
"variable_type": "env_var", "variable_type": "env_var",
"protected": true, "protected": true,
"masked": true "masked": true,
"environment_scope": "*"
} }
``` ```
......
...@@ -163,6 +163,9 @@ The output is: ...@@ -163,6 +163,9 @@ The output is:
### Group CI/CD variables ### Group CI/CD variables
> - Introduced in GitLab 9.4.
> - Support for [environment scopes](https://gitlab.com/gitlab-org/gitlab/-/issues/2874) added to GitLab Premium in 13.11
To make a CI/CD variable available to all projects in a group, define a group CI/CD variable. To make a CI/CD variable available to all projects in a group, define a group CI/CD variable.
Use group variables to store secrets like passwords, SSH keys, and credentials, if you: Use group variables to store secrets like passwords, SSH keys, and credentials, if you:
...@@ -178,6 +181,7 @@ To add a group variable: ...@@ -178,6 +181,7 @@ To add a group variable:
- **Key**: Must be one line, with no spaces, using only letters, numbers, or `_`. - **Key**: Must be one line, with no spaces, using only letters, numbers, or `_`.
- **Value**: No limitations. - **Value**: No limitations.
- **Type**: [`File` or `Variable`](#cicd-variable-types). - **Type**: [`File` or `Variable`](#cicd-variable-types).
- **Environment scope** (optional): `All`, or specific [environments](#limit-the-environment-scope-of-a-cicd-variable).
- **Protect variable** (Optional): If selected, the variable is only available - **Protect variable** (Optional): If selected, the variable is only available
in pipelines that run on protected branches or tags. in pipelines that run on protected branches or tags.
- **Mask variable** (Optional): If selected, the variable's **Value** is masked - **Mask variable** (Optional): If selected, the variable's **Value** is masked
......
...@@ -244,8 +244,7 @@ module EE ...@@ -244,8 +244,7 @@ module EE
end end
def scoped_variables_available? def scoped_variables_available?
::Feature.enabled?(:scoped_group_variables, self, default_enabled: :yaml) && feature_available?(:group_scoped_ci_variables)
feature_available?(:group_scoped_ci_variables)
end end
def actual_size_limit def actual_size_limit
......
---
title: Add environment scopes to group CI/CD variables
merge_request: 58200
author:
type: added
...@@ -677,26 +677,24 @@ RSpec.describe Group do ...@@ -677,26 +677,24 @@ RSpec.describe Group do
end end
describe '#scoped_variables_available?' do describe '#scoped_variables_available?' do
using RSpec::Parameterized::TableSyntax
let(:group) { create(:group) } let(:group) { create(:group) }
subject { group.scoped_variables_available? } subject { group.scoped_variables_available? }
where(:feature_enabled, :feature_available, :scoped_variables_available) do before do
true | true | true stub_licensed_features(group_scoped_ci_variables: feature_available)
false | true | false
true | false | false
false | false | false
end end
with_them do context 'licensed feature is available' do
before do let(:feature_available) { true }
stub_feature_flags(scoped_group_variables: feature_enabled)
stub_licensed_features(group_scoped_ci_variables: feature_available) it { is_expected.to be true }
end end
context 'licensed feature is not available' do
let(:feature_available) { false }
it { is_expected.to eq(scoped_variables_available) } it { is_expected.to be false }
end end
end end
......
...@@ -158,7 +158,6 @@ describe('Ci variable modal', () => { ...@@ -158,7 +158,6 @@ describe('Ci variable modal', () => {
isGroup: true, isGroup: true,
provide: { provide: {
glFeatures: { glFeatures: {
scopedGroupVariables: true,
groupScopedCiVariables: true, groupScopedCiVariables: true,
}, },
}, },
...@@ -168,29 +167,12 @@ describe('Ci variable modal', () => { ...@@ -168,29 +167,12 @@ describe('Ci variable modal', () => {
expect(findCiEnvironmentsDropdown().isVisible()).toBe(true); expect(findCiEnvironmentsDropdown().isVisible()).toBe(true);
}); });
describe('feature flag is disabled', () => {
it('hides the dropdown', () => {
createComponent(shallowMount, {
isGroup: true,
provide: {
glFeatures: {
scopedGroupVariables: false,
groupScopedCiVariables: true,
},
},
});
expect(findCiEnvironmentsDropdown().exists()).toBe(false);
});
});
describe('licensed feature is not available', () => { describe('licensed feature is not available', () => {
it('disables the dropdown', () => { it('disables the dropdown', () => {
createComponent(mount, { createComponent(mount, {
isGroup: true, isGroup: true,
provide: { provide: {
glFeatures: { glFeatures: {
scopedGroupVariables: true,
groupScopedCiVariables: false, groupScopedCiVariables: false,
}, },
}, },
......
...@@ -11,18 +11,13 @@ describe('Ci variable table', () => { ...@@ -11,18 +11,13 @@ describe('Ci variable table', () => {
let wrapper; let wrapper;
let store; let store;
const createComponent = (isGroup = false, scopedGroupVariables = false) => { const createComponent = () => {
store = createStore({ isGroup }); store = createStore();
jest.spyOn(store, 'dispatch').mockImplementation(); jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = mount(CiVariableTable, { wrapper = mount(CiVariableTable, {
attachTo: document.body, attachTo: document.body,
localVue, localVue,
store, store,
provide: {
glFeatures: {
scopedGroupVariables,
},
},
}); });
}; };
...@@ -42,19 +37,6 @@ describe('Ci variable table', () => { ...@@ -42,19 +37,6 @@ describe('Ci variable table', () => {
expect(store.dispatch).toHaveBeenCalledWith('fetchVariables'); expect(store.dispatch).toHaveBeenCalledWith('fetchVariables');
}); });
it('fields do not contain environment_scope if group level and feature is disabled', () => {
createComponent(true, false);
expect(wrapper.vm.fields).not.toEqual(
expect.arrayContaining([
expect.objectContaining({
key: 'environment_scope',
label: 'Environments',
}),
]),
);
});
describe('Renders correct data', () => { describe('Renders correct data', () => {
it('displays empty message when variables are not present', () => { it('displays empty message when variables are not present', () => {
expect(findEmptyVariablesPlaceholder().exists()).toBe(true); expect(findEmptyVariablesPlaceholder().exists()).toBe(true);
......
...@@ -1616,30 +1616,6 @@ RSpec.describe Group do ...@@ -1616,30 +1616,6 @@ RSpec.describe Group do
perfectly_matched_variable]) perfectly_matched_variable])
end end
end end
context 'when :scoped_group_variables feature flag is disabled' do
before do
stub_feature_flags(scoped_group_variables: false)
end
context 'when environment scope is exactly matched' do
let(:environment_scope) { 'review/name' }
it { is_expected.to contain_exactly(ci_variable) }
end
context 'when environment scope is partially matched' do
let(:environment_scope) { 'review/*' }
it { is_expected.to contain_exactly(ci_variable) }
end
context 'when environment scope does not match' do
let(:environment_scope) { 'review/*/special' }
it { is_expected.to contain_exactly(ci_variable) }
end
end
end end
context 'when group has children' do context 'when group has children' do
......
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