Implement DigitaloceanTerraform build type
This commit is contained in:
parent
e95ff3ead2
commit
664f3cfd79
7 changed files with 67 additions and 2 deletions
|
@ -3,6 +3,7 @@ from .devops_factory import DevopsFactory
|
|||
from .image import Image
|
||||
from .c4k import C4k
|
||||
from .terraform import TerraformDomain
|
||||
from .digitalocean_terraform import DigitaloceanTerraform
|
||||
from .provs_k3s import K3s
|
||||
from .release import Release
|
||||
from .credentials import Credentials, CredentialMapping, GopassType
|
||||
|
|
|
@ -11,6 +11,7 @@ class BuildType(Enum):
|
|||
C4K = 1
|
||||
K3S = 2
|
||||
TERRAFORM = 3
|
||||
DIGITALOCEAN_TERRAFORM = 4
|
||||
|
||||
|
||||
class MixinType(Enum):
|
||||
|
|
|
@ -4,6 +4,7 @@ from .image import Image
|
|||
from .c4k import C4k
|
||||
from .provs_k3s import K3s
|
||||
from .terraform import TerraformDomain
|
||||
from .digitalocean_terraform import DigitaloceanTerraform
|
||||
from .release import Release
|
||||
from .version import Version
|
||||
|
||||
|
@ -23,8 +24,10 @@ class DevopsFactory:
|
|||
specialized_builds[BuildType.C4K] = C4k(inp)
|
||||
if BuildType.K3S in build_types:
|
||||
specialized_builds[BuildType.K3S] = K3s(inp)
|
||||
if BuildType.K3S in build_types:
|
||||
if BuildType.TERRAFORM in build_types:
|
||||
specialized_builds[BuildType.TERRAFORM] = TerraformDomain(inp)
|
||||
if BuildType.DIGITALOCEAN_TERRAFORM in build_types:
|
||||
specialized_builds[BuildType.DIGITALOCEAN_TERRAFORM] = DigitaloceanTerraform(inp)
|
||||
|
||||
mixins: Dict[MixinType, Validateable] = {}
|
||||
if MixinType.RELEASE in mixin_types:
|
||||
|
|
22
src/main/python/ddadevops/domain/digitalocean_terraform.py
Normal file
22
src/main/python/ddadevops/domain/digitalocean_terraform.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from typing import List
|
||||
from .common import (
|
||||
Validateable,
|
||||
)
|
||||
|
||||
|
||||
class DigitaloceanTerraform(Validateable):
|
||||
def __init__(
|
||||
self,
|
||||
inp: dict,
|
||||
):
|
||||
self.do_api_key = inp.get("do_api_key")
|
||||
self.do_spaces_access_id = inp.get("do_spaces_access_id")
|
||||
self.do_spaces_secret_key = inp.get("do_spaces_secret_key")
|
||||
|
||||
def validate(self) -> List[str]:
|
||||
result = []
|
||||
result += self.__validate_is_not_empty__("do_api_key")
|
||||
result += self.__validate_is_not_empty__("do_spaces_access_id")
|
||||
result += self.__validate_is_not_empty__("do_spaces_secret_key")
|
||||
return result
|
||||
|
|
@ -33,6 +33,9 @@ def devops_config(overrides: dict) -> dict:
|
|||
"tf_debug_print_terraform_command": None,
|
||||
"tf_additional_tfvar_files": None,
|
||||
"tf_terraform_semantic_version": None,
|
||||
"do_api_key": "api_key",
|
||||
"do_spaces_access_id": "spaces_id",
|
||||
"do_spaces_secret_key": "spaces_secret",
|
||||
|
||||
"release_type": "NONE",
|
||||
"release_main_branch": "main",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
from src.main.python.ddadevops.domain import (
|
||||
DevopsFactory, Version
|
||||
DevopsFactory, Version, BuildType, MixinType
|
||||
)
|
||||
|
||||
|
||||
|
@ -29,6 +29,7 @@ def test_devops_factory():
|
|||
}
|
||||
)
|
||||
assert sut is not None
|
||||
assert sut.specialized_builds[BuildType.IMAGE] is not None
|
||||
|
||||
sut = DevopsFactory().build_devops(
|
||||
{
|
||||
|
@ -44,6 +45,24 @@ def test_devops_factory():
|
|||
Version.from_str("1.0.0")
|
||||
)
|
||||
assert sut is not None
|
||||
assert sut.specialized_builds[BuildType.C4K] is not None
|
||||
|
||||
sut = DevopsFactory().build_devops(
|
||||
{
|
||||
"stage": "test",
|
||||
"name": "mybuild",
|
||||
"module": "test_image",
|
||||
"project_root_path": "../../..",
|
||||
"build_types": ["DIGITALOCEAN_TERRAFORM"],
|
||||
"mixin_types": [],
|
||||
"do_api_key": "api_key",
|
||||
"do_spaces_access_id": "spaces_id",
|
||||
"do_spaces_secret_key": "spaces_secret",
|
||||
},
|
||||
Version.from_str("1.0.0")
|
||||
)
|
||||
assert sut is not None
|
||||
assert sut.specialized_builds[BuildType.DIGITALOCEAN_TERRAFORM] is not None
|
||||
|
||||
sut = DevopsFactory().build_devops(
|
||||
{
|
||||
|
@ -61,3 +80,4 @@ def test_devops_factory():
|
|||
Version.from_str("1.0.0")
|
||||
)
|
||||
assert sut is not None
|
||||
assert sut.mixins[MixinType.RELEASE] is not None
|
||||
|
|
15
src/test/python/domain/test_digitalocean_terraform.py
Normal file
15
src/test/python/domain/test_digitalocean_terraform.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from pybuilder.core import Project
|
||||
from pathlib import Path
|
||||
from src.main.python.ddadevops.domain import (
|
||||
BuildType,
|
||||
DigitaloceanTerraform,
|
||||
)
|
||||
from .helper import devops_config
|
||||
|
||||
|
||||
def test_digitalocean_terraform():
|
||||
sut = DigitaloceanTerraform(devops_config({'do_api_key': 'api_key',
|
||||
'do_spaces_access_id': 'spaces_id',
|
||||
'do_spaces_secret_key': 'spaces_secret'}))
|
||||
assert sut is not None
|
||||
assert sut.is_valid()
|
Loading…
Reference in a new issue