forked from zakkg3/ClusterSecret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_utils.py
32 lines (23 loc) · 772 Bytes
/
os_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from functools import cache
from consts import BLOCKED_LABELS
@cache
def get_version() -> str:
"""
Wrapper for CLUSTER_SECRET_VERSION variable environment
"""
return os.getenv('CLUSTER_SECRET_VERSION', '0')
@cache
def get_replace_existing() -> bool:
replace_existing = os.getenv('REPLACE_EXISTING', 'false')
return replace_existing.lower() == 'true'
@cache
def get_blocked_labels() -> list[str]:
blocked_labels = os.getenv('BLOCKED_LABELS', ','.join(BLOCKED_LABELS))
return [label.strip() for label in blocked_labels.split(',')]
@cache
def in_cluster() -> bool:
"""
Whether we are running in cluster (on the pod) or outside (debug mode.)
"""
return os.getenv('KUBERNETES_SERVICE_HOST', None) is not None