Skip to content

Commit

Permalink
Deprecate forms key in Storm command definitions and related syn:cmd …
Browse files Browse the repository at this point in the history
…props (SYN-6596) (#4076)
  • Loading branch information
Cisphyx authored Jan 17, 2025
1 parent ace3727 commit 2f5c32b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
7 changes: 7 additions & 0 deletions changes/fce9eb48213f47cd09de69147fc605bd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
desc: The ``forms`` key in Storm package command definitions has been deprecated. The
``cmdinputs`` key may still be used to specify node forms that commands are intended
to accept as input.
prs: []
type: deprecation
...
9 changes: 2 additions & 7 deletions docs/docdata/foopkg/foopkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,5 @@ commands:
help: Specify a timeout in seconds.
cmdconf:
srcguid: f751f9ad20e75547be230ae1a425fb9f
forms:
input:
- inet:ipv4
output:
- inet:ipv4
nodedata:
- [ foodata, file:bytes ]
cmdinputs:
- form: inet:ipv4
6 changes: 6 additions & 0 deletions synapse/cortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2860,6 +2860,12 @@ async def _normStormPkg(self, pkgdef, validstorm=True):
cmdtext = cdef.get('storm')
await self.getStormQuery(cmdtext)

if cdef.get('forms') is not None:
name = cdef.get('name')
mesg = f"Storm command definition 'forms' key is deprecated and will be removed " \
f"in 3.0.0 (command {name} in package {pkgname})"
logger.warning(mesg, extra=await self.getLogExtra(name=name, pkgname=pkgname))

for gdef in pkgdef.get('graphs', ()):
gdef['iden'] = s_common.guid((pkgname, gdef.get('name')))
gdef['scope'] = 'power-up'
Expand Down
3 changes: 3 additions & 0 deletions synapse/models/syn.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,13 @@ def getModelDefs(self):
('svciden', ('guid', {'strip': True}), {
'doc': 'Storm service iden which provided the package.'}),
('input', ('array', {'type': 'syn:form'}), {
'deprecated': True,
'doc': 'The list of forms accepted by the command as input.', 'uniq': True, 'sorted': True, 'ro': True}),
('output', ('array', {'type': 'syn:form'}), {
'deprecated': True,
'doc': 'The list of forms produced by the command as output.', 'uniq': True, 'sorted': True, 'ro': True}),
('nodedata', ('array', {'type': 'syn:nodedata'}), {
'deprecated': True,
'doc': 'The list of nodedata that may be added by the command.', 'uniq': True, 'sorted': True, 'ro': True}),
)),
),
Expand Down
12 changes: 9 additions & 3 deletions synapse/tests/test_model_syn.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,16 @@ async def test_syn_cmd_runts(self):
nodes = await core.nodes('syn:cmd +:package')
self.len(0, nodes)

await core.nodes(f'service.add test {url}')
iden = core.getStormSvcs()[0].iden
with self.getLoggerStream('synapse.cortex') as stream:
await core.nodes(f'service.add test {url}')
iden = core.getStormSvcs()[0].iden

await core.nodes('$lib.service.wait(test)')
await core.nodes('$lib.service.wait(test)')

stream.seek(0)
warn = "Storm command definition 'forms' key is deprecated and will be removed " \
"in 3.0.0 (command foobar in package foo)"
self.isin(warn, stream.read())

# check that runt nodes for new commands are created
nodes = await core.nodes('syn:cmd +:package')
Expand Down

0 comments on commit 2f5c32b

Please sign in to comment.