Skip to content

Commit e596d6c

Browse files
committed
lint
1 parent 24eb3b6 commit e596d6c

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/warnet/admin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
)
1818
from .namespaces import copy_namespaces_defaults, namespaces
1919
from .network import copy_network_defaults
20-
from .process import run_command
2120

2221

2322
@click.group(name="admin", hidden=True)
@@ -114,7 +113,11 @@ def create_kubeconfigs(kubeconfig_dir, token_duration):
114113
"contexts": [
115114
{
116115
"name": f"{name}-{namespace}",
117-
"context": {"cluster": cluster["name"], "namespace": namespace, "user": name},
116+
"context": {
117+
"cluster": cluster["name"],
118+
"namespace": namespace,
119+
"user": name,
120+
},
118121
}
119122
],
120123
"current-context": f"{name}-{namespace}",

src/warnet/k8s.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import tarfile
55
import tempfile
66
from pathlib import Path
7-
from time import time, sleep
7+
from time import sleep, time
88
from typing import Optional
99

1010
import yaml
@@ -524,18 +524,22 @@ def get_warnet_user_service_accounts_in_namespace(namespace):
524524
"""
525525
sclient = get_static_client()
526526
sas = sclient.list_namespaced_service_account(namespace)
527-
return [sa for sa in sas.items if sa.metadata.labels and "mission" in sa.metadata.labels and sa.metadata.labels["mission"] == "user"]
527+
return [
528+
sa
529+
for sa in sas.items
530+
if sa.metadata.labels
531+
and "mission" in sa.metadata.labels
532+
and sa.metadata.labels["mission"] == "user"
533+
]
534+
528535

529536
def get_token_for_service_acount(sa, duration):
530537
sclient = get_static_client()
531538
spec = V1TokenRequestSpec(
532-
audiences=["https://kubernetes.default.svc"],
533-
expiration_seconds=duration
539+
audiences=["https://kubernetes.default.svc"], expiration_seconds=duration
534540
)
535541
resp = sclient.create_namespaced_service_account_token(
536-
name=sa.metadata.name,
537-
namespace=sa.metadata.namespace,
538-
body=spec
542+
name=sa.metadata.name, namespace=sa.metadata.namespace, body=spec
539543
)
540544
return resp.status.token
541545

test/wargames_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def check_scenario_permissions(self):
9898
count += 1
9999
assert count <= 1
100100

101+
101102
if __name__ == "__main__":
102103
test = WargamesTest()
103104
test.run_test()

0 commit comments

Comments
 (0)