-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16e4355
commit 820fa10
Showing
6 changed files
with
87 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from abc import abstractmethod | ||
from typing import Optional | ||
|
||
from octoploy.api.Kubectl import K8sApi | ||
from octoploy.k8s.BaseObj import BaseObj | ||
|
||
|
||
class DeploymentMode: | ||
""" | ||
Defines how an object should be deployed | ||
""" | ||
_api: K8sApi | ||
|
||
def use_api(self, api: K8sApi): | ||
self._api = api | ||
|
||
@abstractmethod | ||
def deploy(self, k8s_object: BaseObj, existing_object: Optional[BaseObj], namespace: str): | ||
pass | ||
|
||
|
||
class ReplaceDeploymentMode(DeploymentMode): | ||
""" | ||
Replace the object | ||
""" | ||
|
||
def deploy(self, k8s_object: BaseObj, existing_object: Optional[BaseObj], namespace: str): | ||
self._api.replace(k8s_object.as_string(), namespace=namespace) | ||
|
||
|
||
class ApplyDeploymentMode(DeploymentMode): | ||
""" | ||
Apply the object | ||
""" | ||
|
||
def deploy(self, k8s_object: BaseObj, existing_object: Optional[BaseObj], namespace: str): | ||
self._api.apply(k8s_object.as_string(), namespace=namespace) |
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