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
46568b57
Commit
46568b57
authored
May 25, 2020
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds additional error check for no deployment
Also rejigs code slightly to be more readable / scannable
parent
7df008a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
15 deletions
+29
-15
app/services/clusters/parse_cluster_applications_artifact_service.rb
...s/clusters/parse_cluster_applications_artifact_service.rb
+13
-14
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb
...sters/parse_cluster_applications_artifact_service_spec.rb
+13
-1
No files found.
app/services/clusters/parse_cluster_applications_artifact_service.rb
View file @
46568b57
...
@@ -18,13 +18,9 @@ module Clusters
...
@@ -18,13 +18,9 @@ module Clusters
raise
ArgumentError
,
'Artifact is not cluster_applications file type'
unless
artifact
&
.
cluster_applications?
raise
ArgumentError
,
'Artifact is not cluster_applications file type'
unless
artifact
&
.
cluster_applications?
unless
artifact
.
file
.
size
<
MAX_ACCEPTABLE_ARTIFACT_SIZE
return
error
(
too_big_error_message
,
:bad_request
)
unless
artifact
.
file
.
size
<
MAX_ACCEPTABLE_ARTIFACT_SIZE
return
error
(
too_big_error_message
,
:bad_request
)
return
error
(
no_deployment_message
,
:bad_request
)
unless
job
.
deployment
end
return
error
(
no_deployment_cluster_message
,
:bad_request
)
unless
cluster
unless
cluster
return
error
(
s_
(
'ClusterIntegration|No deployment cluster found for this job'
))
end
parse!
(
artifact
)
parse!
(
artifact
)
...
@@ -61,7 +57,8 @@ module Clusters
...
@@ -61,7 +57,8 @@ module Clusters
Clusters
::
Cluster
.
transaction
do
Clusters
::
Cluster
.
transaction
do
RELEASE_NAMES
.
each
do
|
release_name
|
RELEASE_NAMES
.
each
do
|
release_name
|
application
=
find_or_build_application
(
release_name
)
application_class
=
Clusters
::
Cluster
::
APPLICATIONS
[
release_name
]
application
=
cluster
.
find_or_build_application
(
application_class
)
release
=
release_by_name
[
release_name
]
release
=
release_by_name
[
release_name
]
...
@@ -80,16 +77,18 @@ module Clusters
...
@@ -80,16 +77,18 @@ module Clusters
end
end
end
end
def
find_or_build_application
(
application_name
)
application_class
=
Clusters
::
Cluster
::
APPLICATIONS
[
application_name
]
cluster
.
find_or_build_application
(
application_class
)
end
def
too_big_error_message
def
too_big_error_message
human_size
=
ActiveSupport
::
NumberHelper
.
number_to_human_size
(
MAX_ACCEPTABLE_ARTIFACT_SIZE
)
human_size
=
ActiveSupport
::
NumberHelper
.
number_to_human_size
(
MAX_ACCEPTABLE_ARTIFACT_SIZE
)
s_
(
'ClusterIntegration|Cluster_applications artifact too big. Maximum allowable size: %{human_size}'
)
%
{
human_size:
human_size
}
s_
(
'ClusterIntegration|Cluster_applications artifact too big. Maximum allowable size: %{human_size}'
)
%
{
human_size:
human_size
}
end
end
def
no_deployment_message
s_
(
'ClusterIntegration|No deployment found for this job'
)
end
def
no_deployment_cluster_message
s_
(
'ClusterIntegration|No deployment cluster found for this job'
)
end
end
end
end
end
locale/gitlab.pot
View file @
46568b57
...
@@ -4974,6 +4974,9 @@ msgstr ""
...
@@ -4974,6 +4974,9 @@ msgstr ""
msgid "ClusterIntegration|No deployment cluster found for this job"
msgid "ClusterIntegration|No deployment cluster found for this job"
msgstr ""
msgstr ""
msgid "ClusterIntegration|No deployment found for this job"
msgstr ""
msgid "ClusterIntegration|No instance type found"
msgid "ClusterIntegration|No instance type found"
msgstr ""
msgstr ""
...
...
spec/services/clusters/parse_cluster_applications_artifact_service_spec.rb
View file @
46568b57
...
@@ -85,9 +85,21 @@ describe Clusters::ParseClusterApplicationsArtifactService do
...
@@ -85,9 +85,21 @@ describe Clusters::ParseClusterApplicationsArtifactService do
end
end
end
end
context
'job has no deployment
cluster
'
do
context
'job has no deployment'
do
let
(
:job
)
{
build
(
:ci_build
)
}
let
(
:job
)
{
build
(
:ci_build
)
}
it
'returns an error'
do
result
=
described_class
.
new
(
job
,
user
).
execute
(
artifact
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
'No deployment found for this job'
)
end
end
context
'job has no deployment cluster'
do
let
(
:deployment
)
{
create
(
:deployment
)
}
let
(
:job
)
{
deployment
.
deployable
}
it
'returns an error'
do
it
'returns an error'
do
result
=
described_class
.
new
(
job
,
user
).
execute
(
artifact
)
result
=
described_class
.
new
(
job
,
user
).
execute
(
artifact
)
...
...
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