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
03a7bc50
Commit
03a7bc50
authored
Feb 13, 2020
by
Adrien Kohlbecker
Committed by
Martin Wortschack
Feb 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass logs url from backend to frontend
Instead of computing it manually
parent
1fc8efd1
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
75 additions
and
44 deletions
+75
-44
app/assets/javascripts/clusters/stores/clusters_store.js
app/assets/javascripts/clusters/stores/clusters_store.js
+1
-0
app/assets/javascripts/environments/components/environments_table.vue
...avascripts/environments/components/environments_table.vue
+1
-2
ee/app/assets/javascripts/clusters/components/environments.vue
...p/assets/javascripts/clusters/components/environments.vue
+1
-2
ee/app/assets/javascripts/environments/components/deploy_board_component.vue
...cripts/environments/components/deploy_board_component.vue
+4
-8
ee/app/assets/javascripts/vue_shared/components/deployment_instance.vue
...javascripts/vue_shared/components/deployment_instance.vue
+4
-11
ee/app/helpers/ee/environments_helper.rb
ee/app/helpers/ee/environments_helper.rb
+1
-1
ee/app/serializers/clusters/environment_entity.rb
ee/app/serializers/clusters/environment_entity.rb
+8
-0
ee/app/serializers/ee/environment_entity.rb
ee/app/serializers/ee/environment_entity.rb
+4
-0
ee/spec/frontend/clusters/components/mock_data.js
ee/spec/frontend/clusters/components/mock_data.js
+3
-0
ee/spec/frontend/environments/deploy_board_component_spec.js
ee/spec/frontend/environments/deploy_board_component_spec.js
+5
-9
ee/spec/frontend/environments/environments_table_spec.js
ee/spec/frontend/environments/environments_table_spec.js
+1
-1
ee/spec/frontend/vue_shared/components/deployment_instance/deployment_instance_spec.js
...omponents/deployment_instance/deployment_instance_spec.js
+4
-5
ee/spec/frontend/vue_shared/components/deployment_instance/mock_data.js
...nd/vue_shared/components/deployment_instance/mock_data.js
+1
-1
ee/spec/helpers/ee/environments_helper_spec.rb
ee/spec/helpers/ee/environments_helper_spec.rb
+1
-1
ee/spec/serializers/clusters/environment_entity_spec.rb
ee/spec/serializers/clusters/environment_entity_spec.rb
+20
-3
ee/spec/serializers/environment_entity_spec.rb
ee/spec/serializers/environment_entity_spec.rb
+16
-0
No files found.
app/assets/javascripts/clusters/stores/clusters_store.js
View file @
03a7bc50
...
...
@@ -257,6 +257,7 @@ export default class ClusterStore {
name
:
environment
.
name
,
project
:
environment
.
project
,
environmentPath
:
environment
.
environment_path
,
logsPath
:
environment
.
logs_path
,
lastDeployment
:
environment
.
last_deployment
,
rolloutStatus
:
{
status
:
environment
.
rollout_status
?
environment
.
rollout_status
.
status
:
null
,
...
...
app/assets/javascripts/environments/components/environments_table.vue
View file @
03a7bc50
...
...
@@ -162,8 +162,7 @@ export default {
:is-loading=
"model.isLoadingDeployBoard"
:is-empty=
"model.isEmptyDeployBoard"
:has-legacy-app-label=
"model.hasLegacyAppLabel"
:project-path=
"model.project_path"
:environment-name=
"model.name"
:logs-path=
"model.logs_path"
/>
</div>
</div>
...
...
ee/app/assets/javascripts/clusters/components/environments.vue
View file @
03a7bc50
...
...
@@ -142,8 +142,7 @@ export default {
:tooltip-text=
"instance.tooltip"
:pod-name=
"instance.pod_name"
:stable=
"instance.stable"
:project-path=
"`/$
{row.item.project.path_with_namespace}`"
:environment-name="row.item.name"
:logs-path=
"row.item.logsPath"
/>
</
template
>
</div>
...
...
ee/app/assets/javascripts/environments/components/deploy_board_component.vue
View file @
03a7bc50
...
...
@@ -42,13 +42,10 @@ export default {
type
:
Boolean
,
required
:
true
,
},
environmentName
:
{
logsPath
:
{
type
:
String
,
required
:
true
,
},
projectPath
:
{
type
:
String
,
required
:
true
,
required
:
false
,
default
:
''
,
},
hasLegacyAppLabel
:
{
type
:
Boolean
,
...
...
@@ -143,9 +140,8 @@ export default {
:key=
"i"
:status=
"instance.status"
:tooltip-text=
"instance.tooltip"
:environment-name=
"environmentName"
:pod-name=
"instance.pod_name"
:
project-path=
"project
Path"
:
logs-path=
"logs
Path"
:stable=
"instance.stable"
/>
</
template
>
...
...
ee/app/assets/javascripts/vue_shared/components/deployment_instance.vue
View file @
03a7bc50
...
...
@@ -13,6 +13,7 @@
* Mockup is https://gitlab.com/gitlab-org/gitlab/issues/35570
*/
import
{
GlLink
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
mergeUrlParams
}
from
'
~/lib/utils/url_utility
'
;
export
default
{
components
:
{
...
...
@@ -47,19 +48,13 @@ export default {
default
:
true
,
},
environmentName
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
podName
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
project
Path
:
{
logs
Path
:
{
type
:
String
,
required
:
false
,
default
:
''
,
...
...
@@ -68,7 +63,7 @@ export default {
computed
:
{
isLink
()
{
return
Boolean
(
this
.
logsPath
||
this
.
podName
)
;
return
this
.
logsPath
!==
''
&&
this
.
podName
!==
''
;
},
cssClass
()
{
...
...
@@ -80,9 +75,7 @@ export default {
},
computedLogPath
()
{
return
this
.
isLink
?
`
${
this
.
projectPath
}
/-/logs?environment_name=
${
this
.
environmentName
}
&pod_name=
${
this
.
podName
}
`
:
null
;
return
this
.
isLink
?
mergeUrlParams
({
pod_name
:
this
.
podName
},
this
.
logsPath
)
:
null
;
},
},
};
...
...
ee/app/helpers/ee/environments_helper.rb
View file @
03a7bc50
...
...
@@ -46,7 +46,7 @@ module EE
"custom-metrics-available"
=>
"
#{
custom_metrics_available?
(
project
)
}
"
,
"alerts-endpoint"
=>
project_prometheus_alerts_path
(
project
,
environment_id:
environment
.
id
,
format: :json
),
"prometheus-alerts-available"
=>
"
#{
can?
(
current_user
,
:read_prometheus_alerts
,
project
)
}
"
,
"logs-path"
=>
project_logs_path
(
project
)
"logs-path"
=>
project_logs_path
(
project
,
environment_name:
environment
.
name
)
}
super
.
merge
(
ee_metrics_data
)
...
...
ee/app/serializers/clusters/environment_entity.rb
View file @
03a7bc50
...
...
@@ -12,6 +12,10 @@ module Clusters
project_environment_path
(
environment
.
project
,
environment
)
end
expose
:logs_path
,
if:
->
(
*
)
{
can_read_pod_logs?
}
do
|
environment
|
project_logs_path
(
environment
.
project
,
environment_name:
environment
.
name
)
end
expose
:rollout_status
,
if:
->
(
*
)
{
can_read_cluster_deployments?
},
using:
::
RolloutStatusEntity
expose
:updated_at
...
...
@@ -27,5 +31,9 @@ module Clusters
def
can_read_cluster_deployments?
can?
(
current_user
,
:read_cluster_environments
,
request
.
cluster
)
end
def
can_read_pod_logs?
can?
(
current_user
,
:read_pod_logs
,
environment
.
project
)
end
end
end
ee/app/serializers/ee/environment_entity.rb
View file @
03a7bc50
...
...
@@ -12,6 +12,10 @@ module EE
project_path
(
environment
.
project
)
end
expose
:logs_path
,
if:
->
(
*
)
{
can_read_pod_logs?
}
do
|
environment
|
project_logs_path
(
environment
.
project
,
environment_name:
environment
.
name
)
end
expose
:enable_advanced_logs_querying
,
if:
->
(
*
)
{
can_read_pod_logs?
}
do
|
environment
|
environment
.
deployment_platform
&
.
elastic_stack_available?
end
...
...
ee/spec/frontend/clusters/components/mock_data.js
View file @
03a7bc50
export
default
[
{
environmentPath
:
'
some/path
'
,
logsPath
:
'
some/path/logs
'
,
project
:
{
path_with_namespace
:
'
some/path
'
,
name
:
'
some project
'
},
name
:
'
production
'
,
lastDeployment
:
{
id
:
'
123
'
},
...
...
@@ -14,6 +15,7 @@ export default [
},
{
environmentPath
:
'
some/other/path
'
,
logsPath
:
'
some/other/path/logs
'
,
project
:
{
path_with_namespace
:
'
some/other/path
'
,
name
:
'
some other project
'
},
name
:
'
staging
'
,
lastDeployment
:
{
id
:
'
456
'
},
...
...
@@ -25,6 +27,7 @@ export default [
},
{
environmentPath
:
'
yet/another/path
'
,
logsPath
:
'
yet/another/path/logs
'
,
project
:
{
path_with_namespace
:
'
yet/another/path
'
,
name
:
'
yet another project
'
},
name
:
'
development
'
,
lastDeployment
:
{
id
:
'
789
'
},
...
...
ee/spec/frontend/environments/deploy_board_component_spec.js
View file @
03a7bc50
...
...
@@ -3,7 +3,7 @@ import { mount } from '@vue/test-utils';
import
DeployBoard
from
'
ee/environments/components/deploy_board_component.vue
'
;
import
{
deployBoardMockData
,
environment
}
from
'
./mock_data
'
;
const
projectPath
=
'
gitlab-org/gitlab-test
'
;
const
logsPath
=
`gitlab-org/gitlab-test/-/logs?environment_name=
${
environment
.
name
}
`
;
describe
(
'
Deploy Board
'
,
()
=>
{
let
wrapper
;
...
...
@@ -14,8 +14,7 @@ describe('Deploy Board', () => {
deployBoardData
:
deployBoardMockData
,
isLoading
:
false
,
isEmpty
:
false
,
projectPath
,
environmentName
:
environment
.
name
,
logsPath
,
...
props
,
},
});
...
...
@@ -61,8 +60,7 @@ describe('Deploy Board', () => {
deployBoardData
:
{},
isLoading
:
false
,
isEmpty
:
true
,
projectPath
,
environmentName
:
environment
.
name
,
logsPath
,
});
wrapper
.
vm
.
$nextTick
(
done
);
});
...
...
@@ -81,8 +79,7 @@ describe('Deploy Board', () => {
deployBoardData
:
{},
isLoading
:
true
,
isEmpty
:
false
,
projectPath
,
environmentName
:
environment
.
name
,
logsPath
,
});
wrapper
.
vm
.
$nextTick
(
done
);
});
...
...
@@ -97,8 +94,7 @@ describe('Deploy Board', () => {
wrapper
=
createComponent
({
isLoading
:
false
,
isEmpty
:
false
,
projectPath
,
environmentName
:
environment
.
name
,
logsPath
,
hasLegacyAppLabel
:
true
,
deployBoardData
:
{},
});
...
...
ee/spec/frontend/environments/environments_table_spec.js
View file @
03a7bc50
...
...
@@ -49,7 +49,7 @@ describe('Environment table', () => {
name
:
'
review
'
,
size
:
1
,
environment_path
:
'
url
'
,
project
_path
:
'
url
'
,
logs
_path
:
'
url
'
,
id
:
1
,
hasDeployBoard
:
true
,
deployBoardData
:
deployBoardMockData
,
...
...
ee/spec/frontend/vue_shared/components/deployment_instance/deployment_instance_spec.js
View file @
03a7bc50
...
...
@@ -20,7 +20,7 @@ describe('Deploy Board Instance', () => {
it
(
'
should render a div with the correct css status and tooltip data
'
,
()
=>
{
wrapper
=
createComponent
({
projectPath
:
folder
.
project
_path
,
logsPath
:
folder
.
logs
_path
,
tooltipText
:
'
This is a pod
'
,
});
...
...
@@ -43,8 +43,7 @@ describe('Deploy Board Instance', () => {
it
(
'
should have a log path computed with a pod name as a parameter
'
,
()
=>
{
wrapper
=
createComponent
({
projectPath
:
folder
.
project_path
,
environmentName
:
'
foo
'
,
logsPath
:
folder
.
logs_path
,
podName
:
'
tanuki-1
'
,
});
...
...
@@ -76,10 +75,10 @@ describe('Deploy Board Instance', () => {
wrapper
.
destroy
();
});
it
(
'
should not be a link without a
project
Path prop
'
,
done
=>
{
it
(
'
should not be a link without a
logs
Path prop
'
,
done
=>
{
wrapper
=
createComponent
({
stable
:
false
,
project
Path
:
''
,
logs
Path
:
''
,
});
wrapper
.
vm
.
$nextTick
(()
=>
{
...
...
ee/spec/frontend/vue_shared/components/deployment_instance/mock_data.js
View file @
03a7bc50
...
...
@@ -140,5 +140,5 @@ export const folder = {
created_at
:
'
2017-02-01T19:42:18.400Z
'
,
updated_at
:
'
2017-02-01T19:42:18.400Z
'
,
rollout_status
:
{},
project_path
:
'
/root/review-app
'
,
logs_path
:
'
/root/review-app/-/logs?environment_name=foo
'
,
};
ee/spec/helpers/ee/environments_helper_spec.rb
View file @
03a7bc50
...
...
@@ -27,7 +27,7 @@ describe EnvironmentsHelper do
'custom-metrics-available'
=>
'false'
,
'alerts-endpoint'
=>
project_prometheus_alerts_path
(
project
,
environment_id:
environment
.
id
,
format: :json
),
'prometheus-alerts-available'
=>
'true'
,
'logs-path'
=>
project_logs_path
(
project
)
'logs-path'
=>
project_logs_path
(
project
,
environment_name:
environment
.
name
)
)
end
end
...
...
ee/spec/serializers/clusters/environment_entity_spec.rb
View file @
03a7bc50
...
...
@@ -5,7 +5,7 @@ require 'spec_helper'
describe
Clusters
::
EnvironmentEntity
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:project
,
refind:
true
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:cluster
)
{
create
(
:cluster_for_group
,
groups:
[
group
])
}
it
'inherits from API::Entities::EnvironmentBasic'
do
...
...
@@ -16,12 +16,12 @@ describe Clusters::EnvironmentEntity do
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let
(
:request
)
{
double
(
'request'
,
current_user:
user
,
cluster:
cluster
)
}
subject
{
described_class
.
new
(
environment
,
request:
request
).
as_json
}
before
do
group
.
add_maintainer
(
user
)
end
subject
{
described_class
.
new
(
environment
,
request:
request
).
as_json
}
context
'deploy board available'
do
before
do
allow
(
group
).
to
receive
(
:feature_available?
).
and_call_original
...
...
@@ -50,5 +50,22 @@ describe Clusters::EnvironmentEntity do
expect
(
subject
).
not_to
include
(
:rollout_status
)
end
end
context
'when pod_logs are available'
do
before
do
stub_licensed_features
(
pod_logs:
true
)
project
.
add_maintainer
(
user
)
end
it
'exposes logs_path'
do
expect
(
subject
).
to
include
(
:logs_path
)
end
end
context
'when pod_logs are not available'
do
it
'does not expose logs_path'
do
expect
(
subject
).
not_to
include
(
:logs_path
)
end
end
end
end
ee/spec/serializers/environment_entity_spec.rb
View file @
03a7bc50
...
...
@@ -45,5 +45,21 @@ describe EnvironmentEntity do
expect
(
subject
).
not_to
include
(
:rollout_status
)
end
end
context
'when pod_logs are available'
do
before
do
stub_licensed_features
(
pod_logs:
true
)
end
it
'exposes logs_path'
do
expect
(
subject
).
to
include
(
:logs_path
)
end
end
context
'when pod_logs are not available'
do
it
'does not expose logs_path'
do
expect
(
subject
).
not_to
include
(
:logs_path
)
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