-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow to pass an explicit commit * Split into several modules * Add more unit tests
- Loading branch information
1 parent
783f358
commit 850731b
Showing
5 changed files
with
338 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# SPDX-FileCopyrightText: 2023 Greenbone AG | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from argparse import ArgumentParser, Namespace | ||
|
||
from mattermost_notify.status import Status | ||
|
||
|
||
def parse_args(args=None) -> Namespace: | ||
parser = ArgumentParser() | ||
|
||
parser.add_argument( | ||
"url", | ||
help="Mattermost (WEBHOOK) URL", | ||
type=str, | ||
) | ||
|
||
parser.add_argument( | ||
"channel", | ||
type=str, | ||
help="Mattermost Channel", | ||
) | ||
|
||
parser.add_argument( | ||
"-s", | ||
"--short", | ||
action="store_true", | ||
help="Send a short single line message", | ||
) | ||
|
||
parser.add_argument( | ||
"-S", | ||
"--status", | ||
type=str, | ||
choices=["success", "failure"], | ||
default=Status.SUCCESS.name, | ||
help="Status of Job", | ||
) | ||
|
||
parser.add_argument( | ||
"-r", "--repository", type=str, help="git repository name (orga/repo)" | ||
) | ||
|
||
parser.add_argument("-b", "--branch", type=str, help="git branch") | ||
|
||
parser.add_argument( | ||
"-w", "--workflow", type=str, help="hash/ID of the workflow" | ||
) | ||
|
||
parser.add_argument( | ||
"-n", "--workflow_name", type=str, help="name of the workflow" | ||
) | ||
|
||
parser.add_argument("--commit", help="Commit to use") | ||
|
||
parser.add_argument( | ||
"--free", | ||
type=str, | ||
help="Print a free-text message to the given channel", | ||
) | ||
|
||
parser.add_argument( | ||
"--highlight", | ||
nargs="+", | ||
help="List of persons to highlight in the channel", | ||
) | ||
|
||
return parser.parse_args(args=args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-FileCopyrightText: 2022-2023 Greenbone AG | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from enum import Enum | ||
|
||
|
||
class Status(Enum): | ||
SUCCESS = ":white_check_mark: success" | ||
FAILURE = ":x: failure" | ||
UNKNOWN = ":grey_question: unknown" | ||
CANCELLED = ":no_entry_sign: canceled" | ||
|
||
def __str__(self): | ||
return self.name |
Oops, something went wrong.