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
cd358ee8
Commit
cd358ee8
authored
2 years ago
by
richard.petersen
Committed by
richard.petersen
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add: OXUI-1092 - Add configurable salt to manually invalidate client caches
parent
88f4c8bf
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+10
-0
10 additions, 0 deletions
README.md
spec/salt_test.js
+46
-0
46 additions, 0 deletions
spec/salt_test.js
src/configMap.js
+6
-0
6 additions, 0 deletions
src/configMap.js
src/version.js
+1
-1
1 addition, 1 deletion
src/version.js
with
63 additions
and
1 deletion
README.md
+
10
−
0
View file @
cd358ee8
...
...
@@ -75,6 +75,16 @@ It is possible to horizontally scale the UI Middleware, as more clients are fetc
|
`compressFileSize`
| Larger files will be gzipped |
`600`
|
|
`compressFileTypes`
| Set of compression mime types |see values|
**config map**
```
yaml
# List of urls where to find ui containers
baseUrls
:
-
http://service.namespace.svc.cluster.local/
# optional, when this number is changed, the changes on clients will be invalidated and will reload the ui-sources
salt
:
'
1234'
```
## Ingress
When using Ingress to make the service available to the public, the service is intended to be
...
...
This diff is collapsed.
Click to expand it.
spec/salt_test.js
0 → 100644
+
46
−
0
View file @
cd358ee8
import
request
from
'
supertest
'
import
{
brotliParser
,
generateSimpleViteManifest
,
mockApp
,
mockConfig
,
mockFetch
,
mockRedis
}
from
'
./util.js
'
import
{
expect
}
from
'
chai
'
import
*
as
td
from
'
testdouble
'
import
RedisMock
from
'
ioredis-mock
'
describe
(
'
Salt
'
,
function
()
{
let
app
let
config
beforeEach
(
async
function
()
{
mockConfig
(
config
=
{
baseUrls
:
[
'
http://ui-server/
'
]
})
mockRedis
()
mockFetch
({
'
http://ui-server
'
:
{
'
/manifest.json
'
:
generateSimpleViteManifest
({
'
example.js
'
:
'
test
'
}),
'
/example.js
'
:
''
}
})
app
=
await
mockApp
()
})
afterEach
(
async
function
()
{
td
.
reset
()
await
new
RedisMock
().
flushdb
()
})
it
(
'
change version when salt changes
'
,
async
function
()
{
const
response
=
await
request
(
app
.
server
).
get
(
'
/manifests
'
).
parse
(
brotliParser
)
expect
(
response
.
statusCode
).
to
.
equal
(
200
)
expect
(
response
.
headers
.
version
).
to
.
equal
(
'
1916675216
'
)
// update salt
config
.
salt
=
'
1
'
await
import
(
'
../src/version.js
'
).
then
(
async
({
updateVersionProcessor
})
=>
{
// need to process two times to actually trigger the update
await
updateVersionProcessor
()
await
updateVersionProcessor
()
})
const
responseAfterUpdate
=
await
request
(
app
.
server
).
get
(
'
/manifests
'
).
parse
(
brotliParser
)
expect
(
responseAfterUpdate
.
statusCode
).
to
.
equal
(
200
)
expect
(
responseAfterUpdate
.
headers
.
version
).
to
.
equal
(
'
1916675216-1
'
)
})
})
This diff is collapsed.
Click to expand it.
src/configMap.js
+
6
−
0
View file @
cd358ee8
...
...
@@ -7,12 +7,18 @@ class Config {
const
doc
=
yaml
.
load
(
await
fs
.
readFile
(
'
./config/config.yaml
'
,
'
utf8
'
))
// @ts-ignore
this
.
_urls
=
doc
.
baseUrls
// @ts-ignore
this
.
_salt
=
doc
.
salt
logger
.
debug
(
'
[Config] Config has been loaded
'
)
}
get
urls
()
{
return
this
.
_urls
||
[]
}
get
salt
()
{
return
this
.
_salt
}
}
export
const
configMap
=
new
Config
()
This diff is collapsed.
Click to expand it.
src/version.js
+
1
−
1
View file @
cd358ee8
...
...
@@ -45,7 +45,7 @@ export const fetchLatestVersion = async () => {
logger
.
error
(
`[Version] Cannot fetch manifest from
${
baseUrl
}
. Version info will not be correct.`
)
}
}))
return
hash
(
infos
)
return
`
${
hash
(
infos
)
}${
configMap
.
salt
?
`-
${
configMap
.
salt
}
`
:
''
}
`
}
export
async
function
getLatestVersion
()
{
...
...
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