Skip to content

Commit 67bbf3b

Browse files
committed
Linting
1 parent 48b27b5 commit 67bbf3b

5 files changed

Lines changed: 23 additions & 32 deletions

File tree

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-12-12T20:28:52Z",
6+
"generated_at": "2025-12-15T15:57:18Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -82,15 +82,15 @@
8282
"hashed_secret": "053f5ed451647be0bbb6f67b80d6726808cad97e",
8383
"is_secret": false,
8484
"is_verified": false,
85-
"line_number": 42,
85+
"line_number": 44,
8686
"type": "Secret Keyword",
8787
"verified_result": null
8888
},
8989
{
9090
"hashed_secret": "4f75456d6c1887d41ed176f7ad3e2cfff3fdfd91",
9191
"is_secret": false,
9292
"is_verified": false,
93-
"line_number": 51,
93+
"line_number": 53,
9494
"type": "Secret Keyword",
9595
"verified_result": null
9696
}

bin/mas-devops-create-initial-users-for-saas

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,18 @@
1010
#
1111
# *****************************************************************************
1212

13+
from mas.devops.users import MASUserUtils
14+
from botocore.exceptions import ClientError
15+
import boto3
16+
import sys
17+
import json
18+
import yaml
1319
from kubernetes import client, config
1420
from kubernetes.config.config_exception import ConfigException
1521
import argparse
1622
import logging
1723
import urllib3
1824
urllib3.disable_warnings()
19-
import yaml
20-
import json
21-
import sys
22-
23-
import boto3
24-
from botocore.exceptions import ClientError
25-
26-
from mas.devops.users import MASUserUtils
27-
2825

2926

3027
if __name__ == "__main__":
@@ -38,7 +35,6 @@ if __name__ == "__main__":
3835
parser.add_argument("--admin-dashboard-port", required=False, default=443)
3936
parser.add_argument("--manage-api-port", required=False, default=443)
4037

41-
4238
group = parser.add_mutually_exclusive_group(required=True)
4339
group.add_argument("--initial-users-yaml-file")
4440
group.add_argument("--initial-users-secret-name")
@@ -66,7 +62,6 @@ if __name__ == "__main__":
6662
admin_dashboard_port = args.admin_dashboard_port
6763
manage_api_port = args.manage_api_port
6864

69-
7065
logger.info("Configuration:")
7166
logger.info("--------------")
7267
logger.info(f"mas_instance_id: {mas_instance_id}")
@@ -88,7 +83,6 @@ if __name__ == "__main__":
8883
config.load_kube_config()
8984
logger.debug("Loaded kubeconfig file")
9085

91-
9286
user_utils = MASUserUtils(mas_instance_id, mas_workspace_id, client.api_client.ApiClient(), coreapi_port=coreapi_port, admin_dashboard_port=admin_dashboard_port, manage_api_port=manage_api_port)
9387

