Skip to content
This repository was archived by the owner on Oct 3, 2020. It is now read-only.

Commit 1eb7678

Browse files
authored
refactor into scale_down/scale_up functions (#103)
* refactor into scale_down/scale_up functions * use f-literals * add a test for --include-resources
1 parent b225188 commit 1eb7678

File tree

5 files changed

+143
-166
lines changed

5 files changed

+143
-166
lines changed

kube_downscaler/cmd.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def check_include_resources(value):
1010
resources = frozenset(value.split(","))
1111
if not resources <= VALID_RESOURCES:
1212
raise argparse.ArgumentTypeError(
13-
f"--include-resources argument should contain a subset of [{', '.join(VALID_RESOURCES)}]"
13+
f"--include-resources argument should contain a subset of [{', '.join(sorted(VALID_RESOURCES))}]"
1414
)
1515
return value
1616

@@ -38,8 +38,7 @@ def get_parser():
3838
"--include-resources",
3939
type=check_include_resources,
4040
default="deployments",
41-
help="Downscale resources of this kind as comma separated list. [%s] (default: deployments)"
42-
% (",".join(VALID_RESOURCES)),
41+
help=f"Downscale resources of this kind as comma separated list. [{', '.join(sorted(VALID_RESOURCES))}] (default: deployments)",
4342
)
4443
parser.add_argument(
4544
"--grace-period",

kube_downscaler/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def run_loop(
8383
deployment_time_annotation=deployment_time_annotation,
8484
)
8585
except Exception as e:
86-
logger.exception("Failed to autoscale : %s", e)
86+
logger.exception(f"Failed to autoscale: {e}")
8787
if run_once or handler.shutdown_now:
8888
return
8989
with handler.safe_exit():

0 commit comments

Comments
 (0)