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
96956d47
Commit
96956d47
authored
May 24, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backend implementation for protected variables
parent
54fe9a1e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
4 deletions
+33
-4
app/models/ci/build.rb
app/models/ci/build.rb
+1
-0
app/models/project.rb
app/models/project.rb
+15
-3
db/migrate/20170524161101_add_protected_to_ci_variables.rb
db/migrate/20170524161101_add_protected_to_ci_variables.rb
+15
-0
db/schema.rb
db/schema.rb
+2
-1
No files found.
app/models/ci/build.rb
View file @
96956d47
...
...
@@ -186,6 +186,7 @@ module Ci
variables
+=
yaml_variables
variables
+=
user_variables
variables
+=
project
.
secret_variables
variables
+=
project
.
protected_variables
if
ProtectedBranch
.
protected?
(
project
,
ref
)
variables
+=
trigger_request
.
user_variables
if
trigger_request
variables
end
...
...
app/models/project.rb
View file @
96956d47
...
...
@@ -1257,9 +1257,15 @@ class Project < ActiveRecord::Base
end
def
secret_variables
variables
.
map
do
|
variable
|
{
key:
variable
.
key
,
value:
variable
.
value
,
public:
false
}
end
filtered_variables
=
variables
.
to_a
.
reject
(
&
:protected?
)
build_variables
(
filtered_variables
)
end
def
protected_variables
filtered_variables
=
variables
.
to_a
.
select
(
&
:protected?
)
build_variables
(
filtered_variables
)
end
def
deployment_variables
...
...
@@ -1412,4 +1418,10 @@ class Project < ActiveRecord::Base
raise
ex
end
def
build_variables
(
filtered_variables
)
filtered_variables
.
map
do
|
variable
|
{
key:
variable
.
key
,
value:
variable
.
value
,
public:
false
}
end
end
end
db/migrate/20170524161101_add_protected_to_ci_variables.rb
0 → 100644
View file @
96956d47
class
AddProtectedToCiVariables
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
(
:ci_variables
,
:protected
,
:boolean
,
default:
false
)
end
def
down
remove_column
(
:ci_variables
,
:protected
)
end
end
db/schema.rb
View file @
96956d47
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2017052
1184006
)
do
ActiveRecord
::
Schema
.
define
(
version:
2017052
4161101
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -355,6 +355,7 @@ ActiveRecord::Schema.define(version: 20170521184006) do
t
.
string
"encrypted_value_salt"
t
.
string
"encrypted_value_iv"
t
.
integer
"project_id"
,
null:
false
t
.
boolean
"protected"
,
default:
false
end
add_index
"ci_variables"
,
[
"project_id"
],
name:
"index_ci_variables_on_project_id"
,
using: :btree
...
...
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