Skip to content

Commit

Permalink
make bandit happy
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAeich committed Aug 4, 2024
1 parent f9b630b commit 5f44926
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ requires = ["poetry-core"]

[tool.bandit]
skips = [
"B101", # Use of asserts is discouraged as it is removed during byte generation, we don't need that!
"B108", # Insecure usage of temp file/directory, false positive.
"B321", # FTP-related functions are being called.
"B402", # A FTP-related module is being imported.
"B108" # Insecure usage of temp file/directory, false positive.
"B402" # A FTP-related module is being imported.
]

[tool.poetry]
Expand Down
2 changes: 1 addition & 1 deletion tesk/custom_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DownwardAPIItem(BaseModel):
"""Downward API item configuration."""

path: str
fieldRef: Dict[str, str]
fieldRef: str


class Volume(BaseModel):
Expand Down
15 changes: 10 additions & 5 deletions tesk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

import os
from pathlib import Path
from typing import Any, List, Optional, Sequence
from typing import List, Optional, Sequence

from foca import Foca
from kubernetes.client.models import (
V1Container,
V1DownwardAPIProjection,
V1DownwardAPIVolumeFile,
V1DownwardAPIVolumeSource,
V1EnvVar,
V1EnvVarSource,
V1Job,
V1JobSpec,
V1ObjectFieldSelector,
V1ObjectMeta,
V1PodSpec,
V1PodTemplateSpec,
Expand Down Expand Up @@ -126,14 +127,18 @@ def convert_downward_api_item(
downward_api_item: DownwardAPIItem,
) -> V1DownwardAPIVolumeFile:
return V1DownwardAPIVolumeFile(
path=downward_api_item.path, field_ref=downward_api_item.fieldRef
path=downward_api_item.path,
field_ref=V1ObjectFieldSelector(
# TODO: Check if this is correct.
field_path=downward_api_item.fieldRef
),
)

def convert_volume(volume: Volume) -> V1Volume:
if volume.downwardAPI:
return V1Volume(
name=volume.name,
downward_api=V1DownwardAPIProjection(
downward_api=V1DownwardAPIVolumeSource(
items=[
convert_downward_api_item(item)
for item in volume.downwardAPI["items"]
Expand Down Expand Up @@ -193,7 +198,7 @@ def convert_job_metadata(job_metadata: JobMetadata) -> V1ObjectMeta:
)


def pydantic_model_list_json(model_list: Sequence[BaseModel]) -> List[dict[str, Any]]:
def pydantic_model_list_json(model_list: Sequence[BaseModel]) -> List[str]:
"""Convert a list of pydantic models to a list of JSON objects."""
json_list = []
for item in model_list:
Expand Down

0 comments on commit 5f44926

Please sign in to comment.