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

Using constant values instead of reassigning variables in each check run #17749

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions windows_service/changelog.d/17749.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Using constant values instead of reassigning variables in each check run
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class ServiceView(object):
}
STARTUP_TYPE_DELAYED_AUTO = "automatic_delayed_start"
STARTUP_TYPE_UNKNOWN = "unknown"
DISPLAY_NAME_UNKNOWN = "Not_Found"

def __init__(self, scm_handle, name):
self.scm_handle = scm_handle
Expand Down Expand Up @@ -308,18 +309,16 @@ def check(self, instance):
for service in services_unseen:
# if a name doesn't match anything (wrong name or no permission to access the service), report UNKNOWN
status = self.UNKNOWN
startup_type_string = ServiceView.STARTUP_TYPE_UNKNOWN
display_name = "Not_Found"

tags = ['windows_service:{}'.format(service)]

tags.extend(custom_tags)

if instance.get('windows_service_startup_type_tag', False):
tags.append('windows_service_startup_type:{}'.format(startup_type_string))
tags.append('windows_service_startup_type:{}'.format(ServiceView.STARTUP_TYPE_UNKNOWN))

if instance.get('collect_display_name_as_tag', False):
tags.append('display_name:{}'.format(display_name))
tags.append('display_name:{}'.format(ServiceView.DISPLAY_NAME_UNKNOWN))

if not instance.get('disable_legacy_service_tag', False):
self._log_deprecation('service_tag', 'windows_service')
Expand Down
Loading