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
79ee324c
Commit
79ee324c
authored
Feb 06, 2020
by
Kirstie Cook
Committed by
James Lopez
Feb 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create an environment for self monitoring project
parent
5f6d1b6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
0 deletions
+39
-0
changelogs/unreleased/self-monitoring-env.yml
changelogs/unreleased/self-monitoring-env.yml
+5
-0
lib/gitlab/database_importers/self_monitoring/project/create_service.rb
...abase_importers/self_monitoring/project/create_service.rb
+12
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb
..._importers/self_monitoring/project/create_service_spec.rb
+19
-0
No files found.
changelogs/unreleased/self-monitoring-env.yml
0 → 100644
View file @
79ee324c
---
title
:
Create an environment for self monitoring project
merge_request
:
24403
author
:
type
:
added
lib/gitlab/database_importers/self_monitoring/project/create_service.rb
View file @
79ee324c
...
...
@@ -15,6 +15,7 @@ module Gitlab
:create_group
,
:create_project
,
:save_project_id
,
:create_environment
,
:add_prometheus_manual_configuration
,
:track_event
...
...
@@ -80,6 +81,17 @@ module Gitlab
end
end
def
create_environment
(
result
)
environment
=
::
Environment
.
new
(
project_id:
result
[
:project
].
id
,
name:
'production'
)
if
environment
.
save
success
(
result
)
else
log_error
(
"Could not create environment for the Self monitoring project. Errors: %{errors}"
%
{
errors:
environment
.
errors
.
full_messages
})
error
(
_
(
'Could not create environment'
))
end
end
def
add_prometheus_manual_configuration
(
result
)
return
success
(
result
)
unless
prometheus_enabled?
return
success
(
result
)
unless
prometheus_listen_address
.
present?
...
...
locale/gitlab.pot
View file @
79ee324c
...
...
@@ -5379,6 +5379,9 @@ msgstr ""
msgid "Could not create Wiki Repository at this time. Please try again later."
msgstr ""
msgid "Could not create environment"
msgstr ""
msgid "Could not create group"
msgstr ""
...
...
spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb
View file @
79ee324c
...
...
@@ -125,6 +125,25 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do
expect
(
application_setting
.
self_monitoring_project_id
).
to
eq
(
project
.
id
)
end
it
'creates an environment for the project'
do
expect
(
project
.
default_environment
.
name
).
to
eq
(
'production'
)
end
context
'when the environment creation fails'
do
let
(
:environment
)
{
build
(
:environment
,
name:
'production'
)
}
it
'returns error'
do
allow
(
Environment
).
to
receive
(
:new
).
and_return
(
environment
)
allow
(
environment
).
to
receive
(
:save
).
and_return
(
false
)
expect
(
result
).
to
eq
(
status: :error
,
message:
'Could not create environment'
,
last_step: :create_environment
)
end
end
it
'returns error when saving project ID fails'
do
allow
(
application_setting
).
to
receive
(
:update
).
and_call_original
allow
(
application_setting
).
to
receive
(
:update
)
...
...
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