diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-07-09 13:56:33 +0200 |
---|---|---|
committer | John Villalovos <john@sodarock.com> | 2022-07-09 08:22:20 -0700 |
commit | 3b1ede4a27cd730982d4c579437c5c689a8799e5 (patch) | |
tree | 62889d73ce7a6523ff8036a6006111695fbc2894 /gitlab/v4/cli.py | |
parent | 0daec5fa1428a56a6a927b133613e8b296248167 (diff) | |
download | gitlab-3b1ede4a27cd730982d4c579437c5c689a8799e5.tar.gz |
feat: support validating CI lint results
Diffstat (limited to 'gitlab/v4/cli.py')
-rw-r--r-- | gitlab/v4/cli.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index d903527..b496669 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -25,6 +25,7 @@ import gitlab import gitlab.base import gitlab.v4.objects from gitlab import cli +from gitlab.exceptions import GitlabCiLintError class GitlabCLI: @@ -133,6 +134,16 @@ class GitlabCLI: except Exception as e: # pragma: no cover, cli.die is unit-tested cli.die("Impossible to download the export", e) + def do_validate(self) -> None: + if TYPE_CHECKING: + assert isinstance(self.mgr, gitlab.v4.objects.CiLintManager) + try: + self.mgr.validate(self.args) + except GitlabCiLintError as e: # pragma: no cover, cli.die is unit-tested + cli.die("CI YAML Lint failed", e) + except Exception as e: # pragma: no cover, cli.die is unit-tested + cli.die("Cannot validate CI YAML", e) + def do_create(self) -> gitlab.base.RESTObject: if TYPE_CHECKING: assert isinstance(self.mgr, gitlab.mixins.CreateMixin) |