Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ophélie Gagnard
slapos.core
Commits
4f5d2411
Commit
4f5d2411
authored
Jul 28, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli/request: support yaml format for --parameters-file option
parent
2e29b436
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
setup.py
setup.py
+1
-0
slapos/cli/request.py
slapos/cli/request.py
+4
-1
slapos/tests/test_cli.py
slapos/tests/test_cli.py
+14
-0
No files found.
setup.py
View file @
4f5d2411
...
...
@@ -75,6 +75,7 @@ setup(name=name,
'cachecontrol'
,
'lockfile'
,
'jsonschema'
,
'PyYAML'
,
'uritemplate'
,
# used by hateoas navigator
'subprocess32; python_version<"3"'
,
'ipaddress; python_version<"3"'
,
# used by whitelistfirewall
...
...
slapos/cli/request.py
View file @
4f5d2411
...
...
@@ -33,6 +33,7 @@ import os.path
import
pprint
import
lxml.etree
import
yaml
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.client
import
(
ClientConfig
,
_getSoftwareReleaseFromSoftwareString
,
...
...
@@ -49,7 +50,9 @@ except ImportError:
def
getParametersFromFile
(
file
,
serialisation
):
# type: (IO[str], SoftwareReleaseSerialisation) -> Dict
extension
=
os
.
path
.
splitext
(
file
.
name
)[
1
]
if
extension
==
'.xml'
:
if
extension
in
(
'.yaml'
,
'.yml'
):
params
=
yaml
.
safe_load
(
file
)
elif
extension
==
'.xml'
:
tree
=
lxml
.
etree
.
parse
(
file
)
params
=
{
e
.
attrib
[
'id'
]:
e
.
text
for
e
in
tree
.
findall
(
'/parameter'
)}
# because the use case of xml files is to copy paste existing XML parameters
...
...
slapos/tests/test_cli.py
View file @
4f5d2411
...
...
@@ -785,6 +785,20 @@ class TestCliRequestParametersFileJsonJsonInXMLSerialisationAlreadySerialised(
self
).
test_request_parameters_file
()
class
TestCliRequestParametersFileYaml
(
TestCliRequestParametersFileJson
):
"""Request with --parameter-file, with a .yaml file. This behaves like json.
"""
def
_makeParameterFile
(
self
):
f
=
tempfile
.
NamedTemporaryFile
(
suffix
=
'.yaml'
,
mode
=
'w'
,
delete
=
False
)
self
.
addCleanup
(
os
.
unlink
,
f
.
name
)
f
.
write
(
textwrap
.
dedent
(
'''
\
foo:
- bar
'''
))
f
.
flush
()
return
f
.
name
class
TestCliRequestParametersFileXml
(
TestCliRequestParametersFileJson
):
"""Request with --parameter-file, with a .xml file
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment