|
| 1 | +# __author__ = "Thomas Steinbach" |
| 2 | +# __copyright__ = "Copyright 2020 DB Systel GmbH" |
| 3 | +# __credits__ = ["Daniel von Eßen"] |
| 4 | +# # SPDX-License-Identifier: Apache-2.0 |
| 5 | +# __license__ = "Apache-2.0" |
| 6 | +# __maintainer__ = "Daniel von Eßen" |
| 7 | +# __email__ = "daniel.von-essen@deutschebahn.com" |
| 8 | + |
| 9 | +# from typing import Any, Dict, List, Optional |
| 10 | + |
| 11 | +# from gcip.core.rule import WhenStatement |
| 12 | +# from gcip.core.variables import PredefinedVariables |
| 13 | + |
| 14 | + |
| 15 | +# class Artifacts: |
| 16 | +# def __init__( |
| 17 | +# self, |
| 18 | +# paths: List[str], |
| 19 | +# *, |
| 20 | +# excludes: List[str] = [], |
| 21 | +# expire_in: Optional[str] = None, |
| 22 | +# expose_as: Optional[str] = None, |
| 23 | +# name: Optional[str] = None, |
| 24 | +# public: Optional[bool] = None, |
| 25 | +# untracked: Optional[bool] = None, |
| 26 | +# when: Optional[WhenStatement] = None, |
| 27 | +# ) -> None: |
| 28 | +# self._expire_in = expire_in |
| 29 | +# self._expose_as = expose_as |
| 30 | +# self._name = name if name else f"{PredefinedVariables.CI_JOB_NAME}-{PredefinedVariables.CI_COMMIT_REF_SLUG}" |
| 31 | +# self._public = public |
| 32 | +# self._untracked = untracked |
| 33 | +# self._when = when |
| 34 | + |
| 35 | +# # Remove project path prefix from paths given. |
| 36 | +# # Prepend ./ to path to clearify that cache paths |
| 37 | +# # are relative to CI_PROJECT_DIR |
| 38 | +# self._paths = [path if not path.startswith(PredefinedVariables.CI_PROJECT_DIR) else path[len(PredefinedVariables.CI_PROJECT_DIR) :] for path in paths] |
| 39 | +# if len(excludes) > 0: |
| 40 | +# self._excludes = [ |
| 41 | +# exclude if not exclude.startswith(PredefinedVariables.CI_PROJECT_DIR) else exclude[len(PredefinedVariables.CI_PROJECT_DIR) :] |
| 42 | +# for exclude in excludes |
| 43 | +# ] |
| 44 | + |
| 45 | +# @property |
| 46 | +# def paths(self): |
| 47 | +# return self._paths |
| 48 | + |
| 49 | +# @property |
| 50 | +# def excludes(self): |
| 51 | +# return self._excludes |
| 52 | + |
| 53 | +# @property |
| 54 | +# def expire_in(self): |
| 55 | +# return self._expire_in |
| 56 | + |
| 57 | +# @property |
| 58 | +# def expose_as(self): |
| 59 | +# return self._expose_as |
| 60 | + |
| 61 | +# @property |
| 62 | +# def name(self): |
| 63 | +# return self._name |
| 64 | + |
| 65 | +# @property |
| 66 | +# def public(self): |
| 67 | +# return self._public |
| 68 | + |
| 69 | +# @property |
| 70 | +# def untracked(self): |
| 71 | +# return self._untracked |
| 72 | + |
| 73 | +# @property |
| 74 | +# def when(self): |
| 75 | +# return self._when |
| 76 | + |
| 77 | +# def render(self) -> Dict[str, Any]: |
| 78 | +# """Return a representation of this Cache object as dictionary with static values. |
| 79 | + |
| 80 | +# The rendered representation is used by the gcip to dump it |
| 81 | +# in YAML format as part of the .gitlab-ci.yml pipeline. |
| 82 | + |
| 83 | +# Returns: |
| 84 | +# Dict[str, Any]: A dictionary prepresenting the cache object in Gitlab CI. |
| 85 | +# """ |
| 86 | +# rendered: Dict[str, Union[str, bool, List[str], Union[str, Dict[str, Union[List[str], str]]]]] |
| 87 | +# rendered = { |
| 88 | +# "paths": self.paths, |
| 89 | +# "name": self.name, |
| 90 | +# } |
| 91 | +# if self.excludes: |
| 92 | +# rendered["excludes"] = self.excludes |
| 93 | +# if self.expire_in: |
| 94 | +# rendered["expire_in"] = self.expire_in |
| 95 | +# if self.expose_as: |
| 96 | +# rendered["expose_as"] = self.expose_as |
| 97 | +# if self.expose_as: |
| 98 | +# rendered["expose_as"] = self._policy.value |
| 99 | +# if self.expose_as: |
| 100 | +# rendered["expose_as"] = self._policy.value |
| 101 | +# if self.expose_as: |
| 102 | +# rendered["expose_as"] = self._policy.value |
| 103 | +# rendered["key"] = self._cache_key.render() |
| 104 | + |
| 105 | +# return rendered |
0 commit comments