Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
64e6689501a6
Commit
64e66895
authored
Oct 30, 2018
by
Marcel Amirault
Browse files
Renaming Secret Variables in the codebase
parent
0360938132ae
Changes
28
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
64e66895
...
...
@@ -265,7 +265,7 @@
SCRIPT_NAME
:
trigger-build-docs
environment
:
name
:
review-docs/$CI_COMMIT_REF_SLUG
# DOCS_REVIEW_APPS_DOMAIN and DOCS_GITLAB_REPO_SUFFIX are
secret
variables
# DOCS_REVIEW_APPS_DOMAIN and DOCS_GITLAB_REPO_SUFFIX are
CI
variables
# Discussion: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14236/diffs#note_40140693
url
:
http://$CI_ENVIRONMENT_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX
on_stop
:
review-docs-cleanup
...
...
app/assets/javascripts/ci_variable_list/ajax_variable_list.js
View file @
64e66895
...
...
@@ -47,7 +47,7 @@
}
onSaveClicked
()
{
const
loadingIcon
=
this
.
saveButton
.
querySelector
(
'
.js-
secret
-variables-save-loading-icon
'
);
const
loadingIcon
=
this
.
saveButton
.
querySelector
(
'
.js-
ci
-variables-save-loading-icon
'
);
loadingIcon
.
classList
.
toggle
(
'
hide
'
,
false
);
this
.
errorBox
.
classList
.
toggle
(
'
hide
'
,
true
);
// We use this to prevent a user from changing a key before we have a chance
...
...
app/assets/javascripts/pages/groups/settings/ci_cd/show/index.js
View file @
64e66895
...
...
@@ -9,7 +9,7 @@
// eslint-disable-next-line no-new
new
AjaxVariableList
({
container
:
variableListEl
,
saveButton
:
variableListEl
.
querySelector
(
'
.js-
secret
-variables-save-button
'
),
saveButton
:
variableListEl
.
querySelector
(
'
.js-
ci
-variables-save-button
'
),
errorBox
:
variableListEl
.
querySelector
(
'
.js-ci-variable-error-box
'
),
saveEndpoint
:
variableListEl
.
dataset
.
saveEndpoint
,
});
...
...
app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js
View file @
64e66895
...
...
@@ -18,7 +18,7 @@
// eslint-disable-next-line no-new
new
AjaxVariableList
({
container
:
variableListEl
,
saveButton
:
variableListEl
.
querySelector
(
'
.js-
secret
-variables-save-button
'
),
saveButton
:
variableListEl
.
querySelector
(
'
.js-
ci
-variables-save-button
'
),
errorBox
:
variableListEl
.
querySelector
(
'
.js-ci-variable-error-box
'
),
saveEndpoint
:
variableListEl
.
dataset
.
saveEndpoint
,
});
...
...
app/controllers/groups/settings/ci_cd_controller.rb
View file @
64e66895
...
...
@@ -7,7 +7,7 @@
before_action
:authorize_admin_pipeline!
def
show
define_
secret
_variables
define_
ci
_variables
end
def
reset_registration_token
...
...
@@ -19,7 +19,7 @@
private
def
define_
secret
_variables
def
define_
ci
_variables
@variable
=
Ci
::
GroupVariable
.
new
(
group:
group
)
.
present
(
current_user:
current_user
)
@variables
=
group
.
variables
.
order_key_asc
...
...
app/controllers/projects/settings/ci_cd_controller.rb
View file @
64e66895
...
...
@@ -68,7 +68,7 @@
def
define_variables
define_runners_variables
define_
secret
_variables
define_
ci
_variables
define_triggers_variables
define_badges_variables
define_auto_devops_variables
...
...
@@ -90,7 +90,7 @@
@group_runners
=
::
Ci
::
Runner
.
belonging_to_parent_group_of_project
(
@project
.
id
)
end
def
define_
secret
_variables
def
define_
ci
_variables
@variable
=
::
Ci
::
Variable
.
new
(
project:
project
)
.
present
(
current_user:
current_user
)
@variables
=
project
.
variables
.
order_key_asc
...
...
app/models/ci/build.rb
View file @
64e66895
...
...
@@ -593,7 +593,7 @@
def
secret_group_variables
return
[]
unless
project
.
group
project
.
group
.
secret
_variables_for
(
ref
,
project
)
project
.
group
.
ci
_variables_for
(
ref
,
project
)
end
def
secret_project_variables
(
environment:
persisted_environment
)
...
...
@@ -597,7 +597,7 @@
end
def
secret_project_variables
(
environment:
persisted_environment
)
project
.
secret
_variables_for
(
ref:
ref
,
environment:
environment
)
project
.
ci
_variables_for
(
ref:
ref
,
environment:
environment
)
end
def
steps
...
...
app/models/group.rb
View file @
64e66895
...
...
@@ -369,7 +369,7 @@
}
end
def
secret
_variables_for
(
ref
,
project
)
def
ci
_variables_for
(
ref
,
project
)
list_of_ids
=
[
self
]
+
ancestors
variables
=
Ci
::
GroupVariable
.
where
(
group:
list_of_ids
)
variables
=
variables
.
unprotected
unless
project
.
protected_for?
(
ref
)
...
...
app/models/project.rb
View file @
64e66895
...
...
@@ -1811,7 +1811,7 @@
.
first
end
def
secret
_variables_for
(
ref
:,
environment:
nil
)
def
ci
_variables_for
(
ref
:,
environment:
nil
)
# EE would use the environment
if
protected_for?
(
ref
)
variables
...
...
app/views/ci/variables/_index.html.haml
View file @
64e66895
...
...
@@ -9,8 +9,8 @@
=
render
'ci/variables/variable_row'
,
form_field:
'variables'
,
variable:
variable
=
render
'ci/variables/variable_row'
,
form_field:
'variables'
.prepend-top-20
%button
.btn.btn-success.js-
secret
-variables-save-button
{
type:
'button'
}
%span
.hide.js-
secret
-variables-save-loading-icon
%button
.btn.btn-success.js-
ci
-variables-save-button
{
type:
'button'
}
%span
.hide.js-
ci
-variables-save-loading-icon
=
icon
(
'spinner spin'
)
=
_
(
'Save variables'
)
%button
.btn.btn-info.btn-inverted.prepend-left-10.js-secret-value-reveal-button
{
type:
'button'
,
data:
{
secret_reveal_status:
"#{@variables.size == 0}"
}
}
...
...
app/views/groups/settings/ci_cd/show.html.haml
View file @
64e66895
...
...
@@ -3,7 +3,7 @@
-
expanded
=
Rails
.
env
.
test?
%section
.settings
#
secret
-variables
.no-animate
{
class:
(
'expanded'
if
expanded
)
}
%section
.settings
#
ci
-variables
.no-animate
{
class:
(
'expanded'
if
expanded
)
}
.settings-header
%h4
=
_
(
'Variables'
)
...
...
changelogs/unreleased/ravlen-rename-secret-variables-in-codebase.yml
0 → 100644
View file @
64e66895
---
title
:
"
Secret
Variables
renamed
to
CI
Variables
in
the
codebase,
to
match
UX"
merge_request
:
22414
author
:
Marcel Amirault @ravlen
type
:
changed
\ No newline at end of file
qa/qa.rb
View file @
64e66895
...
...
@@ -53,7 +53,7 @@
autoload
:DeployKey
,
'qa/factory/resource/deploy_key'
autoload
:DeployToken
,
'qa/factory/resource/deploy_token'
autoload
:Branch
,
'qa/factory/resource/branch'
autoload
:
Secret
Variable
,
'qa/factory/resource/
secret
_variable'
autoload
:
Ci
Variable
,
'qa/factory/resource/
ci
_variable'
autoload
:Runner
,
'qa/factory/resource/runner'
autoload
:PersonalAccessToken
,
'qa/factory/resource/personal_access_token'
autoload
:KubernetesCluster
,
'qa/factory/resource/kubernetes_cluster'
...
...
@@ -183,7 +183,7 @@
autoload
:DeployKeys
,
'qa/page/project/settings/deploy_keys'
autoload
:DeployTokens
,
'qa/page/project/settings/deploy_tokens'
autoload
:ProtectedBranches
,
'qa/page/project/settings/protected_branches'
autoload
:
Secret
Variables
,
'qa/page/project/settings/
secret
_variables'
autoload
:
Ci
Variables
,
'qa/page/project/settings/
ci
_variables'
autoload
:Runners
,
'qa/page/project/settings/runners'
autoload
:MergeRequest
,
'qa/page/project/settings/merge_request'
autoload
:Members
,
'qa/page/project/settings/members'
...
...
qa/qa/factory/resource/ci_variable.rb
0 → 100644
View file @
64e66895
module
QA
module
Factory
module
Resource
class
CiVariable
<
Factory
::
Base
attr_accessor
:key
,
:value
attribute
:project
do
Factory
::
Resource
::
Project
.
fabricate!
do
|
resource
|
resource
.
name
=
'project-with-ci-variables'
resource
.
description
=
'project for adding CI variable test'
end
end
def
fabricate!
project
.
visit!
Page
::
Project
::
Menu
.
perform
(
&
:click_ci_cd_settings
)
Page
::
Project
::
Settings
::
CICD
.
perform
do
|
setting
|
setting
.
expand_ci_variables
do
|
page
|
page
.
fill_variable
(
key
,
value
)
page
.
save_variables
end
end
end
end
end
end
end
qa/qa/factory/resource/secret_variable.rb
deleted
100644 → 0
View file @
03609381
module
QA
module
Factory
module
Resource
class
SecretVariable
<
Factory
::
Base
attr_accessor
:key
,
:value
attribute
:project
do
Factory
::
Resource
::
Project
.
fabricate!
do
|
resource
|
resource
.
name
=
'project-with-secret-variables'
resource
.
description
=
'project for adding secret variable test'
end
end
def
fabricate!
project
.
visit!
Page
::
Project
::
Menu
.
perform
(
&
:click_ci_cd_settings
)
Page
::
Project
::
Settings
::
CICD
.
perform
do
|
setting
|
setting
.
expand_secret_variables
do
|
page
|
page
.
fill_variable
(
key
,
value
)
page
.
save_variables
end
end
end
end
end
end
end
qa/qa/page/project/settings/ci_cd.rb
View file @
64e66895
...
...
@@ -25,5 +25,5 @@
end
end
def
expand_
secret
_variables
(
&
block
)
def
expand_
ci
_variables
(
&
block
)
expand_section
(
:variables_settings
)
do
...
...
@@ -29,5 +29,5 @@
expand_section
(
:variables_settings
)
do
Settings
::
Secret
Variables
.
perform
(
&
block
)
Settings
::
Ci
Variables
.
perform
(
&
block
)
end
end
...
...
qa/qa/page/project/settings/ci_variables.rb
0 → 100644
View file @
64e66895
module
QA
module
Page
module
Project
module
Settings
class
CiVariables
<
Page
::
Base
include
Common
view
'app/views/ci/variables/_variable_row.html.haml'
do
element
:variable_row
,
'.ci-variable-row-body'
# rubocop:disable QA/ElementWithPattern
element
:variable_key
,
'.qa-ci-variable-input-key'
# rubocop:disable QA/ElementWithPattern
element
:variable_value
,
'.qa-ci-variable-input-value'
# rubocop:disable QA/ElementWithPattern
end
view
'app/views/ci/variables/_index.html.haml'
do
element
:save_variables
,
'.js-ci-variables-save-button'
# rubocop:disable QA/ElementWithPattern
element
:reveal_values
,
'.js-secret-value-reveal-button'
# rubocop:disable QA/ElementWithPattern
end
def
fill_variable
(
key
,
value
)
keys
=
all_elements
(
:ci_variable_input_key
)
index
=
keys
.
size
-
1
# After we fill the key, JS would generate another field so
# we need to use the same index to find the corresponding one.
keys
[
index
].
set
(
key
)
node
=
all_elements
(
:ci_variable_input_value
)[
index
]
# Simply run `node.set(value)` is too slow for long text here,
# so we need to run JavaScript directly to set the value.
# The code was inspired from:
# https://github.com/teamcapybara/capybara/blob/679548cea10773d45e32808f4d964377cfe5e892/lib/capybara/selenium/node.rb#L217
execute_script
(
"arguments[0].value =
#{
value
.
to_json
}
"
,
node
)
end
def
save_variables
find
(
'.js-ci-variables-save-button'
).
click
end
def
reveal_variables
find
(
'.js-secret-value-reveal-button'
).
click
end
def
variable_value
(
key
)
within
(
'.ci-variable-row-body'
,
text:
key
)
do
find
(
'.qa-ci-variable-input-value'
).
value
end
end
end
end
end
end
end
qa/qa/page/project/settings/secret_variables.rb
deleted
100644 → 0
View file @
03609381
module
QA
module
Page
module
Project
module
Settings
class
SecretVariables
<
Page
::
Base
include
Common
view
'app/views/ci/variables/_variable_row.html.haml'
do
element
:variable_row
,
'.ci-variable-row-body'
# rubocop:disable QA/ElementWithPattern
element
:variable_key
,
'.qa-ci-variable-input-key'
# rubocop:disable QA/ElementWithPattern
element
:variable_value
,
'.qa-ci-variable-input-value'
# rubocop:disable QA/ElementWithPattern
end
view
'app/views/ci/variables/_index.html.haml'
do
element
:save_variables
,
'.js-secret-variables-save-button'
# rubocop:disable QA/ElementWithPattern
element
:reveal_values
,
'.js-secret-value-reveal-button'
# rubocop:disable QA/ElementWithPattern
end
def
fill_variable
(
key
,
value
)
keys
=
all_elements
(
:ci_variable_input_key
)
index
=
keys
.
size
-
1
# After we fill the key, JS would generate another field so
# we need to use the same index to find the corresponding one.
keys
[
index
].
set
(
key
)
node
=
all_elements
(
:ci_variable_input_value
)[
index
]
# Simply run `node.set(value)` is too slow for long text here,
# so we need to run JavaScript directly to set the value.
# The code was inspired from:
# https://github.com/teamcapybara/capybara/blob/679548cea10773d45e32808f4d964377cfe5e892/lib/capybara/selenium/node.rb#L217
execute_script
(
"arguments[0].value =
#{
value
.
to_json
}
"
,
node
)
end
def
save_variables
find
(
'.js-secret-variables-save-button'
).
click
end
def
reveal_variables
find
(
'.js-secret-value-reveal-button'
).
click
end
def
variable_value
(
key
)
within
(
'.ci-variable-row-body'
,
text:
key
)
do
find
(
'.qa-ci-variable-input-value'
).
value
end
end
end
end
end
end
end
qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb
0 → 100644
View file @
64e66895
# frozen_string_literal: true
module
QA
context
'Verify'
do
describe
'CI variable support'
do
it
'user adds a CI variable'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Factory
::
Resource
::
CiVariable
.
fabricate!
do
|
resource
|
resource
.
key
=
'VARIABLE_KEY'
resource
.
value
=
'some CI variable'
end
Page
::
Project
::
Settings
::
CICD
.
perform
do
|
settings
|
settings
.
expand_ci_variables
do
|
page
|
expect
(
page
).
to
have_field
(
with:
'VARIABLE_KEY'
)
expect
(
page
).
not_to
have_field
(
with:
'some CI variable'
)
page
.
reveal_variables
expect
(
page
).
to
have_field
(
with:
'some CI variable'
)
end
end
end
end
end
end
qa/qa/specs/features/browser_ui/4_verify/secret_variable/add_secret_variable_spec.rb
deleted
100644 → 0
View file @
03609381
# frozen_string_literal: true
module
QA
context
'Verify'
do
describe
'Secret variable support'
do
it
'user adds a secret variable'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Factory
::
Resource
::
SecretVariable
.
fabricate!
do
|
resource
|
resource
.
key
=
'VARIABLE_KEY'
resource
.
value
=
'some secret variable'
end
Page
::
Project
::
Settings
::
CICD
.
perform
do
|
settings
|
settings
.
expand_secret_variables
do
|
page
|
expect
(
page
).
to
have_field
(
with:
'VARIABLE_KEY'
)
expect
(
page
).
not_to
have_field
(
with:
'some secret variable'
)
page
.
reveal_variables
expect
(
page
).
to
have_field
(
with:
'some secret variable'
)
end
end
end
end
end
end
Prev
1
2
Next
Write
Preview
Supports
Markdown
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