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
02df78db
Commit
02df78db
authored
Mar 18, 2020
by
Fabio Pitino
Committed by
Grzegorz Bizon
Mar 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move HasVariable concern to CI namespace
HasVariable concern is only used by CI variable classes
parent
521663ea
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
60 additions
and
56 deletions
+60
-56
app/models/ci/group_variable.rb
app/models/ci/group_variable.rb
+1
-1
app/models/ci/job_variable.rb
app/models/ci/job_variable.rb
+1
-1
app/models/ci/pipeline_schedule_variable.rb
app/models/ci/pipeline_schedule_variable.rb
+1
-1
app/models/ci/pipeline_variable.rb
app/models/ci/pipeline_variable.rb
+1
-1
app/models/ci/variable.rb
app/models/ci/variable.rb
+1
-1
app/models/concerns/ci/has_variable.rb
app/models/concerns/ci/has_variable.rb
+36
-0
app/models/concerns/ci/new_has_variable.rb
app/models/concerns/ci/new_has_variable.rb
+16
-0
app/models/concerns/has_variable.rb
app/models/concerns/has_variable.rb
+0
-34
app/models/concerns/new_has_variable.rb
app/models/concerns/new_has_variable.rb
+0
-14
lib/gitlab/ci/variables/collection/item.rb
lib/gitlab/ci/variables/collection/item.rb
+1
-1
spec/models/concerns/ci/has_variable_spec.rb
spec/models/concerns/ci/has_variable_spec.rb
+1
-1
spec/support/shared_examples/models/ci_variable_shared_examples.rb
...ort/shared_examples/models/ci_variable_shared_examples.rb
+1
-1
No files found.
app/models/ci/group_variable.rb
View file @
02df78db
...
...
@@ -3,7 +3,7 @@
module
Ci
class
GroupVariable
<
ApplicationRecord
extend
Gitlab
::
Ci
::
Model
include
HasVariable
include
Ci
::
HasVariable
include
Presentable
include
Maskable
...
...
app/models/ci/job_variable.rb
View file @
02df78db
...
...
@@ -3,7 +3,7 @@
module
Ci
class
JobVariable
<
ApplicationRecord
extend
Gitlab
::
Ci
::
Model
include
NewHasVariable
include
Ci
::
NewHasVariable
include
BulkInsertSafe
belongs_to
:job
,
class_name:
"Ci::Build"
,
foreign_key: :job_id
...
...
app/models/ci/pipeline_schedule_variable.rb
View file @
02df78db
...
...
@@ -3,7 +3,7 @@
module
Ci
class
PipelineScheduleVariable
<
ApplicationRecord
extend
Gitlab
::
Ci
::
Model
include
HasVariable
include
Ci
::
HasVariable
belongs_to
:pipeline_schedule
...
...
app/models/ci/pipeline_variable.rb
View file @
02df78db
...
...
@@ -3,7 +3,7 @@
module
Ci
class
PipelineVariable
<
ApplicationRecord
extend
Gitlab
::
Ci
::
Model
include
HasVariable
include
Ci
::
HasVariable
belongs_to
:pipeline
...
...
app/models/ci/variable.rb
View file @
02df78db
...
...
@@ -3,7 +3,7 @@
module
Ci
class
Variable
<
ApplicationRecord
extend
Gitlab
::
Ci
::
Model
include
HasVariable
include
Ci
::
HasVariable
include
Presentable
include
Maskable
prepend
HasEnvironmentScope
...
...
app/models/concerns/ci/has_variable.rb
0 → 100644
View file @
02df78db
# frozen_string_literal: true
module
Ci
module
HasVariable
extend
ActiveSupport
::
Concern
included
do
enum
variable_type:
{
env_var:
1
,
file:
2
}
validates
:key
,
presence:
true
,
length:
{
maximum:
255
},
format:
{
with:
/\A[a-zA-Z0-9_]+\z/
,
message:
"can contain only letters, digits and '_'."
}
scope
:order_key_asc
,
->
{
reorder
(
key: :asc
)
}
attr_encrypted
:value
,
mode: :per_attribute_iv_and_salt
,
insecure_mode:
true
,
key:
Settings
.
attr_encrypted_db_key_base
,
algorithm:
'aes-256-cbc'
def
key
=
(
new_key
)
super
(
new_key
.
to_s
.
strip
)
end
end
def
to_runner_variable
{
key:
key
,
value:
value
,
public:
false
,
file:
file?
}
end
end
end
app/models/concerns/ci/new_has_variable.rb
0 → 100644
View file @
02df78db
# frozen_string_literal: true
module
Ci
module
NewHasVariable
extend
ActiveSupport
::
Concern
include
Ci
::
HasVariable
included
do
attr_encrypted
:value
,
mode: :per_attribute_iv
,
algorithm:
'aes-256-gcm'
,
key:
Settings
.
attr_encrypted_db_key_base_32
,
insecure_mode:
false
end
end
end
app/models/concerns/has_variable.rb
deleted
100644 → 0
View file @
521663ea
# frozen_string_literal: true
module
HasVariable
extend
ActiveSupport
::
Concern
included
do
enum
variable_type:
{
env_var:
1
,
file:
2
}
validates
:key
,
presence:
true
,
length:
{
maximum:
255
},
format:
{
with:
/\A[a-zA-Z0-9_]+\z/
,
message:
"can contain only letters, digits and '_'."
}
scope
:order_key_asc
,
->
{
reorder
(
key: :asc
)
}
attr_encrypted
:value
,
mode: :per_attribute_iv_and_salt
,
insecure_mode:
true
,
key:
Settings
.
attr_encrypted_db_key_base
,
algorithm:
'aes-256-cbc'
def
key
=
(
new_key
)
super
(
new_key
.
to_s
.
strip
)
end
end
def
to_runner_variable
{
key:
key
,
value:
value
,
public:
false
,
file:
file?
}
end
end
app/models/concerns/new_has_variable.rb
deleted
100644 → 0
View file @
521663ea
# frozen_string_literal: true
module
NewHasVariable
extend
ActiveSupport
::
Concern
include
HasVariable
included
do
attr_encrypted
:value
,
mode: :per_attribute_iv
,
algorithm:
'aes-256-gcm'
,
key:
Settings
.
attr_encrypted_db_key_base_32
,
insecure_mode:
false
end
end
lib/gitlab/ci/variables/collection/item.rb
View file @
02df78db
...
...
@@ -37,7 +37,7 @@ module Gitlab
case
resource
when
Hash
self
.
new
(
resource
.
symbolize_keys
)
when
::
HasVariable
when
::
Ci
::
HasVariable
self
.
new
(
resource
.
to_runner_variable
)
when
self
resource
.
dup
...
...
spec/models/concerns/has_variable_spec.rb
→
spec/models/concerns/
ci/
has_variable_spec.rb
View file @
02df78db
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
describe
HasVariable
do
describe
Ci
::
HasVariable
do
subject
{
build
(
:ci_variable
)
}
it
{
is_expected
.
to
validate_presence_of
(
:key
)
}
...
...
spec/support/shared_examples/models/ci_variable_shared_examples.rb
View file @
02df78db
# frozen_string_literal: true
RSpec
.
shared_examples
'CI variable'
do
it
{
is_expected
.
to
include_module
(
HasVariable
)
}
it
{
is_expected
.
to
include_module
(
Ci
::
HasVariable
)
}
describe
"variable type"
do
it
'defines variable types'
do
...
...
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