Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ui-middleware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
OX App Suite
Core
ui-middleware
Commits
4a45145b
Commit
4a45145b
authored
3 years ago
by
richard.petersen
Browse files
Options
Downloads
Patches
Plain Diff
Introduce metadata from ui-containers and manifest-service container
parent
5f220230
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitlab-ci.yml
+7
-0
7 additions, 0 deletions
.gitlab-ci.yml
Dockerfile
+7
-0
7 additions, 0 deletions
Dockerfile
spec/meta_test.js
+80
-0
80 additions, 0 deletions
spec/meta_test.js
src/createApp.js
+9
-0
9 additions, 0 deletions
src/createApp.js
src/meta.js
+24
-0
24 additions, 0 deletions
src/meta.js
with
127 additions
and
0 deletions
.gitlab-ci.yml
+
7
−
0
View file @
4a45145b
...
...
@@ -5,6 +5,13 @@ include:
variables
:
INGRESS_HOSTNAME
:
manifest-$CI_COMMIT_REF_SLUG
build image
:
before_script
:
-
"
[
-z
\"
$APP_VERSION
\"
]
&&
export
APP_VERSION=$CI_COMMIT_TAG"
-
"
[
-z
\"
$APP_VERSION
\"
]
&&
export
APP_VERSION=$(cat
package.json
|
grep
'version'
|
cut
-f
4
-d'
\"
')"
-
echo "Building version $APP_VERSION"
extends
:
.build image
deploy helm chart
:
extends
:
.auto-deploy-helm-chart
environment
:
...
...
This diff is collapsed.
Click to expand it.
Dockerfile
+
7
−
0
View file @
4a45145b
FROM
node:17-alpine
LABEL
maintainer="ui-team@open-xchange.com"
ARG
APP_VERSION
ARG
BUILD_TIMESTAMP
ARG
CI_COMMIT_SHA
ENV
APP_VERSION=$APP_VERSION
ENV
BUILD_TIMESTAMP=$BUILD_TIMESTAMP
ENV
CI_COMMIT_SHA=$CI_COMMIT_SHA
WORKDIR
/app
ADD
. /app
RUN
yarn
--production
--non-interactive
--no-progress
-s
...
...
This diff is collapsed.
Click to expand it.
spec/meta_test.js
0 → 100644
+
80
−
0
View file @
4a45145b
import
{
describe
,
it
,
expect
,
beforeAll
,
afterAll
,
beforeEach
,
afterEach
}
from
'
@jest/globals
'
import
mockfs
from
'
mock-fs
'
import
request
from
'
supertest
'
import
{
createApp
}
from
'
../src/createApp
'
import
{
createMockServer
,
generateSimpleViteManifest
,
getRandomPort
}
from
'
./util.js
'
describe
(
'
Responses contain custom headers
'
,
()
=>
{
let
app
let
mockserver
const
port
=
getRandomPort
()
beforeAll
(()
=>
{
mockfs
({
'
./config/manifests
'
:
{
'
urls.yaml
'
:
`manifests:
- http://localhost:
${
port
}
/manifest.json`
}
})
app
=
createApp
()
})
afterAll
(()
=>
{
mockfs
.
restore
()
})
beforeEach
(
async
()
=>
{
mockserver
=
await
createMockServer
({
port
})
mockserver
.
respondWith
({
'
/manifest.json
'
:
generateSimpleViteManifest
({
'
example.js
'
:
{}
}),
'
/example.js
'
:
(
req
,
res
)
=>
res
.
setHeader
(
'
content-type
'
,
'
application/javascript
'
).
status
(
200
).
send
(
'
this is example
'
),
'
/meta.json
'
:
{
name
:
'
sample-service
'
,
version
:
'
1.0
'
}
})
await
request
(
app
).
get
(
'
/ready
'
)
})
afterEach
(()
=>
{
mockserver
.
close
()
delete
process
.
env
.
APP_VERSION
delete
process
.
env
.
BUILD_TIMESTAMP
delete
process
.
env
.
CI_COMMIT_SHA
})
it
(
'
has own metadata
'
,
async
()
=>
{
process
.
env
.
APP_VERSION
=
'
4.2
'
process
.
env
.
BUILD_TIMESTAMP
=
'
0123456789
'
process
.
env
.
CI_COMMIT_SHA
=
'
0123456789abcdef
'
const
response
=
await
request
(
app
).
get
(
'
/meta
'
)
expect
(
response
.
statusCode
).
toBe
(
200
)
expect
(
response
.
body
).
toContainEqual
({
id
:
'
manifest-service
'
,
name
:
'
Manifest Service
'
,
buildDate
:
'
0123456789
'
,
commitSha
:
'
0123456789abcdef
'
,
version
:
'
4.2
'
})
})
it
(
'
has metadata from another ui service if available
'
,
async
()
=>
{
const
response
=
await
request
(
app
).
get
(
'
/meta
'
)
expect
(
response
.
statusCode
).
toBe
(
200
)
expect
(
response
.
body
).
toContainEqual
({
name
:
'
sample-service
'
,
version
:
'
1.0
'
})
})
it
(
'
does not have metadata from ui service when unavailable
'
,
async
()
=>
{
await
mockserver
.
close
()
const
response
=
await
request
(
app
).
get
(
'
/meta
'
)
expect
(
response
.
statusCode
).
toBe
(
200
)
expect
(
response
.
body
).
not
.
toContain
({
name
:
'
sample-service
'
,
version
:
'
1.0
'
})
})
})
This diff is collapsed.
Click to expand it.
src/createApp.js
+
9
−
0
View file @
4a45145b
...
...
@@ -20,6 +20,7 @@ import yaml from 'js-yaml'
import
fs
from
'
fs
'
import
{
getCSSDependenciesFor
,
getDependencies
,
getOxManifests
,
getVersion
,
loadViteManifests
,
viteManifestToDeps
}
from
'
./manifests.js
'
import
{
fileCache
}
from
'
./files.js
'
import
{
getMergedMetadata
}
from
'
./meta.js
'
const
ignorePaths
=
[
'
/ready
'
,
'
/healthy
'
]
const
swaggerDocument
=
yaml
.
load
(
fs
.
readFileSync
(
'
./src/swagger.yaml
'
,
'
utf8
'
))
...
...
@@ -93,6 +94,14 @@ export function createApp () {
}
})
app
.
get
(
'
/meta
'
,
async
(
req
,
res
,
next
)
=>
{
try
{
res
.
json
(
await
getMergedMetadata
())
}
catch
(
err
)
{
next
(
err
)
}
})
app
.
get
(
'
/
'
,
async
(
req
,
res
,
next
)
=>
{
const
{
'
content-type
'
:
contentType
,
content
}
=
fileCache
.
get
(
'
/index.html
'
)
if
(
content
)
return
res
.
setHeader
(
'
content-type
'
,
contentType
).
status
(
200
).
send
(
content
)
...
...
This diff is collapsed.
Click to expand it.
src/meta.js
0 → 100644
+
24
−
0
View file @
4a45145b
import
{
config
}
from
'
./config.js
'
import
fetch
from
'
node-fetch
'
export
async
function
getMergedMetadata
()
{
const
metadata
=
await
Promise
.
all
(
config
.
urls
.
map
(
async
url
=>
{
const
{
origin
}
=
new
URL
(
url
)
try
{
const
response
=
await
fetch
(
new
URL
(
'
meta.json
'
,
origin
))
if
(
!
response
.
ok
)
return
return
response
.
json
()
}
catch
(
e
)
{
// unhandled
}
}))
metadata
.
push
({
id
:
'
manifest-service
'
,
name
:
'
Manifest Service
'
,
buildDate
:
process
.
env
.
BUILD_TIMESTAMP
,
commitSha
:
process
.
env
.
CI_COMMIT_SHA
,
version
:
process
.
env
.
APP_VERSION
})
// only return when contains data
return
metadata
.
filter
(
Boolean
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment