-
Notifications
You must be signed in to change notification settings - Fork 230
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
feat: converted init_systems plugin to v1 #1346
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1346 +/- ##
==========================================
- Coverage 92.54% 91.59% -0.95%
==========================================
Files 381 376 -5
Lines 24397 20999 -3398
==========================================
- Hits 22577 19234 -3343
+ Misses 1820 1765 -55 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contrary to my comment above, I'm not sure if we should simplify this plugin to do the following:
- Detect init-systems by filename (As is done currently)
- Display the whole file contents in the frontend
Currently, the schema does not seem too useful to me.
What do you think?
SYSTEMD_EXECSTART_REGEX = re.compile(r'ExecStart=(.*)', re.MULTILINE) | ||
SYSTEMD_DESCRIPTION_REGEX = re.compile(r'Description=(.*)', re.MULTILINE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unneeded re.MULTILINE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
class Schema(BaseModel): | ||
init_type: Optional[str] = Field(None, description='The type of init system that was identified for this file') | ||
data: Optional[dict] = Field( | ||
None, | ||
description='Optional meta information and init data contained in this init script', | ||
) | ||
is_init: bool = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer sth. like this:
class Schema(BaseModel):
class SystemD:
#: A list of all ExecStart lines
exec_start: list[str]
#: The Description of the unit
description: str
class Inittab:
class Entry:
id: str
state: str
action: str
process: str
entries: list[Entry]
class Upstart:
...
class SysVInit:
...
systemd: Optional[SystemD]
inittab: Optional[Inittab]
sysvinit: Optional[SysVInit]
upstart: Optional[Upstart]
I find it hard to argue for/against anything since I haven't had a use case for this plugin.
The only thing I can imagine is searching for units that execute a specific executable.
However, I think that the usefulness of a plugin increases with a more structured result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, isn't init_type != None
equivalent to is_init
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer sth. like this:
class Schema(BaseModel): ...I find it hard to argue for/against anything since I haven't had a use case for this plugin. The only thing I can imagine is searching for units that execute a specific executable. However, I think that the usefulness of a plugin increases with a more structured result.
Hmm I don't think it makes a lot sense to have a result with the keys systemd, inittab, sysvinit and upstart and every value except one (at most) is None
(and it gets even worse when we add more types like procd). Having the result as a list also doesn't make a lot of sense. How about inheritance? Can we have a "InitData" base class with more concrete inheritors with more fields? Does JSON schema support that?
Also, isn't init_type != None equivalent to is_init?
Yes, absolutely. This could only bring better readability in code/queries but is totally redundant . It's probably better to throw it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it so that is uses multiple data classes with Union[]
. This is equivalent to a "anyOf" relation in JSON schema. There seems to be no way to connect it directly to the type of init system, though.
dec49dd
to
52c566f
Compare
52c566f
to
87e3661
Compare
No description provided.