Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
csbase-dev
sgarest-daemon
Commits
4d04b14c
Commit
4d04b14c
authored
5 years ago
by
Carla Goncalves Ourofino
Browse files
Options
Download
Patches
Plain Diff
Alteração para permitir arquivo .cfg com múlltiplas configurações de sga.
[SOMA-3827][SOMA-4041]
parent
0297af77
master
maia/4208/FixInvalidPropTestInCiCd
maia/9022/SgaCygwinInstall
maia/9564/DisableKubernetesDeploy
newfeature/SOMA-3699_IdentificarVersaoSGA
newfeature/SOMA-4444_AddSgaToK8s
1.7.9
1.7.8
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sga/configuration.lua
+34
-4
sga/configuration.lua
with
34 additions
and
4 deletions
+34
-4
sga/configuration.lua
+
34
−
4
View file @
4d04b14c
...
...
@@ -4,27 +4,57 @@ local configuration = {}
local
safer
=
require
(
"safer"
)
local
schema
=
require
(
"schema"
)
function
configuration
.
read
(
filename
)
function
configuration
.
read
(
filename
,
sga_name
)
local
config_fd
=
io.open
(
filename
,
"r"
)
if
not
config_fd
then
return
nil
,
"Could not read config file "
..
filename
end
local
config_data
=
config_fd
:
read
(
"*a"
)
config_fd
:
close
()
local
config
,
err
=
{}
config
.
sga
=
{}
config
,
err
=
configuration
.
get
(
config_data
,
filename
,
config
)
if
not
config
then
return
nil
,
err
end
local
is_multiple
=
config
.
sga
and
next
(
config
.
sga
)
if
is_multiple
then
if
not
sga_name
then
return
nil
,
"Failed getting config from file "
..
filename
..
": missing sga_name argument"
end
if
config
.
sga_name
then
-- TODO: O que fazer nesse caso? Avisar que foi ignorado?
config
.
sga_name
=
nil
end
config
,
err
=
configuration
.
get
(
config
.
sga
[
sga_name
],
filename
,
config
)
if
not
config
then
return
nil
,
"["
..
sga_name
..
"] "
..
err
end
-- TODO: O que fazer se sga_name tiver diferente na configuração? Erro?
config
.
sga_name
=
config
.
sga_name
or
sga_name
end
local
config
=
{}
config
=
safer
.
readonly
(
config
)
return
config
end
function
configuration
.
get
(
config_data
,
filename
,
config
)
local
config
=
config
or
{}
local
chunk
,
err
=
load
(
config_data
,
filename
,
"t"
,
config
)
if
not
chunk
then
return
nil
,
"Failed loading config file "
..
filename
..
": "
..
err
end
config
.
os
=
{
getenv
=
os.getenv
}
config
.
tonumber
=
tonumber
local
ok
,
err
=
pcall
(
chunk
)
config
.
os
=
nil
if
not
ok
then
return
nil
,
"Failed processing config file "
..
filename
..
": "
..
err
end
config
=
safer
.
readonly
(
config
)
return
config
end
...
...
@@ -51,7 +81,7 @@ function configuration.check(config)
}
local
err
=
schema
.
CheckSchema
(
config
,
config_schema
)
if
err
then
io.stderr
:
write
(
"Configuration error: "
..
tostring
(
err
)
..
"
\n
"
)
io.stderr
:
write
(
"
["
..
config
.
sga_name
..
"]
Configuration error: "
..
tostring
(
err
)
..
"
\n
"
)
os.exit
(
1
)
end
end
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets