Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
ffbs-gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
darkbit
ffbs-gluon
Commits
1a7d93a2
Unverified
Commit
1a7d93a2
authored
7 years ago
by
Matthias Schiffer
Browse files
Options
Downloads
Patches
Plain Diff
scripts/check_site.lua: add support for alternative checks
parent
91912f49
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/check_site.lua
+36
-15
36 additions, 15 deletions
scripts/check_site.lua
with
36 additions
and
15 deletions
scripts/check_site.lua
+
36
−
15
View file @
1a7d93a2
local
cjson
=
require
'cjson'
local
function
exit_error
(
src
,
...
)
io.stderr
:
write
(
string.format
(
'*** %s error: %s\n'
,
src
,
string.format
(
...
)))
os.exit
(
1
)
local
function
config_error
(
src
,
...
)
error
(
src
..
' error: '
..
string.format
(
...
),
0
)
end
...
...
@@ -27,7 +26,7 @@ local function get_domains()
dirs
:
close
()
if
not
next
(
domains
)
then
exit
_error
(
'site'
,
'no domain configurations found'
)
config
_error
(
'site'
,
'no domain configurations found'
)
end
return
domains
...
...
@@ -101,13 +100,13 @@ local function var_error(path, val, msg)
src
=
site_src
()
end
exit
_error
(
src
,
'expected %s to %s, but it is %s'
,
path_to_string
(
path
),
msg
,
tostring
(
val
))
config
_error
(
src
,
'expected %s to %s, but it is %s'
,
path_to_string
(
path
),
msg
,
tostring
(
val
))
end
function
in_site
(
path
)
if
has_domains
and
loadpath
(
nil
,
domain
,
unpack
(
path
))
~=
nil
then
exit
_error
(
domain_src
(),
'%s is allowed in site configuration only'
,
path_to_string
(
path
))
config
_error
(
domain_src
(),
'%s is allowed in site configuration only'
,
path_to_string
(
path
))
end
return
path
...
...
@@ -115,7 +114,7 @@ end
function
in_domain
(
path
)
if
has_domains
and
loadpath
(
nil
,
site
,
unpack
(
path
))
~=
nil
then
exit
_error
(
site_src
(),
'%s is allowed in domain configuration only'
,
path_to_string
(
path
))
config
_error
(
site_src
(),
'%s is allowed in domain configuration only'
,
path_to_string
(
path
))
end
return
path
...
...
@@ -174,6 +173,21 @@ local function check_one_of(array)
end
end
function
alternatives
(
...
)
local
errs
=
{
'All of the following alternatives have failed:'
}
for
i
,
f
in
ipairs
({
...
})
do
local
ok
,
err
=
pcall
(
f
)
if
ok
then
return
end
errs
[
#
errs
+
1
]
=
string.format
(
'%i) %s'
,
i
,
err
)
end
error
(
table.concat
(
errs
,
'
\n
'
),
0
)
end
function
need
(
path
,
check
,
required
,
msg
)
local
val
=
loadvar
(
path
)
if
required
==
false
and
val
==
nil
then
...
...
@@ -283,14 +297,21 @@ local check = assert(loadfile())
site
=
load_json
(
os.getenv
(
'IPKG_INSTROOT'
)
..
'/lib/gluon/site.json'
)
if
has_domains
then
for
k
,
v
in
pairs
(
get_domains
())
do
domain_code
=
k
domain
=
v
conf
=
merge
(
site
,
domain
)
local
ok
,
err
=
pcall
(
function
()
if
has_domains
then
for
k
,
v
in
pairs
(
get_domains
())
do
domain_code
=
k
domain
=
v
conf
=
merge
(
site
,
domain
)
check
()
end
else
conf
=
site
check
()
end
else
conf
=
site
check
()
end
)
if
not
ok
then
io.stderr
:
write
(
'*** '
,
err
,
'
\n
'
)
os.exit
(
1
)
end
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