Skip to content

Commit

Permalink
blinkstick config options
Browse files Browse the repository at this point in the history
  • Loading branch information
tobru committed Jun 1, 2024
1 parent fa4316e commit fa77b49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion podstatus/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@
bstick = blinkstick.find_first()
if not bstick:
logging.info("No BlinkStick found")
led_per_pod = 3
logging.info(
f"BlinkStick found: {bstick.get_description()} - {bstick.get_serial()}"
)
logging.info(
f"Setting total LED to {config.BLINKSTICK_TOTAL_LED} and grouping to {config.BLINKSTICK_GROUP_LED}"
)
bstick.set_led_count(config.BLINKSTICK_TOTAL_LED)
led_per_pod = config.BLINKSTICK_GROUP_LED
except NoBackendError as e:
logging.fatal(f"BlinkStick setup failed: {e}")
bstick = None
Expand Down
4 changes: 3 additions & 1 deletion podstatus/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def __init__(self):
self.LOG_LEVEL = self.get_env_var("LOG_LEVEL", "INFO").upper()
self.KUBECONFIG = os.getenv("KUBECONFIG", None)
self.K8S_NAMESPACE = self.get_env_var("K8S_NAMESPACE")
self.BLINKSTICK_TOTAL_LED = self.get_env_int_var("BLINKSTICK_TOTAL_LED", 15)
self.BLINKSTICK_GROUP_LED = self.get_env_int_var("BLINKSTICK_GROUP_LED", 3)

def get_env_var(self, name, default=None):
value = os.getenv(name, default)
Expand All @@ -22,7 +24,7 @@ def get_env_var(self, name, default=None):
return value.replace('"', "")

def get_env_int_var(self, name, default=None):
value = self.get_env_var(name, default)
value = os.getenv(name, default)
try:
return int(value)
except ValueError:
Expand Down

0 comments on commit fa77b49

Please sign in to comment.