Skip to content

Commit

Permalink
Using constant values instead of reassigning variables in each check …
Browse files Browse the repository at this point in the history
…run (#17749)

* using const instead of reassigning vars in function

* adding changelog
  • Loading branch information
mrafi97 authored Jun 6, 2024
1 parent b880923 commit 415d227
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 415d227

Please sign in to comment.