Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[component] Apply plugopts from cmdline gently #3855

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion sos/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,20 @@ def apply_options_from_cmdline(self, opts):
setattr(opts, oopt, [x for x in getattr(opts, oopt)
if x not in common])

if val != opts.arg_defaults[opt]:
# plugin options as a list should be concatenated, not overriden
# BUT if cmdline plugoption overrides same option in opts, we must
# drop the opts's value; since the items are in form
# 'apache.log=on', we must separate the *name* of each option
if opt == 'plugopts':
oplugopts = getattr(opts, opt)
valnames = [v.split('=')[0] for v in val]
ovalnames = [v.split('=')[0] for v in oplugopts]
for common in set(valnames) & set(ovalnames):
cstring = f"{common}="
oplugopts = [oopt for oopt in oplugopts
if not oopt.startswith(cstring)]
setattr(opts, opt, list(set(val) | set(oplugopts)))
elif val != opts.arg_defaults[opt]:
setattr(opts, opt, val)

return opts
Expand Down
Loading