Skip to content

Commit 48b27b5

Browse files
authored
Update mas-devops-notify-slack
1 parent b539f6a commit 48b27b5

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

bin/mas-devops-notify-slack

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import os
1515
import sys
1616
from mas.devops.slack import SlackUtil
1717

18+
1819
def _getClusterName() -> str:
1920
name = os.getenv("CLUSTER_NAME", "")
2021
if name == "":
2122
print("CLUSTER_NAME env var must be set")
2223
sys.exit(1)
2324
return name
2425

26+
2527
def _getToolchainLink() -> str:
2628
toolchainUrl = os.getenv("TOOLCHAIN_PIPELINERUN_URL", None)
2729
toolchainTriggerName = os.getenv("TOOLCHAIN_TRIGGER_NAME", None)
@@ -31,7 +33,7 @@ def _getToolchainLink() -> str:
3133
return ""
3234

3335

34-
def notifyProvisionFyre(channels: list[str], rc: int, additionalMsg: str = "") -> bool:
36+
def notifyProvisionFyre(channels: list[str], rc: int, additionalMsg: str=None) -> bool:
3537
"""Send Slack notification about Fyre OCP cluster provisioning status."""
3638
name = _getClusterName()
3739
toolchainLink = _getToolchainLink()
@@ -51,7 +53,7 @@ def notifyProvisionFyre(channels: list[str], rc: int, additionalMsg: str = "") -
5153
SlackUtil.buildSection(f"- Username: `{username}`\n- Password: `{password}`"),
5254
SlackUtil.buildSection(f"<https://beta.fyre.ibm.com/development/vms|Fyre Dashboard>{toolchainLink}")
5355
]
54-
if additionalMsg:
56+
if additionalMsg is not None:
5557
message.append(SlackUtil.buildSection(additionalMsg))
5658
else:
5759
message = [
@@ -65,7 +67,7 @@ def notifyProvisionFyre(channels: list[str], rc: int, additionalMsg: str = "") -
6567
return response.data.get("ok", False)
6668

6769

68-
def notifyProvisionRoks(channels: list[str], rc: int, additionalMsg: str = "") -> bool:
70+
def notifyProvisionRoks(channels: list[str], rc: int, additionalMsg: str=None) -> bool:
6971
"""Send Slack notification about ROKS cluster provisioning status."""
7072
name = _getClusterName()
7173
toolchainLink = _getToolchainLink()
@@ -81,7 +83,7 @@ def notifyProvisionRoks(channels: list[str], rc: int, additionalMsg: str = "") -
8183
SlackUtil.buildSection(f"{url}"),
8284
SlackUtil.buildSection(f"<https://cloud.ibm.com/kubernetes/clusters|IBM Cloud Dashboard>{toolchainLink}")
8385
]
84-
if additionalMsg:
86+
if additionalMsg is not None:
8587
message.append(SlackUtil.buildSection(additionalMsg))
8688
else:
8789
message = [
@@ -111,7 +113,7 @@ if __name__ == "__main__":
111113
# Primary Options
112114
parser.add_argument("--action", required=True)
113115
parser.add_argument("--rc", required=True, type=int)
114-
parser.add_argument("--msg", required=False, default="")
116+
parser.add_argument("--msg", required=False, default=None)
115117

116118
args, unknown = parser.parse_known_args()
117119

0 commit comments

Comments
 (0)