Skip to content

Commit

Permalink
refactor according to review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
iurly committed Apr 18, 2024
1 parent 72c608e commit 29f9c16
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions plugins/filter/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,47 +34,30 @@ def to_agent_version_pinned(data):
return True
return False

def to_agent_packages(data):
def to_agent_install_packages(data):
""" Returns the agent packages to install
"""
pinned = to_agent_version_pinned(data)
older = False
all_packages = {
"draios-agent": False,
"draios-agent-slim": False,
"draios-agent-kmodule": False,
"draios-agent-legacy-ebpf": False,
}
if pinned:
version = to_agent_version(data)
minver = LooseVersion("1.0.0")
maxver = LooseVersion("13.1.0")
older = minver < LooseVersion(version) < maxver
if older:
all_packages ["draios-agent"] = True
else:
dt = to_agent_driver_type(data)
if dt == "universal_ebpf":
all_packages ["draios-agent-slim"] = True
elif dt == "legacy_ebpf":
all_packages ["draios-agent-slim"] = True
all_packages ["draios-agent-legacy-ebpf"] = True
else:
all_packages ["draios-agent"] = True
all_packages ["draios-agent-slim"] = True
all_packages ["draios-agent-kmodule"] = True

return all_packages
return ["draios-agent"]
package_map = {
"universal_ebpf": ["draios-agent-slim"],
"legacy_ebpf": ["draios-agent-slim", "draios-agent-legacy-ebpf"],
"kmod": ["draios-agent", "draios-agent-slim", "draios-agent-kmodule"]
}
return package_map[to_agent_driver_type(data)]

def to_agent_uninstall_packages(data):
""" Return the list of packages to be uninstalled
"""
return [ k for k, v in to_agent_packages(data).items() if v == False ]

def to_agent_install_packages(data):
""" Return the list of packages to be uninstalled
"""
return [ k for k, v in to_agent_packages(data).items() if v == True ]
all_packages = ["draios-agent", "draios-agent-legacy-ebpf", "draios-agent-slim", "draios-agent-kmodule"]
return [p for p in all_packages if p not in to_agent_install_packages(data)]

def to_agent_install_probe_build_dependencies(data):
""" Return true or false depending on if the probe (legacy_ebpf|kmod) build
Expand Down

0 comments on commit 29f9c16

Please sign in to comment.