9488
if initial_users_secret_name is not None:
@@ -100,7 +94,7 @@ if __name__ == "__main__":
10094
service_name='secretsmanager',
10195
)
10296
try:
103-
initial_users_secret = aws_sm_client.get_secret_value( # pragma: allowlist secret
97+
initial_users_secret = aws_sm_client.get_secret_value( # pragma: allowlist secret
10498
SecretId=initial_users_secret_name
10599
)
106100
except ClientError as e:
@@ -109,16 +103,15 @@ if __name__ == "__main__":
109103
sys.exit(0)
110104

111105
raise Exception(f"Failed to fetch secret {initial_users_secret_name}: {str(e)}")
112-
106+
113107
secret_json = json.loads(initial_users_secret['SecretString'])
114108
initial_users = user_utils.parse_initial_users_from_aws_secret_json(secret_json)
115109
elif initial_users_yaml_file is not None:
116110
with open(initial_users_yaml_file, 'r') as file:
117111
initial_users = yaml.safe_load(file)
118112
else:
119113
raise Exception("Something unexpected happened")
120-
121-
114+
122115
result = user_utils.create_initial_users_for_saas(initial_users)
123116

124117
# if user details were sourced from an AWS SM secret, remove the completed entries from the secret
@@ -133,14 +126,13 @@ if __name__ == "__main__":
133126
if has_updates:
134127
logger.info(f"Updating secret {initial_users_secret_name}")
135128
try:
136-
aws_sm_client.update_secret( # pragma: allowlist secret
129+
aws_sm_client.update_secret( # pragma: allowlist secret
137130
SecretId=initial_users_secret_name,
138131
SecretString=json.dumps(secret_json)
139132
)
140133
except ClientError as e:
141134
raise Exception(f"Failed to update secret {initial_users_secret_name}: {str(e)}")
142-
143135

144136
if len(result["failed"]) > 0:
145-
failed_user_ids = list(map(lambda u : u["email"], result["failed"]))
146-
raise Exception(f"Sync failed for the following user IDs {failed_user_ids}")
137+
failed_user_ids = list(map(lambda u: u["email"], result["failed"]))
138+
raise Exception(f"Sync failed for the following user IDs {failed_user_ids}")

bin/mas-devops-notify-slack

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _getToolchainLink() -> str:
3333
return ""
3434

3535

36-
def notifyProvisionFyre(channels: list[str], rc: int, additionalMsg: str=None) -> bool:
36+
def notifyProvisionFyre(channels: list[str], rc: int, additionalMsg: str = None) -> bool:
3737
"""Send Slack notification about Fyre OCP cluster provisioning status."""
3838
name = _getClusterName()
3939
toolchainLink = _getToolchainLink()
@@ -60,14 +60,14 @@ def notifyProvisionFyre(channels: list[str], rc: int, additionalMsg: str=None) -
6060
SlackUtil.buildHeader(f":glyph-fail: Your IBM DevIT Fyre OCP cluster ({name}) failed to deploy"),
6161
SlackUtil.buildSection(f"<https://beta.fyre.ibm.com/development/vms|Fyre Dashboard>{toolchainLink}")
6262
]
63-
63+
6464
response = SlackUtil.postMessageBlocks(channels, message)
6565
if isinstance(response, list):
6666
return all([res.data.get("ok", False) for res in response])
6767
return response.data.get("ok", False)
6868

6969

70-
def notifyProvisionRoks(channels: list[str], rc: int, additionalMsg: str=None) -> bool:
70+
def notifyProvisionRoks(channels: list[str], rc: int, additionalMsg: str = None) -> bool:
7171
"""Send Slack notification about ROKS cluster provisioning status."""
7272
name = _getClusterName()
7373
toolchainLink = _getToolchainLink()
@@ -103,18 +103,18 @@ if __name__ == "__main__":
103103
SLACK_CHANNEL = os.getenv("SLACK_CHANNEL", "")
104104
if SLACK_TOKEN == "" or SLACK_CHANNEL == "":
105105
sys.exit(0)
106-
106+
107107
# Parse comma-separated channel list
108108
channelList = [ch.strip() for ch in SLACK_CHANNEL.split(",")]
109-
109+
110110
# Initialize the properties we need
111111
parser = argparse.ArgumentParser()
112112

113113
# Primary Options
114114
parser.add_argument("--action", required=True)
115115
parser.add_argument("--rc", required=True, type=int)
116116
parser.add_argument("--msg", required=False, default=None)
117-
117+
118118
args, unknown = parser.parse_known_args()
119119

120120
if args.action == "ocp-provision-fyre":

bin/mas-devops-saas-job-cleaner

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ if __name__ == "__main__":
4646
ch.setFormatter(chFormatter)
4747
logger.addHandler(ch)
4848

49-
5049
limit = args.limit
5150
label = args.label
5251
dry_run = args.dry_run

src/mas/devops/slack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def client(cls) -> WebClient:
3939

4040
# Post message to Slack
4141
# -----------------------------------------------------------------------------
42-
def postMessageBlocks(cls, channelList: str | list[str], messageBlocks: list, threadId: str=None) -> SlackResponse | list[SlackResponse]:
42+
def postMessageBlocks(cls, channelList: str | list[str], messageBlocks: list, threadId: str = None) -> SlackResponse | list[SlackResponse]:
4343
responses: list[SlackResponse] = []
4444

4545
if isinstance(channelList, str):
@@ -84,7 +84,7 @@ def postMessageBlocks(cls, channelList: str | list[str], messageBlocks: list, th
8484

8585
return responses if len(responses) > 1 else responses[0]
8686

87-
def postMessageText(cls, channelList: str | list[str], message: str, attachments=None, threadId: str=None) -> SlackResponse | list[SlackResponse]:
87+
def postMessageText(cls, channelList: str | list[str], message: str, attachments=None, threadId: str = None) -> SlackResponse | list[SlackResponse]:
8888
responses: list[SlackResponse] = []
8989

9090
if isinstance(channelList, str):

0 commit comments

Comments
 (0)