Skip to content

Commit ef8c8cd

Browse files
committed
[confcom] Fix lint errors
1 parent 393e97d commit ef8c8cd

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

src/confcom/azext_confcom/container.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ def _populate_policy_json_elements(self, omit_id: bool = False) -> Dict[str, Any
795795
if self._mounted_cim:
796796
elements[config.POLICY_FIELD_CONTAINERS_ELEMENTS_MOUNTED_CIM] = self._mounted_cim
797797

798-
799798
if not omit_id:
800799
elements[config.POLICY_FIELD_CONTAINERS_ID] = self._identifier
801800
# if we are omitting the id, we should remove the id value from the policy if it's in the name field
@@ -822,7 +821,10 @@ def from_json(
822821
image.get_mounts().extend(_DEFAULT_MOUNTS_VN2)
823822

824823
# Start with the customer environment rules
825-
env_rules = copy.deepcopy(_INJECTED_CUSTOMER_ENV_RULES) if container_json["platform"].startswith("linux") else dict()
824+
env_rules = (
825+
copy.deepcopy(_INJECTED_CUSTOMER_ENV_RULES)
826+
if container_json["platform"].startswith("linux") else dict()
827+
)
826828
# If is_vn2, add the VN2 environment rules
827829
if is_vn2:
828830
env_rules += _INJECTED_SERVICE_VN2_ENV_RULES

src/confcom/azext_confcom/lib/containers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6-
from typing import Optional
6+
77
from dataclasses import asdict
88
from azext_confcom.lib.images import get_image_layers, get_image_config, get_image_platform
99
from azext_confcom.lib.platform import ACI_MOUNTS, VN2_MOUNTS
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from azext_confcom import config
22

3+
34
def get_debug_mode_exec_procs(debug_mode: bool, platform: str) -> list:
45

56
if not debug_mode:
67
return []
78

89
if platform.startswith("linux"):
910
return config.DEBUG_MODE_SETTINGS.get(config.ACI_FIELD_CONTAINERS_EXEC_PROCESSES)
10-
elif platform.startswith("windows"):
11+
if platform.startswith("windows"):
1112
return config.DEBUG_MODE_SETTINGS_WINDOWS.get(config.ACI_FIELD_CONTAINERS_EXEC_PROCESSES)
12-
else:
13-
raise ValueError(f"Unsupported platform for debug mode settings: {platform}")
13+
raise ValueError(f"Unsupported platform for debug mode settings: {platform}")

src/confcom/azext_confcom/rootfs_proxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(self):
8585
st = os.stat(self.policy_bin)
8686
os.chmod(self.policy_bin, st.st_mode | stat.S_IXUSR)
8787

88-
def get_policy_image_layers(
88+
def get_policy_image_layers( # pylint: disable=redefined-outer-name
8989
self,
9090
image: str,
9191
tag: str,
@@ -149,7 +149,7 @@ def get_policy_image_layers(
149149
if "mounted_cim" in json_output:
150150
result["mounted_cim"] = json_output["mounted_cim"]
151151
except json.JSONDecodeError as e:
152-
logger.error(f"Failed to parse JSON output: {e}")
152+
logger.error("Failed to parse JSON output: %s", e)
153153
sys.exit(1)
154154
else:
155155
# Fallback: line-by-line parsing for older dmverity-vhd versions

src/confcom/azext_confcom/security_policy.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def _add_rego_boilerplate(self, output: str) -> str:
236236
pretty_print_func(self._allow_unencrypted_scratch),
237237
pretty_print_func(self._allow_capability_dropping),
238238
)
239-
elif self._platform.startswith("windows"):
239+
if self._platform.startswith("windows"):
240240
return config.CUSTOMER_REGO_POLICY_WINDOWS % (
241241
pretty_print_func(self._api_version),
242242
pretty_print_func(sanitized_fragments),
@@ -841,7 +841,9 @@ def load_policy_from_arm_template_str(
841841
or [],
842842
config.ACI_FIELD_CONTAINERS_MOUNTS: process_mounts(image_properties, volumes)
843843
+ process_configmap(image_properties),
844-
config.ACI_FIELD_CONTAINERS_EXEC_PROCESSES: exec_processes + get_debug_mode_exec_procs(debug_mode, platform),
844+
config.ACI_FIELD_CONTAINERS_EXEC_PROCESSES: (
845+
exec_processes + get_debug_mode_exec_procs(debug_mode, platform)
846+
),
845847
config.ACI_FIELD_CONTAINERS_SIGNAL_CONTAINER_PROCESSES: [],
846848
config.ACI_FIELD_CONTAINERS_ALLOW_STDIO_ACCESS: not disable_stdio,
847849
config.ACI_FIELD_CONTAINERS_SECURITY_CONTEXT: case_insensitive_dict_get(
@@ -1081,7 +1083,9 @@ def load_policy_from_json(
10811083
container_properties, config.ACI_FIELD_TEMPLATE_COMMAND
10821084
) or [],
10831085
config.ACI_FIELD_CONTAINERS_MOUNTS: mounts,
1084-
config.ACI_FIELD_CONTAINERS_EXEC_PROCESSES: exec_processes + get_debug_mode_exec_procs(debug_mode, platform),
1086+
config.ACI_FIELD_CONTAINERS_EXEC_PROCESSES: (
1087+
exec_processes + get_debug_mode_exec_procs(debug_mode, platform)
1088+
),
10851089
config.ACI_FIELD_CONTAINERS_SIGNAL_CONTAINER_PROCESSES: [],
10861090
config.ACI_FIELD_CONTAINERS_ALLOW_STDIO_ACCESS: not disable_stdio,
10871091
config.ACI_FIELD_CONTAINERS_SECURITY_CONTEXT: case_insensitive_dict_get(
@@ -1351,7 +1355,9 @@ def load_policy_from_virtual_node_yaml_str(
13511355
config.ACI_FIELD_TEMPLATE_ENTRYPOINT: command,
13521356
config.ACI_FIELD_CONTAINERS_COMMAND: args,
13531357
config.ACI_FIELD_CONTAINERS_MOUNTS: mounts,
1354-
config.ACI_FIELD_CONTAINERS_EXEC_PROCESSES: exec_processes + get_debug_mode_exec_procs(debug_mode, platform),
1358+
config.ACI_FIELD_CONTAINERS_EXEC_PROCESSES: (
1359+
exec_processes + get_debug_mode_exec_procs(debug_mode, platform)
1360+
),
13551361
config.ACI_FIELD_CONTAINERS_SIGNAL_CONTAINER_PROCESSES: [],
13561362
config.ACI_FIELD_CONTAINERS_ALLOW_STDIO_ACCESS: not disable_stdio,
13571363
config.ACI_FIELD_CONTAINERS_SECURITY_CONTEXT: security_context,

0 commit comments

Comments
 (0)