Skip to content

Commit 0ed2e4f

Browse files
author
Tim Bielawa
committed
Actually. Let's just raise an error if you try to pass in enable:true
1 parent 1fef547 commit 0ed2e4f

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

replugin/funcworker/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,12 @@ def parse_params(self, params, command_cfg):
344344
"for this subcommand")
345345
pass
346346
except ValueError, e:
347-
self.app_logger.error("Could not find parser for specified "
347+
self.app_logger.error("Could not find parser or failed to parse specified "
348348
"subcommand: %s" % params['subcommand'])
349-
# The handler was imported, but there is no parser for
350-
# the given sub-command. Or in other words, this func
351-
# worker doesn't have the requested subcommand. Sorry,
352-
# bud.
349+
# The handler was imported, but: there is no parser for
350+
# the given sub-command, or an invalid parameter was
351+
# provided.. Or in other words, this func worker doesn't
352+
# support the requested subcommand/arg combo. Sorry, bud.
353353
self.app_logger.error(e)
354354
raise FuncWorkerError(
355355
'Requested subcommand for %s is not supported '

replugin/funcworker/puppet.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _parse_Run(params, app_logger):
6666
"""
6767
app_logger.info("Parsing puppet:Run")
6868
# Allowed parameters to the 'run' subcommand
69-
_run_params = ['server', 'noop', 'tags', 'enable']
69+
_run_params = ['server', 'noop', 'tags']
7070

7171
_params = {}
7272
# Override the default cmd/subcmd to call the general purpose
@@ -83,11 +83,8 @@ def _parse_Run(params, app_logger):
8383
# Begin building command string
8484
##################################################################
8585

86-
# enable?
87-
# FIXME: Need to move away from shell logic
88-
# if params.get('enable', False):
89-
# _cmd_parts.append("puppet agent --enable --color=false")
90-
# _cmd_parts.append("&&")
86+
if 'enable' in params:
87+
raise ValueError('"enable" is not a valid parameter for the puppet:Run command')
9188

9289
# actual command
9390
_cmd_parts.append("puppet agent --test")

test/test_puppet_parser.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,17 @@ def test_run_server(self):
7979
(update, cmd) = ppt._parse_Run(params, self.app_logger)
8080
self.assertEqual(cmd, expected)
8181

82-
'''
83-
# FIXME
84-
#
85-
# No longer valid. See DE7743 for details. (Basically, we don't get to use
86-
# shell '&&' chars anymore and so puppet:Run doesn't allow enable:True any more.
87-
#
8882
def test_run_enable(self):
89-
"""puppet:Run with agent enable parses correctly"""
90-
expected = ["puppet agent --enable --color=false && puppet agent --test --color=false"]
83+
"""puppet:Run with agent enable raises"""
9184
params = {
9285
'hosts': ['testhost.example.com'],
9386
'command': 'puppet',
9487
'subcommand': 'Run',
9588
'enable': True
9689
}
97-
(update, cmd) = ppt._parse_Run(params, self.app_logger)
98-
self.assertEqual(cmd, expected)
99-
'''
90+
with self.assertRaises(ValueError):
91+
(update, cmd) = ppt._parse_Run(params, self.app_logger)
92+
10093
##################################################################
10194
# The "puppet:Enable" family
10295
##################################################################

0 commit comments

Comments
 (0)