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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
943827b3
Commit
943827b3
authored
Oct 31, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
option to make variables protected by default
parent
5bf89395
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
5 deletions
+82
-5
app/assets/javascripts/ci_variable_list/ci_variable_list.js
app/assets/javascripts/ci_variable_list/ci_variable_list.js
+3
-1
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+2
-1
app/models/application_setting.rb
app/models/application_setting.rb
+2
-1
app/views/admin/application_settings/_ci_cd.html.haml
app/views/admin/application_settings/_ci_cd.html.haml
+7
-0
app/views/ci/variables/_variable_row.html.haml
app/views/ci/variables/_variable_row.html.haml
+4
-2
db/migrate/20181031145139_add_protected_ci_variables_to_application_settings.rb
...139_add_protected_ci_variables_to_application_settings.rb
+17
-0
db/schema.rb
db/schema.rb
+1
-0
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/javascripts/ci_variable_list/ci_variable_list_spec.js
spec/javascripts/ci_variable_list/ci_variable_list_spec.js
+2
-0
spec/support/features/variable_list_shared_examples.rb
spec/support/features/variable_list_shared_examples.rb
+38
-0
No files found.
app/assets/javascripts/ci_variable_list/ci_variable_list.js
View file @
943827b3
...
@@ -36,7 +36,9 @@ export default class VariableList {
...
@@ -36,7 +36,9 @@ export default class VariableList {
},
},
protected
:
{
protected
:
{
selector
:
'
.js-ci-variable-input-protected
'
,
selector
:
'
.js-ci-variable-input-protected
'
,
default
:
'
false
'
,
// use `attr` instead of `data` as we don't want the value to be
// converted. we need the value as a string.
default
:
$
(
'
.js-ci-variable-input-protected
'
).
attr
(
'
data-default
'
),
},
},
environment_scope
:
{
environment_scope
:
{
// We can't use a `.js-` class here because
// We can't use a `.js-` class here because
...
...
app/helpers/application_settings_helper.rb
View file @
943827b3
...
@@ -218,7 +218,8 @@ module ApplicationSettingsHelper
...
@@ -218,7 +218,8 @@ module ApplicationSettingsHelper
:version_check_enabled
,
:version_check_enabled
,
:web_ide_clientside_preview_enabled
,
:web_ide_clientside_preview_enabled
,
:diff_max_patch_bytes
,
:diff_max_patch_bytes
,
:commit_email_hostname
:commit_email_hostname
,
:protected_ci_variables
]
]
end
end
...
...
app/models/application_setting.rb
View file @
943827b3
...
@@ -302,7 +302,8 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -302,7 +302,8 @@ class ApplicationSetting < ActiveRecord::Base
user_show_add_ssh_key_message:
true
,
user_show_add_ssh_key_message:
true
,
usage_stats_set_by_user_id:
nil
,
usage_stats_set_by_user_id:
nil
,
diff_max_patch_bytes:
Gitlab
::
Git
::
Diff
::
DEFAULT_MAX_PATCH_BYTES
,
diff_max_patch_bytes:
Gitlab
::
Git
::
Diff
::
DEFAULT_MAX_PATCH_BYTES
,
commit_email_hostname:
default_commit_email_hostname
commit_email_hostname:
default_commit_email_hostname
,
protected_ci_variables:
false
}
}
end
end
...
...
app/views/admin/application_settings/_ci_cd.html.haml
View file @
943827b3
...
@@ -49,5 +49,12 @@
...
@@ -49,5 +49,12 @@
Once that time passes, the jobs will be archived and no longer able to be
Once that time passes, the jobs will be archived and no longer able to be
retried. Make it empty to never expire jobs. It has to be no less than 1 day,
retried. Make it empty to never expire jobs. It has to be no less than 1 day,
for example:
<code>
15 days
</code>
,
<code>
1 month
</code>
,
<code>
2 years
</code>
.
for example:
<code>
15 days
</code>
,
<code>
1 month
</code>
,
<code>
2 years
</code>
.
.form-group
.form-check
=
f
.
check_box
:protected_ci_variables
,
class:
'form-check-input'
=
f
.
label
:protected_ci_variables
,
class:
'form-check-label'
do
=
s_
(
'AdminSettings|Environment variables are protected by default'
)
.form-text.text-muted
=
s_
(
'AdminSettings|When creating a new environment variable it will be protected by default.'
)
=
f
.
submit
'Save changes'
,
class:
"btn btn-success"
=
f
.
submit
'Save changes'
,
class:
"btn btn-success"
app/views/ci/variables/_variable_row.html.haml
View file @
943827b3
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
-
id
=
variable
&
.
id
-
id
=
variable
&
.
id
-
key
=
variable
&
.
key
-
key
=
variable
&
.
key
-
value
=
variable
&
.
value
-
value
=
variable
&
.
value
-
is_protected
=
variable
&&
!
only_key_value
?
variable
.
protected
:
false
-
is_protected_default
=
Gitlab
::
CurrentSettings
.
current_application_settings
.
protected_ci_variables
-
is_protected
=
variable
&&
!
only_key_value
?
variable
.
protected
:
is_protected_default
-
id_input_name
=
"
#{
form_field
}
[variables_attributes][][id]"
-
id_input_name
=
"
#{
form_field
}
[variables_attributes][][id]"
-
destroy_input_name
=
"
#{
form_field
}
[variables_attributes][][_destroy]"
-
destroy_input_name
=
"
#{
form_field
}
[variables_attributes][][_destroy]"
...
@@ -39,7 +40,8 @@
...
@@ -39,7 +40,8 @@
%input
{
type:
"hidden"
,
%input
{
type:
"hidden"
,
class:
'js-ci-variable-input-protected js-project-feature-toggle-input'
,
class:
'js-ci-variable-input-protected js-project-feature-toggle-input'
,
name:
protected_input_name
,
name:
protected_input_name
,
value:
is_protected
}
value:
is_protected
,
data:
{
default:
is_protected_default
.
to_s
}
}
%span
.toggle-icon
%span
.toggle-icon
=
sprite_icon
(
'status_success_borderless'
,
size:
16
,
css_class:
'toggle-icon-svg toggle-status-checked'
)
=
sprite_icon
(
'status_success_borderless'
,
size:
16
,
css_class:
'toggle-icon-svg toggle-status-checked'
)
=
sprite_icon
(
'status_failed_borderless'
,
size:
16
,
css_class:
'toggle-icon-svg toggle-status-unchecked'
)
=
sprite_icon
(
'status_failed_borderless'
,
size:
16
,
css_class:
'toggle-icon-svg toggle-status-unchecked'
)
...
...
db/migrate/20181031145139_add_protected_ci_variables_to_application_settings.rb
0 → 100644
View file @
943827b3
# frozen_string_literal: true
class
AddProtectedCiVariablesToApplicationSettings
<
ActiveRecord
::
Migration
[
5.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
(
:application_settings
,
:protected_ci_variables
,
:boolean
,
default:
false
,
allow_null:
false
)
end
def
down
remove_column
(
:application_settings
,
:protected_ci_variables
)
end
end
db/schema.rb
View file @
943827b3
...
@@ -166,6 +166,7 @@ ActiveRecord::Schema.define(version: 20181126153547) do
...
@@ -166,6 +166,7 @@ ActiveRecord::Schema.define(version: 20181126153547) do
t
.
integer
"diff_max_patch_bytes"
,
default:
102400
,
null:
false
t
.
integer
"diff_max_patch_bytes"
,
default:
102400
,
null:
false
t
.
integer
"archive_builds_in_seconds"
t
.
integer
"archive_builds_in_seconds"
t
.
string
"commit_email_hostname"
t
.
string
"commit_email_hostname"
t
.
boolean
"protected_ci_variables"
,
default:
false
,
null:
false
t
.
index
[
"usage_stats_set_by_user_id"
],
name:
"index_application_settings_on_usage_stats_set_by_user_id"
,
using: :btree
t
.
index
[
"usage_stats_set_by_user_id"
],
name:
"index_application_settings_on_usage_stats_set_by_user_id"
,
using: :btree
end
end
...
...
locale/gitlab.pot
View file @
943827b3
...
@@ -414,9 +414,15 @@ msgstr ""
...
@@ -414,9 +414,15 @@ msgstr ""
msgid "AdminProjects|Delete project"
msgid "AdminProjects|Delete project"
msgstr ""
msgstr ""
msgid "AdminSettings|Environment variables are protected by default"
msgstr ""
msgid "AdminSettings|Specify a domain to use by default for every project's Auto Review Apps and Auto Deploy stages."
msgid "AdminSettings|Specify a domain to use by default for every project's Auto Review Apps and Auto Deploy stages."
msgstr ""
msgstr ""
msgid "AdminSettings|When creating a new environment variable it will be protected by default."
msgstr ""
msgid "AdminUsers|Block user"
msgid "AdminUsers|Block user"
msgstr ""
msgstr ""
...
...
spec/javascripts/ci_variable_list/ci_variable_list_spec.js
View file @
943827b3
...
@@ -118,6 +118,8 @@ describe('VariableList', () => {
...
@@ -118,6 +118,8 @@ describe('VariableList', () => {
loadFixtures
(
'
projects/ci_cd_settings.html.raw
'
);
loadFixtures
(
'
projects/ci_cd_settings.html.raw
'
);
$wrapper
=
$
(
'
.js-ci-variable-list-section
'
);
$wrapper
=
$
(
'
.js-ci-variable-list-section
'
);
$wrapper
.
find
(
'
.js-ci-variable-input-protected
'
).
attr
(
'
data-default
'
,
'
false
'
);
variableList
=
new
VariableList
({
variableList
=
new
VariableList
({
container
:
$wrapper
,
container
:
$wrapper
,
formField
:
'
variables
'
,
formField
:
'
variables
'
,
...
...
spec/support/features/variable_list_shared_examples.rb
View file @
943827b3
...
@@ -63,6 +63,44 @@ shared_examples 'variable list' do
...
@@ -63,6 +63,44 @@ shared_examples 'variable list' do
end
end
end
end
context
'defaults to the application setting'
do
context
'application setting is true'
do
before
do
stub_application_setting
(
protected_ci_variables:
true
)
end
it
'defaults to protected'
do
visit
page_path
page
.
within
(
'.js-ci-variable-list-section .js-row:last-child'
)
do
find
(
'.js-ci-variable-input-key'
).
set
(
'key'
)
end
values
=
all
(
'.js-ci-variable-input-protected'
,
visible:
false
).
map
(
&
:value
)
expect
(
values
).
to
eq
%w(false true true)
end
end
context
'application setting is false'
do
before
do
stub_application_setting
(
protected_ci_variables:
false
)
end
it
'defaults to unprotected'
do
visit
page_path
page
.
within
(
'.js-ci-variable-list-section .js-row:last-child'
)
do
find
(
'.js-ci-variable-input-key'
).
set
(
'key'
)
end
values
=
all
(
'.js-ci-variable-input-protected'
,
visible:
false
).
map
(
&
:value
)
expect
(
values
).
to
eq
%w(false false false)
end
end
end
it
'reveals and hides variables'
do
it
'reveals and hides variables'
do
page
.
within
(
'.js-ci-variable-list-section'
)
do
page
.
within
(
'.js-ci-variable-list-section'
)
do
expect
(
first
(
'.js-ci-variable-input-key'
).
value
).
to
eq
(
variable
.
key
)
expect
(
first
(
'.js-ci-variable-input-key'
).
value
).
to
eq
(
variable
.
key
)
...
...
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