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
aa44c745
Commit
aa44c745
authored
Jan 10, 2019
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CI/CD bridge configuration entry
parent
dbae2561
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
0 deletions
+131
-0
ee/lib/ee/gitlab/ci/config/entry/bridge.rb
ee/lib/ee/gitlab/ci/config/entry/bridge.rb
+44
-0
ee/spec/lib/ee/gitlab/ci/config/entry/bridge_spec.rb
ee/spec/lib/ee/gitlab/ci/config/entry/bridge_spec.rb
+87
-0
No files found.
ee/lib/ee/gitlab/ci/config/entry/bridge.rb
0 → 100644
View file @
aa44c745
# frozen_string_literal: true
module
EE
module
Gitlab
module
Ci
module
Config
module
Entry
##
# Entry that represents a CI/CD Bridge job that is responsible for
# defining a downstream project trigger.
#
class
Bridge
<
::
Gitlab
::
Config
::
Entry
::
Node
include
::
Gitlab
::
Config
::
Entry
::
Configurable
include
::
Gitlab
::
Config
::
Entry
::
Attributable
ALLOWED_KEYS
=
%i[trigger]
.
freeze
validations
do
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
presence:
true
validates
:trigger
,
presence:
true
validates
:name
,
presence:
true
validates
:name
,
type:
Symbol
end
entry
:trigger
,
::
EE
::
Gitlab
::
Ci
::
Config
::
Entry
::
Trigger
,
description:
'CI/CD Bridge downstream trigger definition.'
helpers
:trigger
attributes
ALLOWED_KEYS
def
name
@metadata
[
:name
]
end
def
value
{
name:
name
,
trigger:
trigger_value
}
end
end
end
end
end
end
end
ee/spec/lib/ee/gitlab/ci/config/entry/bridge_spec.rb
0 → 100644
View file @
aa44c745
require
'fast_spec_helper'
require_dependency
'active_model'
describe
EE
::
Gitlab
::
Ci
::
Config
::
Entry
::
Bridge
do
subject
{
described_class
.
new
(
config
,
name: :my_trigger
)
}
before
do
subject
.
compose!
end
context
'when trigger config is a non-empty string'
do
let
(
:config
)
{
{
trigger:
'some/project'
}
}
describe
'#valid?'
do
it
{
is_expected
.
to
be_valid
}
end
describe
'#value'
do
it
'is returns a bridge job configuration'
do
expect
(
subject
.
value
).
to
eq
(
name: :my_trigger
,
trigger:
{
project:
'some/project'
})
end
end
end
context
'when bridge trigger is a hash'
do
let
(
:config
)
do
{
trigger:
{
project:
'some/project'
,
branch:
'feature'
}
}
end
describe
'#valid?'
do
it
{
is_expected
.
to
be_valid
}
end
describe
'#value'
do
it
'is returns a bridge job configuration hash'
do
expect
(
subject
.
value
).
to
eq
(
name: :my_trigger
,
trigger:
{
project:
'some/project'
,
branch:
'feature'
})
end
end
end
context
'when trigger config is nil'
do
let
(
:config
)
{
{
trigger:
nil
}
}
describe
'#valid?'
do
it
{
is_expected
.
not_to
be_valid
}
end
describe
'#errors'
do
it
'is returns an error about empty trigger config'
do
expect
(
subject
.
errors
.
first
).
to
match
/can't be blank/
end
end
end
context
'when bridge config contains unknown keys'
do
let
(
:config
)
{
{
unknown:
123
}
}
describe
'#valid?'
do
it
{
is_expected
.
not_to
be_valid
}
end
describe
'#errors'
do
it
'is returns an error about unknown config key'
do
expect
(
subject
.
errors
.
first
)
.
to
match
/config contains unknown keys: unknown/
end
end
end
context
'when bridge configuration is not valid'
do
let
(
:config
)
{
{
script:
'something'
}
}
describe
'#valid?'
do
it
{
is_expected
.
not_to
be_valid
}
end
describe
'#errors'
do
it
'returns an error message'
do
expect
(
subject
.
errors
.
first
)
.
to
match
/contains unknown keys: script/
end
end
end
end
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