Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFS Gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
firmware
FFS Gluon
Commits
abd6d641
Commit
abd6d641
authored
2 years ago
by
lemoer
Browse files
Options
Downloads
Patches
Plain Diff
gluon-core: make interface roles exclusive in site config
parent
e7da5014
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.luacheckrc
+1
-0
1 addition, 0 deletions
.luacheckrc
package/gluon-core/check_site.lua
+5
-1
5 additions, 1 deletion
package/gluon-core/check_site.lua
package/gluon-core/luasrc/lib/gluon/check-site.lua
+23
-0
23 additions, 0 deletions
package/gluon-core/luasrc/lib/gluon/check-site.lua
with
29 additions
and
1 deletion
.luacheckrc
+
1
−
0
View file @
abd6d641
...
@@ -29,6 +29,7 @@ files["package/**/check_site.lua"] = {
...
@@ -29,6 +29,7 @@ files["package/**/check_site.lua"] = {
"need",
"need",
"need_alphanumeric_key",
"need_alphanumeric_key",
"need_array",
"need_array",
"need_array_elements_exclusive",
"need_array_of",
"need_array_of",
"need_boolean",
"need_boolean",
"need_chanlist",
"need_chanlist",
...
...
This diff is collapsed.
Click to expand it.
package/gluon-core/check_site.lua
+
5
−
1
View file @
abd6d641
...
@@ -77,7 +77,11 @@ need_boolean(in_domain({'mesh', 'vxlan'}), false)
...
@@ -77,7 +77,11 @@ need_boolean(in_domain({'mesh', 'vxlan'}), false)
local
interfaces_roles
=
{
'client'
,
'uplink'
,
'mesh'
}
local
interfaces_roles
=
{
'client'
,
'uplink'
,
'mesh'
}
for
_
,
config
in
ipairs
({
'wan'
,
'lan'
,
'single'
})
do
for
_
,
config
in
ipairs
({
'wan'
,
'lan'
,
'single'
})
do
need_array_of
(
in_site
({
'interfaces'
,
config
,
'default_roles'
}),
interfaces_roles
,
false
)
local
default_roles
=
in_site
({
'interfaces'
,
config
,
'default_roles'
})
need_array_of
(
default_roles
,
interfaces_roles
,
false
)
need_array_elements_exclusive
(
default_roles
,
'client'
,
'mesh'
,
false
)
need_array_elements_exclusive
(
default_roles
,
'client'
,
'uplink'
,
false
)
end
end
obsolete
({
'mesh_on_wan'
},
'Use interfaces.wan.default_roles.'
)
obsolete
({
'mesh_on_wan'
},
'Use interfaces.wan.default_roles.'
)
...
...
This diff is collapsed.
Click to expand it.
package/gluon-core/luasrc/lib/gluon/check-site.lua
+
23
−
0
View file @
abd6d641
...
@@ -55,6 +55,14 @@ local function merge(a, b)
...
@@ -55,6 +55,14 @@ local function merge(a, b)
return
m
return
m
end
end
local
function
contains
(
table
,
val
)
for
i
=
1
,
#
table
do
if
table
[
i
]
==
val
then
return
true
end
end
return
false
end
local
function
path_to_string
(
path
)
local
function
path_to_string
(
path
)
if
path
.
is_value
then
if
path
.
is_value
then
...
@@ -370,6 +378,21 @@ function M.need_array_of(path, array, required)
...
@@ -370,6 +378,21 @@ function M.need_array_of(path, array, required)
return
M
.
need_array
(
path
,
function
(
e
)
M
.
need_one_of
(
e
,
array
)
end
,
required
)
return
M
.
need_array
(
path
,
function
(
e
)
M
.
need_one_of
(
e
,
array
)
end
,
required
)
end
end
function
M
.
need_array_elements_exclusive
(
path
,
a
,
b
,
required
)
local
val
=
need_type
(
path
,
'table'
,
required
,
'be an array'
)
if
not
val
then
return
nil
end
if
contains
(
val
,
a
)
and
contains
(
val
,
b
)
then
config_error
(
conf_src
(
path
),
'expected %s to contain only one of the elements %s and %s, but not both.'
,
path_to_string
(
path
),
format
(
a
),
format
(
b
))
end
return
val
end
function
M
.
need_chanlist
(
path
,
channels
,
required
)
function
M
.
need_chanlist
(
path
,
channels
,
required
)
local
valid_chanlist
=
check_chanlist
(
channels
)
local
valid_chanlist
=
check_chanlist
(
channels
)
return
M
.
need
(
path
,
valid_chanlist
,
required
,
return
M
.
need
(
path
,
valid_chanlist
,
required
,
...
...
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