-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce KPOps operation and manifest resources for deployment
- Loading branch information
Showing
21 changed files
with
290 additions
and
15 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
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
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
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,9 @@ | ||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
|
||
|
||
class OperationMode(str, Enum): | ||
ARGO = "argo" | ||
MANIFEST = "manifest" | ||
STANDARD = "standard" |
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from collections.abc import Mapping, Sequence | ||
from collections.abc import Mapping | ||
from typing import Any, TypeAlias | ||
|
||
# representation of final resource for component, e.g. a list of Kubernetes manifests | ||
Resource: TypeAlias = Sequence[Mapping[str, Any]] | ||
Resource: TypeAlias = list[Mapping[str, Any]] |
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
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
Empty file.
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,37 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from kpops.api.operation import OperationMode | ||
from kpops.manifestors.manifestor import Manifestor | ||
|
||
if TYPE_CHECKING: | ||
from kpops.components.base_components import HelmApp | ||
from kpops.components.base_components.models.resource import Resource | ||
|
||
|
||
class HelmAppManifestor(Manifestor): | ||
"""Manifestor for the HelmApp component.""" | ||
|
||
def generate_annotations(self) -> dict[str, str]: | ||
"""Generate annotations for HelmApp based on operation mode.""" | ||
match self.operation_mode: | ||
case OperationMode.ARGO: | ||
return {"argocd.argoproj.io/sync-wave": "1"} | ||
case _: | ||
return {} | ||
|
||
def generate_manifest(self, helm_app: HelmApp) -> Resource: | ||
"""Generate the Helm manifest for HelmApp.""" | ||
values = helm_app.to_helm_values() | ||
annotations = self.generate_annotations() | ||
if annotations: | ||
values["annotations"] = annotations | ||
|
||
return helm_app.helm.template( | ||
helm_app.helm_release_name, | ||
helm_app.helm_chart, | ||
helm_app.namespace, | ||
values, | ||
helm_app.template_flags, | ||
) |
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,27 @@ | ||
from __future__ import annotations | ||
|
||
from abc import ABC, abstractmethod | ||
from typing import TYPE_CHECKING | ||
|
||
from kpops.config import get_config | ||
|
||
if TYPE_CHECKING: | ||
from kpops.components.base_components import HelmApp | ||
from kpops.components.base_components.models.resource import Resource | ||
|
||
|
||
class Manifestor(ABC): | ||
"""Base class for generating manifests for different components.""" | ||
|
||
def __init__(self): | ||
self.operation_mode = get_config().operation_mode | ||
|
||
@abstractmethod | ||
def generate_annotations(self) -> dict[str, str]: | ||
"""Generate the annotations for the component based on the operation mode.""" | ||
... | ||
|
||
@abstractmethod | ||
def generate_manifest(self, helm_app: HelmApp) -> Resource: | ||
"""Generate the Helm manifest for the component.""" | ||
... |
Oops, something went wrong.