Skip to content

Commit

Permalink
adding environment_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
malachi-constant committed Nov 21, 2023
1 parent 35f64fd commit 7d79f81
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions seedfarmer/commands/_module_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def deploy_module(
extra_post_build_commands=["cd module/"] + _phases.post_build.commands + md5_put + metadata_put,
extra_env_vars=env_vars,
codebuild_compute_type=module_manifest.deploy_spec.build_type,
codebuild_environment_type=module_manifest.deploy_spec.environment_type,
codebuild_role_name=module_role_name,
codebuild_image=module_manifest.codebuild_image
if module_manifest.codebuild_image is not None
Expand Down Expand Up @@ -244,6 +245,7 @@ def destroy_module(
extra_post_build_commands=["cd module/"] + _phases.post_build.commands + remove_ssm,
extra_env_vars=env_vars,
codebuild_compute_type=module_manifest.deploy_spec.build_type,
codebuild_environment_type=module_manifest.deploy_spec.environment_type,
codebuild_role_name=module_role_name,
codebuild_image=module_manifest.codebuild_image
if module_manifest.codebuild_image is not None
Expand Down Expand Up @@ -284,6 +286,7 @@ def _execute_module_commands(
extra_post_build_commands: Optional[List[str]] = None,
extra_env_vars: Optional[Dict[str, Any]] = None,
codebuild_compute_type: Optional[str] = None,
codebuild_environment_type: Optional[str] = None,
codebuild_role_name: Optional[str] = None,
codebuild_image: Optional[str] = None,
) -> Tuple[str, Optional[Dict[str, str]]]:
Expand Down Expand Up @@ -313,6 +316,7 @@ def _session_getter() -> Session:
codebuild_image=codebuild_image,
bundle_id=f"{deployment_name}-{group_name}-{module_manifest_name}",
codebuild_compute_type=codebuild_compute_type,
codebuild_environment_type=codebuild_environment_type,
extra_files=extra_file_bundle,
boto3_session=session_getter,
)
Expand All @@ -331,6 +335,7 @@ def _execute_module_commands(
extra_post_build_commands: Optional[List[str]] = None,
extra_env_vars: Optional[Dict[str, Any]] = None,
codebuild_compute_type: Optional[str] = None,
codebuild_environment_type: Optional[str] = None,
) -> str:
deploy_info = {
"aws_region": os.environ.get("AWS_DEFAULT_REGION"),
Expand Down
21 changes: 21 additions & 0 deletions seedfarmer/models/_deploy_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ class BuildType(Enum):
BUILD_LAMBDA_10GB = "BUILD_LAMBDA_10GB"


class EnvironmentType(Enum):
ARM_CONTAINER = "ARM_CONTAINER"
LINUX_CONTAINER = "LINUX_CONTAINER"
LINUX_GPU_CONTAINER = "LINUX_GPU_CONTAINER"
WINDOWS_SERVER_2019_CONTAINER = "WINDOWS_SERVER_2019_CONTAINER"
ARM_LAMBDA_CONTAINER = "ARM_LAMBDA_CONTAINER"
LINUX_LAMBDA_CONTAINER = "LINUX_LAMBDA_CONTAINER"


class BuildPhase(CamelModel):
"""
BuildPhase
Expand Down Expand Up @@ -74,12 +83,24 @@ class DeploySpec(CamelModel):
deploy: Optional[ExecutionType] = None
destroy: Optional[ExecutionType] = None
build_type: Optional[str] = None
environment_type: Optional[str] = None
publish_generic_env_variables: Optional[bool] = False

def __init__(self, **data: Any) -> None:
super().__init__(**data)
import logging

_logger: logging.Logger = logging.getLogger(__name__)
_logger.debug("LUCAS DEBUG")
_logger.debug(data.keys())
_logger.debug(data["environment_type"])
if data.get("build_type"):
chk = str(data["build_type"]).upper()
self.build_type = chk if chk in BuildType.__members__.keys() else BuildType.BUILD_GENERAL1_SMALL.value
else:
self.build_type = BuildType.BUILD_GENERAL1_SMALL.value
if data.get("environment_type"):
chk = str(data["environment_type"]).upper()
_logger.debug(f"LUCAS DEBUG: {chk}")
_logger.debug(f"LUCAS DEBUG: {EnvironmentType.__members__.keys()}")
self.environment_type = chk if chk in EnvironmentType.__members__.keys() else None

0 comments on commit 7d79f81

Please sign in to comment.