Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
define predefined artefact-types from ocm-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ccwienk committed Jan 18, 2023
1 parent 561568a commit bec0341
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bindings-python/gci/componentmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ class ArtefactType(enum.Enum):
COSIGN_SIGNATURE = 'cosignSignature'
GIT = 'git'
OCI_IMAGE = 'ociImage'
OCI_ARTEFACT = 'ociArtifact/v1'
HELM_CHART = 'helmChart/v1'
BLOB = 'blob/v1'


# hack: patch enum to accept "aliases"
# -> the values defined in enum above will be used for serialisation; the aliases are also
# accepted for deserialisation
# note: the `/v1` suffix is _always_ optional (if absent, /v1 is implied)
ArtefactType._value2member_map_ |= {
'blob': ArtefactType.BLOB,
'git/v1': ArtefactType.GIT,
'ociImage/v1': ArtefactType.OCI_IMAGE,
'ociImage': ArtefactType.OCI_IMAGE,
'helmChart': ArtefactType.HELM_CHART,
}


# aliases (deprecated!) for backwards-compatibility
Expand Down Expand Up @@ -530,11 +546,11 @@ def from_dict(
config=dacite.Config(
cast=[
SchemaVersion,
ArtefactType,
ResourceRelation,
],
type_hooks={
typing.Union[AccessType, str]: functools.partial(enum_or_string, enum_type=AccessType),
typing.Union[ArtefactType, str]: functools.partial(enum_or_string, enum_type=ArtefactType),
typing.Union[ArtifactIdentity, str]: functools.partial(enum_or_string, enum_type=ArtefactType),
AccessType: functools.partial(enum_or_string, enum_type=AccessType),
},
Expand Down

0 comments on commit bec0341

Please sign in to comment.